@Test public void testGetElementsContainingPointUpwards() { rootQuad.add(qABox1); rootQuad.add(qABox2); rootQuad.add(qABox3); rootQuad.add(qABox4); Array<CollisionBox> collisionBoxs = qABox1.getQuad().getElementsContainingPoint(new Point(16, 16), QuadTreeSearchDirection.UPWARDS); Assert.assertEquals(1, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(qABox1, false)); collisionBoxs = qABox1.getQuad().getElementsContainingPoint(new Point(112, 16)); Assert.assertEquals(0, collisionBoxs.size); collisionBoxs = qABox1.getQuad().getElementsContainingPoint(new Point(112, 16), QuadTreeSearchDirection.UPWARDS); Assert.assertEquals(1, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(qABox2, false)); collisionBoxs = qABox3.getQuad().getElementsContainingPoint(new Point(16, 112)); Assert.assertEquals(1, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(qABox3, false)); collisionBoxs = qABox4.getQuad().getElementsContainingPoint(new Point(112, 112)); Assert.assertEquals(1, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(qABox4, false)); }
private void getElementsContainingPointUpwards(Array<T> result, Point point, boolean firstInvocation) { lock.lockRead(); if (elements != null){ addElementsContainingPoint(result, point); } if (firstInvocation && topLeft != null){ if (topLeft.contains(point)){ topLeft.getElementsContainingPoint(result, point); } if (topRight.contains(point)){ topRight.getElementsContainingPoint(result, point); } if (bottomLeft.contains(point)){ bottomLeft.getElementsContainingPoint(result, point); } if (bottomRight.contains(point)){ bottomRight.getElementsContainingPoint(result, point); } } if (parent != null){ if (parent.topLeft != this && (parent.topLeft.contains(point) || parent.topLeft.contains(point))) { parent.topLeft.getElementsContainingPoint(result, point); } if (parent.topRight != this && (parent.topRight.contains(point) || parent.topRight.contains(point))) { parent.topRight.getElementsContainingPoint(result, point); } if (parent.bottomLeft != this && (parent.bottomLeft.contains(point) || parent.bottomLeft.contains(point))) { parent.bottomLeft.getElementsContainingPoint(result, point); } if (parent.bottomRight != this && (parent.bottomRight.contains(point) || parent.bottomRight.contains(point))) { parent.bottomRight.getElementsContainingPoint(result, point); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingPointUpwards(result, point, false); } lock.unlockRead(); }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { private void getElementsContainingPointUpwards(Array<T> result, Point point, boolean firstInvocation) { lock.lockRead(); if (elements != null){ addElementsContainingPoint(result, point); } if (firstInvocation && topLeft != null){ if (topLeft.contains(point)){ topLeft.getElementsContainingPoint(result, point); } if (topRight.contains(point)){ topRight.getElementsContainingPoint(result, point); } if (bottomLeft.contains(point)){ bottomLeft.getElementsContainingPoint(result, point); } if (bottomRight.contains(point)){ bottomRight.getElementsContainingPoint(result, point); } } if (parent != null){ if (parent.topLeft != this && (parent.topLeft.contains(point) || parent.topLeft.contains(point))) { parent.topLeft.getElementsContainingPoint(result, point); } if (parent.topRight != this && (parent.topRight.contains(point) || parent.topRight.contains(point))) { parent.topRight.getElementsContainingPoint(result, point); } if (parent.bottomLeft != this && (parent.bottomLeft.contains(point) || parent.bottomLeft.contains(point))) { parent.bottomLeft.getElementsContainingPoint(result, point); } if (parent.bottomRight != this && (parent.bottomRight.contains(point) || parent.bottomRight.contains(point))) { parent.bottomRight.getElementsContainingPoint(result, point); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingPointUpwards(result, point, false); } lock.unlockRead(); } }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { private void getElementsContainingPointUpwards(Array<T> result, Point point, boolean firstInvocation) { lock.lockRead(); if (elements != null){ addElementsContainingPoint(result, point); } if (firstInvocation && topLeft != null){ if (topLeft.contains(point)){ topLeft.getElementsContainingPoint(result, point); } if (topRight.contains(point)){ topRight.getElementsContainingPoint(result, point); } if (bottomLeft.contains(point)){ bottomLeft.getElementsContainingPoint(result, point); } if (bottomRight.contains(point)){ bottomRight.getElementsContainingPoint(result, point); } } if (parent != null){ if (parent.topLeft != this && (parent.topLeft.contains(point) || parent.topLeft.contains(point))) { parent.topLeft.getElementsContainingPoint(result, point); } if (parent.topRight != this && (parent.topRight.contains(point) || parent.topRight.contains(point))) { parent.topRight.getElementsContainingPoint(result, point); } if (parent.bottomLeft != this && (parent.bottomLeft.contains(point) || parent.bottomLeft.contains(point))) { parent.bottomLeft.getElementsContainingPoint(result, point); } if (parent.bottomRight != this && (parent.bottomRight.contains(point) || parent.bottomRight.contains(point))) { parent.bottomRight.getElementsContainingPoint(result, point); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingPointUpwards(result, point, false); } lock.unlockRead(); } ConcurrentRegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  ConcurrentRegionQuadTree(int elementLimit, float x, float y, float width, float height);  ConcurrentRegionQuadTree(ConcurrentRegionQuadTree<T> parent, float x, float y, float width, float height);  ConcurrentRegionQuadTree(float minimumQuadWidth, float minimumQuadHeight, int elementLimitPerQuad,
			int mergeWatermark, float x, float y, float width, float height); }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { private void getElementsContainingPointUpwards(Array<T> result, Point point, boolean firstInvocation) { lock.lockRead(); if (elements != null){ addElementsContainingPoint(result, point); } if (firstInvocation && topLeft != null){ if (topLeft.contains(point)){ topLeft.getElementsContainingPoint(result, point); } if (topRight.contains(point)){ topRight.getElementsContainingPoint(result, point); } if (bottomLeft.contains(point)){ bottomLeft.getElementsContainingPoint(result, point); } if (bottomRight.contains(point)){ bottomRight.getElementsContainingPoint(result, point); } } if (parent != null){ if (parent.topLeft != this && (parent.topLeft.contains(point) || parent.topLeft.contains(point))) { parent.topLeft.getElementsContainingPoint(result, point); } if (parent.topRight != this && (parent.topRight.contains(point) || parent.topRight.contains(point))) { parent.topRight.getElementsContainingPoint(result, point); } if (parent.bottomLeft != this && (parent.bottomLeft.contains(point) || parent.bottomLeft.contains(point))) { parent.bottomLeft.getElementsContainingPoint(result, point); } if (parent.bottomRight != this && (parent.bottomRight.contains(point) || parent.bottomRight.contains(point))) { parent.bottomRight.getElementsContainingPoint(result, point); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingPointUpwards(result, point, false); } lock.unlockRead(); } ConcurrentRegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  ConcurrentRegionQuadTree(int elementLimit, float x, float y, float width, float height);  ConcurrentRegionQuadTree(ConcurrentRegionQuadTree<T> parent, float x, float y, float width, float height);  ConcurrentRegionQuadTree(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> elements); @Override boolean add(T element); @Override void removeAll(Array<T> elementsToRemove); @Override boolean remove(T element); @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); }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { private void getElementsContainingPointUpwards(Array<T> result, Point point, boolean firstInvocation) { lock.lockRead(); if (elements != null){ addElementsContainingPoint(result, point); } if (firstInvocation && topLeft != null){ if (topLeft.contains(point)){ topLeft.getElementsContainingPoint(result, point); } if (topRight.contains(point)){ topRight.getElementsContainingPoint(result, point); } if (bottomLeft.contains(point)){ bottomLeft.getElementsContainingPoint(result, point); } if (bottomRight.contains(point)){ bottomRight.getElementsContainingPoint(result, point); } } if (parent != null){ if (parent.topLeft != this && (parent.topLeft.contains(point) || parent.topLeft.contains(point))) { parent.topLeft.getElementsContainingPoint(result, point); } if (parent.topRight != this && (parent.topRight.contains(point) || parent.topRight.contains(point))) { parent.topRight.getElementsContainingPoint(result, point); } if (parent.bottomLeft != this && (parent.bottomLeft.contains(point) || parent.bottomLeft.contains(point))) { parent.bottomLeft.getElementsContainingPoint(result, point); } if (parent.bottomRight != this && (parent.bottomRight.contains(point) || parent.bottomRight.contains(point))) { parent.bottomRight.getElementsContainingPoint(result, point); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingPointUpwards(result, point, false); } lock.unlockRead(); } ConcurrentRegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  ConcurrentRegionQuadTree(int elementLimit, float x, float y, float width, float height);  ConcurrentRegionQuadTree(ConcurrentRegionQuadTree<T> parent, float x, float y, float width, float height);  ConcurrentRegionQuadTree(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> elements); @Override boolean add(T element); @Override void removeAll(Array<T> elementsToRemove); @Override boolean remove(T element); @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);  }