PointOctreeTest Remove Error
ricaun opened this issue · 1 comments
ricaun commented
I was messing around with PointOctree
and found some issues by trying to remove a point in some specific location, I guess is some round stuff related.
The test below fails in the i = 50
with the vector <25. 25. 25>
[Fact]
public void RemoveTest2()
{
var size = 0.5f;
// Add points.
for (int i = 1; i < 100; ++i)
_octree.Add(i, new Vector3(size * i));
// Should remove geometries based on object and bounding box
for (int i = 1; i < 100; ++i)
{
_octree.Remove(i, new Vector3(size * i))
.ShouldBeTrue($"{i} {new Vector3(size * i)}"); // Fail in 50 <25. 25. 25>
}
_octree.Count.ShouldBe(0);
}
ricaun commented
The same problem happens if you edit the original RemoveTest
and remove the first part.
Just add and remove by point. In that case, fails in i=25
.
I noticed using a different initial octree size you have points in the border of the octree, in the test the octree size is 50 and the test fails when i = 50/2.
[Fact]
public void RemoveTest()
{
//// Add points
//for (int i = 1; i < 100; ++i)
// _octree.Add(i, new Vector3(i));
//// Should not remove geometries that are not in the tree
//_octree.Remove(10, Vector3.Zero).ShouldBeFalse();
//_octree.Remove(10, new Vector3(5)).ShouldBeFalse();
//// Should remove geometries based on object
//for (int i = 1; i < 100; ++i)
// _octree.Remove(i).ShouldBeTrue();
//_octree.Count.ShouldBe(0);
// Re-add points.
for (int i = 1; i < 100; ++i)
_octree.Add(i, new Vector3(i));
// Should remove geometries based on object and bounding box
for (int i = 1; i < 100; ++i)
_octree.Remove(i, new Vector3(i)).ShouldBeTrue();
_octree.Count.ShouldBe(0);
}