public class GridRegionQuadTree<T extends Sizeable> extends Rectangle implements QuadTree<T>
| Modifier and Type | Field and Description |
|---|---|
protected int |
cellHeight |
protected int |
cellWidth |
static float |
DEFAULT_MINIMUM_QUAD_SIZE |
protected java.util.BitSet |
dirtyCells |
static Color |
ELEMENT_COLOR |
protected int |
gridWorldX |
protected int |
gridWorldY |
protected float |
invCellHeight |
protected float |
invCellWidth |
protected GridRegionQuadTreeLooseCell[] |
looseGrid |
protected float |
minimumQuadHeight |
protected float |
minimumQuadWidth |
protected org.mini2Dx.gdx.utils.Queue<RegionQuadTree<T>> |
pool |
static Color |
QUAD_COLOR |
protected GridRegionQuadTreeTightCell[] |
tightGrid |
protected int |
totalCellsX |
protected int |
totalElementsCache |
disposed, geometry, positionChangeListeners, sizeChangeListeners| Constructor and Description |
|---|
GridRegionQuadTree(float minimumQuadWidth,
float minimumQuadHeight,
int elementLimitPerQuad,
int x,
int y,
int width,
int height,
int gridCellWidth,
int gridCellHeight) |
GridRegionQuadTree(int elementLimitPerQuad,
int x,
int y,
int width,
int height,
int gridCellWidth,
int gridCellHeight) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T element)
Adds an element to this
QuadTree |
void |
addAll(org.mini2Dx.gdx.utils.Array<T> elements)
Adds all element to this
QuadTree. |
void |
cleanup() |
void |
clear()
Same a
CollisionDetection.removeAll(Array) except the results are not stored |
void |
debugRender(Graphics g) |
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,
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) |
protected int |
getGridIndex(float x,
float y) |
GridRegionQuadTreeLooseCell<T> |
getLooseCell(float x,
float y) |
GridRegionQuadTreeLooseCell<T> |
getLooseCell(T element) |
int |
getMaxGridIndex(T element) |
int |
getMinGridIndex(T element) |
float |
getMinimumQuadHeight() |
float |
getMinimumQuadWidth() |
QuadTree<T> |
getParent() |
GridRegionQuadTreeTightCell<T> |
getTightCell(float x,
float y) |
GridRegionQuadTreeTightCell<T> |
getTightCell(int index) |
GridRegionQuadTreeTightCell<T> |
getTightCell(T element) |
int |
getTotalElements() |
int |
getTotalQuads() |
void |
positionChanged(T moved) |
boolean |
remove(T element)
Removes an element from this
QuadTree |
void |
removeAll(org.mini2Dx.gdx.utils.Array<T> elements)
Removes all elements in this
QuadTree and stores them in an Array |
protected boolean |
removeElement(T element,
boolean clearQuadRef) |
void |
warmupPool(int poolSize) |
void |
warmupPool(int poolSize,
int expectedElementsPerQuad) |
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 final float DEFAULT_MINIMUM_QUAD_SIZE
public static Color QUAD_COLOR
public static Color ELEMENT_COLOR
protected final GridRegionQuadTreeLooseCell[] looseGrid
protected final GridRegionQuadTreeTightCell[] tightGrid
protected final java.util.BitSet dirtyCells
protected final int gridWorldX
protected final int gridWorldY
protected final int totalCellsX
protected final int cellWidth
protected final int cellHeight
protected final float invCellWidth
protected final float invCellHeight
protected final float minimumQuadWidth
protected final float minimumQuadHeight
protected final org.mini2Dx.gdx.utils.Queue<RegionQuadTree<T extends Sizeable>> pool
protected int totalElementsCache
public GridRegionQuadTree(int elementLimitPerQuad,
int x,
int y,
int width,
int height,
int gridCellWidth,
int gridCellHeight)
public GridRegionQuadTree(float minimumQuadWidth,
float minimumQuadHeight,
int elementLimitPerQuad,
int x,
int y,
int width,
int height,
int gridCellWidth,
int gridCellHeight)
protected int getGridIndex(float x,
float y)
public int getMinGridIndex(T element)
public int getMaxGridIndex(T element)
public GridRegionQuadTreeTightCell<T> getTightCell(int index)
public GridRegionQuadTreeTightCell<T> getTightCell(T element)
public GridRegionQuadTreeTightCell<T> getTightCell(float x, float y)
public GridRegionQuadTreeLooseCell<T> getLooseCell(T element)
public GridRegionQuadTreeLooseCell<T> getLooseCell(float x, float y)
public void warmupPool(int poolSize)
public void warmupPool(int poolSize,
int expectedElementsPerQuad)
public void cleanup()
public void debugRender(Graphics g)
debugRender in interface CollisionDetection<T extends Sizeable>public boolean add(T element)
CollisionDetectionQuadTreeadd in interface CollisionDetection<T extends Sizeable>element - The element to addpublic boolean remove(T element)
CollisionDetectionQuadTreeremove in interface CollisionDetection<T extends Sizeable>element - The element to removepublic void addAll(org.mini2Dx.gdx.utils.Array<T> elements)
CollisionDetectionQuadTree. Note that if an element exists outside of this QuadTree's bounds, it will not be addedaddAll in interface CollisionDetection<T extends Sizeable>elements - The elements to addpublic void removeAll(org.mini2Dx.gdx.utils.Array<T> elements)
CollisionDetectionQuadTree and stores them in an ArrayremoveAll in interface CollisionDetection<T extends Sizeable>elements - After executing, this Array will contain all the removed elementsprotected boolean removeElement(T element, boolean clearQuadRef)
public void clear()
CollisionDetectionCollisionDetection.removeAll(Array) except the results are not storedclear in interface CollisionDetection<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsWithinArea(Shape area)
getElementsWithinArea in interface CollisionDetection<T extends Sizeable>public void getElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area)
getElementsWithinArea in interface CollisionDetection<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsWithinAreaIgnoringEdges(Shape area)
getElementsWithinAreaIgnoringEdges in interface CollisionDetection<T extends Sizeable>public void getElementsWithinAreaIgnoringEdges(org.mini2Dx.gdx.utils.Array<T> result, Shape area)
getElementsWithinAreaIgnoringEdges in interface CollisionDetection<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsContainingArea(Shape area, boolean entirelyContained)
getElementsContainingArea in interface CollisionDetection<T extends Sizeable>public void getElementsContainingArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area, boolean entirelyContained)
getElementsContainingArea in interface CollisionDetection<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsIntersectingLineSegment(LineSegment lineSegment)
getElementsIntersectingLineSegment in interface CollisionDetection<T extends Sizeable>public void getElementsIntersectingLineSegment(org.mini2Dx.gdx.utils.Array<T> result, LineSegment lineSegment)
getElementsIntersectingLineSegment in interface CollisionDetection<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsContainingPoint(Point point)
getElementsContainingPoint in interface CollisionDetection<T extends Sizeable>public void getElementsContainingPoint(org.mini2Dx.gdx.utils.Array<T> result, Point point)
getElementsContainingPoint in interface CollisionDetection<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsWithinArea(Shape area, QuadTreeSearchDirection searchDirection)
getElementsWithinArea in interface QuadTree<T extends Sizeable>public void getElementsWithinArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area, QuadTreeSearchDirection searchDirection)
getElementsWithinArea in interface QuadTree<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsWithinAreaIgnoringEdges(Shape area, QuadTreeSearchDirection searchDirection)
getElementsWithinAreaIgnoringEdges in interface QuadTree<T extends Sizeable>public void getElementsWithinAreaIgnoringEdges(org.mini2Dx.gdx.utils.Array<T> result, Shape area, QuadTreeSearchDirection searchDirection)
getElementsWithinAreaIgnoringEdges in interface QuadTree<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsContainingArea(Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained)
getElementsContainingArea in interface QuadTree<T extends Sizeable>public void getElementsContainingArea(org.mini2Dx.gdx.utils.Array<T> result, Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained)
getElementsContainingArea in interface QuadTree<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsIntersectingLineSegment(LineSegment lineSegment, QuadTreeSearchDirection searchDirection)
getElementsIntersectingLineSegment in interface QuadTree<T extends Sizeable>public void getElementsIntersectingLineSegment(org.mini2Dx.gdx.utils.Array<T> result, LineSegment lineSegment, QuadTreeSearchDirection searchDirection)
getElementsIntersectingLineSegment in interface QuadTree<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElementsContainingPoint(Point point, QuadTreeSearchDirection searchDirection)
getElementsContainingPoint in interface QuadTree<T extends Sizeable>public void getElementsContainingPoint(org.mini2Dx.gdx.utils.Array<T> result, Point point, QuadTreeSearchDirection searchDirection)
getElementsContainingPoint in interface QuadTree<T extends Sizeable>public void positionChanged(T moved)
positionChanged in interface PositionChangeListener<T extends Sizeable>public org.mini2Dx.gdx.utils.Array<T> getElements()
getElements in interface CollisionDetection<T extends Sizeable>public void getElements(org.mini2Dx.gdx.utils.Array<T> result)
getElements in interface CollisionDetection<T extends Sizeable>public int getTotalElements()
getTotalElements in interface CollisionDetection<T extends Sizeable>public int getTotalQuads()
getTotalQuads in interface QuadTree<T extends Sizeable>public float getMinimumQuadWidth()
getMinimumQuadWidth in interface QuadTree<T extends Sizeable>public float getMinimumQuadHeight()
getMinimumQuadHeight in interface QuadTree<T extends Sizeable>