-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
PointOctree with 8 or fewer points fails to retrieve leaves #40
Comments
As a workaround, I'm adding 9 "dummy points" at initialization for now. |
Here is a failing test case (append to test("retrieves leaves when octree is small", (t) => {
const octree = new PointOctree(box.min, box.max);
octree.set(new Vector3(0.0, 0, 0), data0);
octree.set(new Vector3(0.1, 0, 0), data1);
octree.set(new Vector3(0.2, 0, 0), data2);
const found = [];
for (let node of octree.leaves()) {
if (!node.data) continue;
const { points } = node.data;
if (points) {
for (let point of points) found.push(point);
}
}
t.is(found.length, 3, "should find points");
}); |
Thanks for the report! Would you like to add the failing test with a PR? I've pushed some minor changes just now, so make sure to update beforehand if you do. |
Also, to clarify: this is technically not a bug since the Changing the following line to pass in sparse-octree/src/core/Octree.ts Line 231 in 4c9af67
|
Ok, I've added tests. Thanks for the help! Should line 243 also be passed sparse-octree/src/core/Octree.ts Line 243 in 4c9af67
|
I've added a PR to fix based on your suggestion, and assumed "yes" to my question above, but I can fix / change if the answer is "no". |
I think I'm describing the issue properly, although I'm a bit new to octrees in general, so any help would be appreciated.
I'm creating a PointOctree to represent the centerpoints of objects in a scene. What I'm seeing is that when my worlds have fewer then 8 items, calling
leaves(frustum)
returns an empty iterator.I can see that the transition happens between when
root.data
has 8 elements, and whenroot.data
becomes null (presumably because adding the 9th item shifts points + data down into lower children leaves).The text was updated successfully, but these errors were encountered: