public class PointQuadTree<T extends Positionable> extends Rectangle implements QuadTree<T>
| Modifier and Type | Field and Description |
|---|---|
protected PointQuadTree<T> |
bottomLeft |
protected PointQuadTree<T> |
bottomRight |
static Color |
BOUNDS_COLOR |
protected boolean |
cleanupRequired |
static float |
DEFAULT_MINIMUM_QUAD_SIZE |
static Color |
ELEMENT_COLOR |
protected int |
elementLimitPerQuad |
protected org.mini2Dx.gdx.utils.Array<T> |
elements |
protected Rectangle |
elementsBounds |
protected int |
mergeWatermark |
protected float |
minimumQuadHeight |
protected float |
minimumQuadWidth |
protected PointQuadTree<T> |
parent |
protected org.mini2Dx.gdx.utils.Queue<PointQuadTree<T>> |
pool |
static Color |
QUAD_COLOR |
protected PointQuadTree<T> |
topLeft |
protected PointQuadTree<T> |
topRight |
protected int |
totalElementsCache |
disposed, geometry, positionChangeListeners, sizeChangeListeners| Constructor and Description |
|---|
PointQuadTree(float minimumQuadWidth,
float minimumQuadHeight,
int elementLimitPerQuad,
int mergeWatermark,
float x,
float y,
float width,
float height)
Constructs a
PointQuadTree with a specified minimum quad size,
element limit and watermark |
PointQuadTree(int elementLimitPerQuad,
float x,
float y,
float width,
float height)
Constructs a
PointQuadTree with a specified element limit and no
merging watermark. |
PointQuadTree(int elementLimitPerQuad,
int mergeWatermark,
float x,
float y,
float width,
float height)
Constructs a
PointQuadTree with a specified element limit and
watermark |
PointQuadTree(PointQuadTree<T> parent,
float x,
float y,
float width,
float height)
Constructs a
PointQuadTree as a child of another
PointQuadTree |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T element)
Adds an element to this
QuadTree |
void |
addAll(org.mini2Dx.gdx.utils.Array<T> elementsToAdd)
Adds all element to this
QuadTree. |
protected boolean |
addElement(T element) |
protected void |
addElementsContainingPoint(org.mini2Dx.gdx.utils.Array<T> result,
Point point) |
protected void |
addElementsIntersectingLineSegment(org.mini2Dx.gdx.utils.Array<T> result,
LineSegment lineSegment) |
protected void |
addElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result,
Shape area) |
protected void |
addElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result,
Shape area,
boolean allElements) |
protected boolean |
addElementToChild(T element) |
protected PointQuadTree<T> |
allocate(PointQuadTree<T> parent,
float x,
float y,
float width,
float height) |
void |
cleanup() |
void |
clear()
Same a
CollisionDetection.removeAll(Array) except the results are not stored |
protected void |
clearTotalElementsCache() |
void |
debugRender(Graphics g) |
protected void |
disposeBounds() |
int |
getElementLimitPerQuad() |
org.mini2Dx.gdx.utils.Array<T> |
getElements() |
void |
getElements(org.mini2Dx.gdx.utils.Array<T> result) |
void |
getElementsContainingArea(org.mini2Dx.gdx.utils.Array<T> result,
Shape area,
boolean entirelyContained) |
void |
getElementsContainingArea(org.mini2Dx.gdx.utils.Array<T> result,
Shape area,
QuadTreeSearchDirection searchDirection,
boolean entirelyContained) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsContainingArea(Shape area,
boolean entirelyContained) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsContainingArea(Shape area,
QuadTreeSearchDirection searchDirection,
boolean entirelyContained) |
void |
getElementsContainingPoint(org.mini2Dx.gdx.utils.Array<T> result,
Point point) |
void |
getElementsContainingPoint(org.mini2Dx.gdx.utils.Array<T> result,
Point point,
QuadTreeSearchDirection searchDirection) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsContainingPoint(Point point) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsContainingPoint(Point point,
QuadTreeSearchDirection searchDirection) |
void |
getElementsIntersectingLineSegment(org.mini2Dx.gdx.utils.Array<T> result,
LineSegment lineSegment) |
void |
getElementsIntersectingLineSegment(org.mini2Dx.gdx.utils.Array<T> result,
LineSegment lineSegment,
QuadTreeSearchDirection searchDirection) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsIntersectingLineSegment(LineSegment lineSegment) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsIntersectingLineSegment(LineSegment lineSegment,
QuadTreeSearchDirection searchDirection) |
void |
getElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result,
Shape area) |
void |
getElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result,
Shape area,
boolean allElements) |
void |
getElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result,
Shape area,
QuadTreeSearchDirection searchDirection) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsWithinArea(Shape area) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsWithinArea(Shape area,
QuadTreeSearchDirection searchDirection) |
void |
getElementsWithinAreaIgnoringEdges(org.mini2Dx.gdx.utils.Array<T> result,
Shape area) |
void |
getElementsWithinAreaIgnoringEdges(org.mini2Dx.gdx.utils.Array<T> result,
Shape area,
QuadTreeSearchDirection searchDirection) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsWithinAreaIgnoringEdges(Shape area) |
org.mini2Dx.gdx.utils.Array<T> |
getElementsWithinAreaIgnoringEdges(Shape area,
QuadTreeSearchDirection searchDirection) |
int |
getMergeWatermark() |
float |
getMinimumQuadHeight() |
float |
getMinimumQuadWidth() |
QuadTree<T> |
getParent() |
int |
getTotalElements() |
int |
getTotalImmediateElements() |
int |
getTotalQuads() |
boolean |
hasChildQuads() |
protected void |
initBounds() |
protected static boolean |
intersects(Rectangle tree,
LineSegment segment) |
protected boolean |
isMergable() |
protected boolean |
isSearchRequired() |
protected void |
markCleanupRequired() |
protected void |
merge() |
void |
positionChanged(T moved) |
boolean |
remove(T element)
Removes an element from this
QuadTree |
void |
removeAll(org.mini2Dx.gdx.utils.Array<T> elementsToRemove)
Removes all elements in this
QuadTree and stores them in an Array |
protected boolean |
removeElement(T element,
boolean clearQuadRef) |
protected boolean |
removeElementFromChild(T element) |
protected void |
subdivide() |
protected boolean |
updateBounds() |
protected boolean |
updateBounds(T element) |
void |
warmupPool(int poolSize) |
void |
warmupPool(int poolSize,
int expectedElementsPerQuad) |
void |
warmupWithDepth(int depth) |
void |
warmupWithObjects(org.mini2Dx.gdx.utils.Array<T> elements) |
contains, contains, contains, contains, contains, copy, dispose, draw, edgeIterator, equals, fill, getCenterX, getCenterY, getDistanceTo, getHeight, getMaxX, getMaxY, getMinX, getMinY, getNumberOfSides, getPolygon, getRotation, getVertices, getWidth, getX, getY, hashCode, intersection, intersects, intersects, intersects, intersects, intersects, intersects, intersectsIgnoringEdges, intersectsLineSegment, intersectsLineSegment, isCircle, lerp, lerp, lerp, rotate, rotateAround, scale, set, set, setCenter, setCenterX, setCenterY, setHeight, setRadius, setRotation, setRotationAround, setSize, setSize, setWidth, setX, setXY, setXY, setY, toString, translateadd, addPostionChangeListener, addSizeChangeListener, clearPositionChangeListeners, clearPositionListeners, clearPositionListeners, clearSizeChangeListeners, clearSizeListeners, clearSizeListeners, getDistanceTo, intersects, moveTowards, moveTowards, notifyPositionChangeListeners, notifyPositionListeners, notifyPositionListeners, notifySizeChangeListeners, notifySizeListeners, notifySizeListeners, removePositionChangeListener, removePositionListener, removePositionListener, removeSizeChangeListener, removeSizeListener, removeSizeListener, setDisposed, setRotationAround, subtractpublic static float DEFAULT_MINIMUM_QUAD_SIZE
public static Color QUAD_COLOR
public static Color BOUNDS_COLOR
public static Color ELEMENT_COLOR
protected org.mini2Dx.gdx.utils.Queue<PointQuadTree<T extends Positionable>> pool
protected PointQuadTree<T extends Positionable> parent
protected PointQuadTree<T extends Positionable> topLeft
protected PointQuadTree<T extends Positionable> topRight
protected PointQuadTree<T extends Positionable> bottomLeft
protected PointQuadTree<T extends Positionable> bottomRight
protected Rectangle elementsBounds
protected org.mini2Dx.gdx.utils.Array<T extends Positionable> elements
protected final int elementLimitPerQuad
protected final int mergeWatermark
protected final float minimumQuadWidth
protected final float minimumQuadHeight
protected int totalElementsCache
protected boolean cleanupRequired
public PointQuadTree(int elementLimitPerQuad,
int mergeWatermark,
float x,
float y,
float width,
float height)
PointQuadTree with a specified element limit and
watermarkelementLimitPerQuad - The maximum number of elements in a quad before it is split
into 4 child PointQuadTreesmergeWatermark - When a parent PointQuadTree's total elements go lower
than this mark, the child PointQuadTrees will be
merged back togetherx - The x coordinate of the PointQuadTreey - The y coordiante of the PointQuadTreewidth - The width of the PointQuadTreeheight - The height of the PointQuadTreepublic PointQuadTree(int elementLimitPerQuad,
float x,
float y,
float width,
float height)
PointQuadTree with a specified element limit and no
merging watermark. As elements are removed, small sized child
PointQuadTrees will not be merged back together.elementLimitPerQuad - The maximum number of elements in a quad before it is split
into 4 child PointQuadTreesx - The x coordinate of the PointQuadTreey - The y coordiante of the PointQuadTreewidth - The width of the PointQuadTreeheight - The height of the PointQuadTreepublic PointQuadTree(PointQuadTree<T> parent, float x, float y, float width, float height)
PointQuadTree as a child of another
PointQuadTreeparent - The parent PointQuadTreex - The x coordinate of the PointQuadTreey - The y coordiante of the PointQuadTreewidth - The width of the PointQuadTreeheight - The height of the PointQuadTreepublic PointQuadTree(float minimumQuadWidth,
float minimumQuadHeight,
int elementLimitPerQuad,
int mergeWatermark,
float x,
float y,
float width,
float height)
PointQuadTree with a specified minimum quad size,
element limit and watermarkminimumQuadWidth - The minimum width of quads. Quads will not subdivide smaller
than this width.minimumQuadHeight - The minimum height of quads. Quads will not subdivide smaller
than this height.elementLimitPerQuad - The maximum number of elements in a quad before it is split
into 4 child PointQuadTreesmergeWatermark - When a parent PointQuadTree's total elements go lower
than this mark, the child PointQuadTrees will be
merged back togetherx - The x coordinate of the PointQuadTreey - The y coordiante of the PointQuadTreewidth - The width of the PointQuadTreeheight - The height of the PointQuadTreepublic void cleanup()
protected void markCleanupRequired()
public void warmupWithDepth(int depth)
public void warmupWithObjects(org.mini2Dx.gdx.utils.Array<T> elements)
public void warmupPool(int poolSize)
public void warmupPool(int poolSize,
int expectedElementsPerQuad)
public void debugRender(Graphics g)
debugRender in interface CollisionDetection<T extends Positionable>public void addAll(org.mini2Dx.gdx.utils.Array<T> elementsToAdd)
CollisionDetectionQuadTree. Note that if an element exists outside of this QuadTree's bounds, it will not be addedaddAll in interface CollisionDetection<T extends Positionable>elementsToAdd - The elements to addpublic boolean add(T element)
CollisionDetectionQuadTreeadd in interface CollisionDetection<T extends Positionable>element - The element to addprotected boolean addElement(T element)
protected void initBounds()
protected void disposeBounds()
protected boolean updateBounds(T element)
protected boolean updateBounds()
protected boolean addElementToChild(T element)
protected void subdivide()
protected PointQuadTree<T> allocate(PointQuadTree<T> parent, float x, float y, float width, float height)
protected boolean isMergable()
protected void merge()
public void removeAll(org.mini2Dx.gdx.utils.Array<T> elementsToRemove)
CollisionDetectionQuadTree and stores them in an ArrayremoveAll in interface CollisionDetection<T extends Positionable>elementsToRemove - After executing, this Array will contain all the removed elementspublic boolean remove(T element)
CollisionDetectionQuadTreeremove in interface CollisionDetection<T extends Positionable>element - The element to removepublic void clear()
CollisionDetectionCollisionDetection.removeAll(Array) except the results are not storedclear in interface CollisionDetection<T extends Positionable>protected boolean removeElementFromChild(T element)
protected boolean removeElement(T element, boolean clearQuadRef)
public org.mini2Dx.gdx.utils.Array<T> getElementsWithinArea(Shape area)
getElementsWithinArea in interface CollisionDetection<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElementsWithinArea(Shape area, QuadTreeSearchDirection searchDirection)
getElementsWithinArea in interface QuadTree<T extends Positionable>protected void addElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area)
protected void addElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area, boolean allElements)
public void getElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area)
getElementsWithinArea in interface CollisionDetection<T extends Positionable>public void getElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area, boolean allElements)
public void getElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area, QuadTreeSearchDirection searchDirection)
getElementsWithinArea in interface QuadTree<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElementsWithinAreaIgnoringEdges(Shape area)
getElementsWithinAreaIgnoringEdges in interface CollisionDetection<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElementsWithinAreaIgnoringEdges(Shape area, QuadTreeSearchDirection searchDirection)
getElementsWithinAreaIgnoringEdges in interface QuadTree<T extends Positionable>public void getElementsWithinAreaIgnoringEdges(org.mini2Dx.gdx.utils.Array<T> result, Shape area)
getElementsWithinAreaIgnoringEdges in interface CollisionDetection<T extends Positionable>public void getElementsWithinAreaIgnoringEdges(org.mini2Dx.gdx.utils.Array<T> result, Shape area, QuadTreeSearchDirection searchDirection)
getElementsWithinAreaIgnoringEdges in interface QuadTree<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElementsContainingArea(Shape area, boolean entirelyContained)
getElementsContainingArea in interface CollisionDetection<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElementsContainingArea(Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained)
getElementsContainingArea in interface QuadTree<T extends Positionable>public void getElementsContainingArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area, boolean entirelyContained)
getElementsContainingArea in interface CollisionDetection<T extends Positionable>public void getElementsContainingArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained)
getElementsContainingArea in interface QuadTree<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElementsContainingPoint(Point point)
getElementsContainingPoint in interface CollisionDetection<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElementsContainingPoint(Point point, QuadTreeSearchDirection searchDirection)
getElementsContainingPoint in interface QuadTree<T extends Positionable>protected void addElementsContainingPoint(org.mini2Dx.gdx.utils.Array<T> result, Point point)
public void getElementsContainingPoint(org.mini2Dx.gdx.utils.Array<T> result, Point point)
getElementsContainingPoint in interface CollisionDetection<T extends Positionable>public void getElementsContainingPoint(org.mini2Dx.gdx.utils.Array<T> result, Point point, QuadTreeSearchDirection searchDirection)
getElementsContainingPoint in interface QuadTree<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElementsIntersectingLineSegment(LineSegment lineSegment)
getElementsIntersectingLineSegment in interface CollisionDetection<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElementsIntersectingLineSegment(LineSegment lineSegment, QuadTreeSearchDirection searchDirection)
getElementsIntersectingLineSegment in interface QuadTree<T extends Positionable>protected void addElementsIntersectingLineSegment(org.mini2Dx.gdx.utils.Array<T> result, LineSegment lineSegment)
protected static boolean intersects(Rectangle tree, LineSegment segment)
public void getElementsIntersectingLineSegment(org.mini2Dx.gdx.utils.Array<T> result, LineSegment lineSegment)
getElementsIntersectingLineSegment in interface CollisionDetection<T extends Positionable>public void getElementsIntersectingLineSegment(org.mini2Dx.gdx.utils.Array<T> result, LineSegment lineSegment, QuadTreeSearchDirection searchDirection)
getElementsIntersectingLineSegment in interface QuadTree<T extends Positionable>public org.mini2Dx.gdx.utils.Array<T> getElements()
getElements in interface CollisionDetection<T extends Positionable>public void getElements(org.mini2Dx.gdx.utils.Array<T> result)
getElements in interface CollisionDetection<T extends Positionable>public int getTotalQuads()
getTotalQuads in interface QuadTree<T extends Positionable>public int getTotalElements()
getTotalElements in interface CollisionDetection<T extends Positionable>public int getTotalImmediateElements()
protected void clearTotalElementsCache()
public void positionChanged(T moved)
positionChanged in interface PositionChangeListener<T extends Positionable>protected boolean isSearchRequired()
public QuadTree<T> getParent()
getParent in interface QuadTree<T extends Positionable>public int getElementLimitPerQuad()
public int getMergeWatermark()
public boolean hasChildQuads()
public float getMinimumQuadWidth()
getMinimumQuadWidth in interface QuadTree<T extends Positionable>public float getMinimumQuadHeight()
getMinimumQuadHeight in interface QuadTree<T extends Positionable>