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

Crash on update of an Entity #1

Open
neo-expert opened this issue Sep 3, 2019 · 1 comment
Open

Crash on update of an Entity #1

neo-expert opened this issue Sep 3, 2019 · 1 comment

Comments

@neo-expert
Copy link

The following test case crashes:

 @Test
   public void shouldDetectRayIntersection() {
      // Given
      AABBTree<TestEntity> tree = givenTree();
      Rayf ray = new Rayf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
      TestEntity entity1 = new TestEntity(1, 2.0f, 0.0f, 3.0f, 3.0f);
      TestEntity entity2 = new TestEntity(2, -5.0f, 0.0f, 3.0f, 2.0f);
      tree.add(entity1);
      tree.add(entity2);

      // When
      List<TestEntity> intersecting = new ArrayList<>();
      tree.detectRayIntersection(ray, intersecting);

      tree.update(entity1);
      tree.update(entity2);
      tree.update(entity2);
      tree.update(entity2);

      // Then
      assertEquals(1, intersecting.size());
      assertEquals(1L, intersecting.get(0).getID());
   }

Stacktrace:
java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 3
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:458)
at pl.pateman.dynamicaabbtree.AABBTree.getNodeAt(AABBTree.java:102)
at pl.pateman.dynamicaabbtree.AABBTree.balanceLeft(AABBTree.java:146)
at pl.pateman.dynamicaabbtree.AABBTree.balanceNode(AABBTree.java:199)
at pl.pateman.dynamicaabbtree.AABBTree.syncUpHierarchy(AABBTree.java:207)
at pl.pateman.dynamicaabbtree.AABBTree.insertNode(AABBTree.java:246)
at pl.pateman.dynamicaabbtree.AABBTree.add(AABBTree.java:292)
at pl.pateman.dynamicaabbtree.AABBTree.update(AABBTree.java:312)
at pl.pateman.dynamicaabbtree.AABBTreeTest.shouldDetectRayIntersection(AABBTreeTest.java:367)

@gviznyuk
Copy link

Did you managed to fix this?

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

2 participants