@Test public void testGetElementsIntersectingLineSegment() { rootQuad.add(box1); rootQuad.add(box2); rootQuad.add(box3); rootQuad.add(box4); Array<CollisionBox> collisionBoxs = rootQuad.getElementsIntersectingLineSegment(new LineSegment(0, 0, 128, 128)); Assert.assertEquals(2, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(box1, false)); Assert.assertEquals(true, collisionBoxs.contains(box4, false)); CollisionBox collisionBox5 = new CollisionBox(24, 24, 2, 2); CollisionBox collisionBox6 = new CollisionBox(48, 48, 32, 32); CollisionBox collisionBox7 = new CollisionBox(12, 48, 8, 8); rootQuad.add(collisionBox5); rootQuad.add(collisionBox6); rootQuad.add(collisionBox7); collisionBoxs = rootQuad.getElementsIntersectingLineSegment(new LineSegment(0, 0, 128, 128)); Assert.assertEquals(4, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(box1, false)); Assert.assertEquals(true, collisionBoxs.contains(box4, false)); Assert.assertEquals(true, collisionBoxs.contains(collisionBox5, false)); Assert.assertEquals(true, collisionBoxs.contains(collisionBox6, false)); }
@Override public void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment) { if (topLeft != null) { if (intersects(topLeft, lineSegment)) { topLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(topRight, lineSegment)) { topRight.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomLeft, lineSegment)) { bottomLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomRight, lineSegment)) { bottomRight.getElementsIntersectingLineSegment(result, lineSegment); } } addElementsIntersectingLineSegment(result, lineSegment); }
RegionQuadTree extends PointQuadTree<T> { @Override public void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment) { if (topLeft != null) { if (intersects(topLeft, lineSegment)) { topLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(topRight, lineSegment)) { topRight.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomLeft, lineSegment)) { bottomLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomRight, lineSegment)) { bottomRight.getElementsIntersectingLineSegment(result, lineSegment); } } addElementsIntersectingLineSegment(result, lineSegment); } }
RegionQuadTree extends PointQuadTree<T> { @Override public void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment) { if (topLeft != null) { if (intersects(topLeft, lineSegment)) { topLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(topRight, lineSegment)) { topRight.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomLeft, lineSegment)) { bottomLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomRight, lineSegment)) { bottomRight.getElementsIntersectingLineSegment(result, lineSegment); } } addElementsIntersectingLineSegment(result, lineSegment); } RegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  RegionQuadTree(int elementLimit, float x, float y, float width, float height);  RegionQuadTree(RegionQuadTree<T> parent, float x, float y, float width, float height);  RegionQuadTree(float minimumQuadWidth, float minimumQuadHeight, int elementLimitPerQuad, int mergeWatermark,
			float x, float y, float width, float height); }
RegionQuadTree extends PointQuadTree<T> { @Override public void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment) { if (topLeft != null) { if (intersects(topLeft, lineSegment)) { topLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(topRight, lineSegment)) { topRight.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomLeft, lineSegment)) { bottomLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomRight, lineSegment)) { bottomRight.getElementsIntersectingLineSegment(result, lineSegment); } } addElementsIntersectingLineSegment(result, lineSegment); } RegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  RegionQuadTree(int elementLimit, float x, float y, float width, float height);  RegionQuadTree(RegionQuadTree<T> parent, float x, float y, float width, float height);  RegionQuadTree(float minimumQuadWidth, float minimumQuadHeight, int elementLimitPerQuad, int mergeWatermark,
			float x, float y, float width, float height); @Override void debugRender(Graphics g); @Override void addAll(Array<T> elementsToAdd); @Override boolean add(T element); @Override boolean remove(T element); @Override void clear(); @Override void getElementsWithinArea(Array<T> result, Shape area); @Override void getElementsWithinArea(Array<T> result, Shape area, QuadTreeSearchDirection searchDirection); @Override Array<T> getElementsContainingArea(Shape area, boolean entirelyContained); @Override Array<T> getElementsContainingArea(Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained); @Override void getElementsContainingArea(Array<T> result, Shape area, boolean entirelyContained); @Override void getElementsContainingArea(Array<T> result, Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained); @Override void getElementsContainingPoint(Array<T> result, Point point); @Override void getElementsContainingPoint(Array<T> result, Point point, QuadTreeSearchDirection searchDirection); @Override void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment); @Override void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment, QuadTreeSearchDirection searchDirection); @Override Array<T> getElements(); @Override void getElements(Array<T> result); @Override int getTotalElements(); @Override void positionChanged(T moved); }
RegionQuadTree extends PointQuadTree<T> { @Override public void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment) { if (topLeft != null) { if (intersects(topLeft, lineSegment)) { topLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(topRight, lineSegment)) { topRight.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomLeft, lineSegment)) { bottomLeft.getElementsIntersectingLineSegment(result, lineSegment); } if (intersects(bottomRight, lineSegment)) { bottomRight.getElementsIntersectingLineSegment(result, lineSegment); } } addElementsIntersectingLineSegment(result, lineSegment); } RegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  RegionQuadTree(int elementLimit, float x, float y, float width, float height);  RegionQuadTree(RegionQuadTree<T> parent, float x, float y, float width, float height);  RegionQuadTree(float minimumQuadWidth, float minimumQuadHeight, int elementLimitPerQuad, int mergeWatermark,
			float x, float y, float width, float height); @Override void debugRender(Graphics g); @Override void addAll(Array<T> elementsToAdd); @Override boolean add(T element); @Override boolean remove(T element); @Override void clear(); @Override void getElementsWithinArea(Array<T> result, Shape area); @Override void getElementsWithinArea(Array<T> result, Shape area, QuadTreeSearchDirection searchDirection); @Override Array<T> getElementsContainingArea(Shape area, boolean entirelyContained); @Override Array<T> getElementsContainingArea(Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained); @Override void getElementsContainingArea(Array<T> result, Shape area, boolean entirelyContained); @Override void getElementsContainingArea(Array<T> result, Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained); @Override void getElementsContainingPoint(Array<T> result, Point point); @Override void getElementsContainingPoint(Array<T> result, Point point, QuadTreeSearchDirection searchDirection); @Override void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment); @Override void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment, QuadTreeSearchDirection searchDirection); @Override Array<T> getElements(); @Override void getElements(Array<T> result); @Override int getTotalElements(); @Override void positionChanged(T moved);  }