Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PointOctreeTest Remove Error #11

Open
ricaun opened this issue May 11, 2023 · 1 comment
Open

PointOctreeTest Remove Error #11

ricaun opened this issue May 11, 2023 · 1 comment

Comments

@ricaun
Copy link
Contributor

ricaun commented May 11, 2023

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
Copy link
Contributor Author

ricaun commented May 11, 2023

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant