@Test public void testGetElementsContainingAreaUpwards() { rootQuad.add(qABox1); rootQuad.add(qABox2); rootQuad.add(qABox3); rootQuad.add(qABox4); Array<CollisionBox> collisionBoxs = qABox1.getQuad().getElementsContainingArea( new CollisionBox(16, 16, 1, 1), QuadTreeSearchDirection.UPWARDS, true); Assert.assertEquals(1, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(qABox1, false)); collisionBoxs = qABox1.getQuad().getElementsContainingArea(new CollisionBox(112, 16, 1, 1), true); Assert.assertEquals(0, collisionBoxs.size); collisionBoxs = qABox1.getQuad().getElementsContainingArea(new CollisionBox(112, 16, 1, 1), QuadTreeSearchDirection.UPWARDS, true); Assert.assertEquals(1, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(qABox2, false)); collisionBoxs = qABox3.getQuad().getElementsContainingArea(new CollisionBox(16, 112, 1, 1), QuadTreeSearchDirection.UPWARDS, true); Assert.assertEquals(1, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(qABox3, false)); collisionBoxs = qABox4.getQuad().getElementsContainingArea(new CollisionBox(112, 112, 1, 1), QuadTreeSearchDirection.UPWARDS, true); Assert.assertEquals(1, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(qABox4, false)); collisionBoxs = qABox1.getQuad().getElementsContainingArea( new CollisionBox(16, 16, 20, 10), QuadTreeSearchDirection.UPWARDS, false); Assert.assertEquals(1, collisionBoxs.size); Assert.assertEquals(true, collisionBoxs.contains(qABox1, false)); collisionBoxs = qABox1.getQuad().getElementsContainingArea( new CollisionBox(16, 16, 20, 10), QuadTreeSearchDirection.UPWARDS, true); Assert.assertEquals(0, collisionBoxs.size); Assert.assertEquals(false, collisionBoxs.contains(qABox1, false)); collisionBoxs = qABox1.getQuad().getElementsContainingArea( new CollisionBox(0.5f, 0.5f, 40, 40), QuadTreeSearchDirection.UPWARDS, false); Assert.assertEquals(0, collisionBoxs.size); Assert.assertEquals(false, collisionBoxs.contains(qABox1, false)); collisionBoxs = qABox1.getQuad().getElementsContainingArea( new CollisionBox(0.5f, 0.5f, 40, 40), QuadTreeSearchDirection.UPWARDS, true); Assert.assertEquals(0, collisionBoxs.size); Assert.assertEquals(false, collisionBoxs.contains(qABox1, false)); }
protected void getElementsContainingAreaUpwards(Array<T> result, Shape area, boolean firstInvocation, boolean entirelyContained) { lock.lockRead(); if (elements != null) { addElementsContainingArea(result, area, entirelyContained); } if (firstInvocation && topLeft != null){ if (area.contains(topLeft) || area.intersects(topLeft)){ topLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(topRight) || area.intersects(topRight)){ topRight.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomLeft) || area.intersects(bottomLeft)){ bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomRight) || area.intersects(bottomRight)){ bottomRight.getElementsContainingArea(result, area, entirelyContained); } } if (parent != null) { if (parent.topLeft != this && (area.contains(parent.topLeft) || area.intersects(parent.topLeft))) { parent.topLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.topRight != this && (area.contains(parent.topRight) || area.intersects(parent.topRight))) { parent.topRight.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomLeft != this && (area.contains(parent.bottomLeft) || area.intersects(parent.bottomLeft))) { parent.bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomRight != this && (area.contains(parent.bottomRight) || area.intersects(parent.bottomRight))) { parent.bottomRight.getElementsContainingArea(result, area, entirelyContained); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingAreaUpwards(result, area, false, entirelyContained); } lock.unlockRead(); }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { protected void getElementsContainingAreaUpwards(Array<T> result, Shape area, boolean firstInvocation, boolean entirelyContained) { lock.lockRead(); if (elements != null) { addElementsContainingArea(result, area, entirelyContained); } if (firstInvocation && topLeft != null){ if (area.contains(topLeft) || area.intersects(topLeft)){ topLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(topRight) || area.intersects(topRight)){ topRight.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomLeft) || area.intersects(bottomLeft)){ bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomRight) || area.intersects(bottomRight)){ bottomRight.getElementsContainingArea(result, area, entirelyContained); } } if (parent != null) { if (parent.topLeft != this && (area.contains(parent.topLeft) || area.intersects(parent.topLeft))) { parent.topLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.topRight != this && (area.contains(parent.topRight) || area.intersects(parent.topRight))) { parent.topRight.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomLeft != this && (area.contains(parent.bottomLeft) || area.intersects(parent.bottomLeft))) { parent.bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomRight != this && (area.contains(parent.bottomRight) || area.intersects(parent.bottomRight))) { parent.bottomRight.getElementsContainingArea(result, area, entirelyContained); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingAreaUpwards(result, area, false, entirelyContained); } lock.unlockRead(); } }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { protected void getElementsContainingAreaUpwards(Array<T> result, Shape area, boolean firstInvocation, boolean entirelyContained) { lock.lockRead(); if (elements != null) { addElementsContainingArea(result, area, entirelyContained); } if (firstInvocation && topLeft != null){ if (area.contains(topLeft) || area.intersects(topLeft)){ topLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(topRight) || area.intersects(topRight)){ topRight.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomLeft) || area.intersects(bottomLeft)){ bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomRight) || area.intersects(bottomRight)){ bottomRight.getElementsContainingArea(result, area, entirelyContained); } } if (parent != null) { if (parent.topLeft != this && (area.contains(parent.topLeft) || area.intersects(parent.topLeft))) { parent.topLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.topRight != this && (area.contains(parent.topRight) || area.intersects(parent.topRight))) { parent.topRight.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomLeft != this && (area.contains(parent.bottomLeft) || area.intersects(parent.bottomLeft))) { parent.bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomRight != this && (area.contains(parent.bottomRight) || area.intersects(parent.bottomRight))) { parent.bottomRight.getElementsContainingArea(result, area, entirelyContained); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingAreaUpwards(result, area, false, entirelyContained); } 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> { protected void getElementsContainingAreaUpwards(Array<T> result, Shape area, boolean firstInvocation, boolean entirelyContained) { lock.lockRead(); if (elements != null) { addElementsContainingArea(result, area, entirelyContained); } if (firstInvocation && topLeft != null){ if (area.contains(topLeft) || area.intersects(topLeft)){ topLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(topRight) || area.intersects(topRight)){ topRight.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomLeft) || area.intersects(bottomLeft)){ bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomRight) || area.intersects(bottomRight)){ bottomRight.getElementsContainingArea(result, area, entirelyContained); } } if (parent != null) { if (parent.topLeft != this && (area.contains(parent.topLeft) || area.intersects(parent.topLeft))) { parent.topLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.topRight != this && (area.contains(parent.topRight) || area.intersects(parent.topRight))) { parent.topRight.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomLeft != this && (area.contains(parent.bottomLeft) || area.intersects(parent.bottomLeft))) { parent.bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomRight != this && (area.contains(parent.bottomRight) || area.intersects(parent.bottomRight))) { parent.bottomRight.getElementsContainingArea(result, area, entirelyContained); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingAreaUpwards(result, area, false, entirelyContained); } 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> { protected void getElementsContainingAreaUpwards(Array<T> result, Shape area, boolean firstInvocation, boolean entirelyContained) { lock.lockRead(); if (elements != null) { addElementsContainingArea(result, area, entirelyContained); } if (firstInvocation && topLeft != null){ if (area.contains(topLeft) || area.intersects(topLeft)){ topLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(topRight) || area.intersects(topRight)){ topRight.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomLeft) || area.intersects(bottomLeft)){ bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (area.contains(bottomRight) || area.intersects(bottomRight)){ bottomRight.getElementsContainingArea(result, area, entirelyContained); } } if (parent != null) { if (parent.topLeft != this && (area.contains(parent.topLeft) || area.intersects(parent.topLeft))) { parent.topLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.topRight != this && (area.contains(parent.topRight) || area.intersects(parent.topRight))) { parent.topRight.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomLeft != this && (area.contains(parent.bottomLeft) || area.intersects(parent.bottomLeft))) { parent.bottomLeft.getElementsContainingArea(result, area, entirelyContained); } if (parent.bottomRight != this && (area.contains(parent.bottomRight) || area.intersects(parent.bottomRight))) { parent.bottomRight.getElementsContainingArea(result, area, entirelyContained); } ((ConcurrentRegionQuadTree<T>)parent).getElementsContainingAreaUpwards(result, area, false, entirelyContained); } 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);  }