Package com.badlogic.gdx.utils
Class QuadTreeFloat
- java.lang.Object
-
- com.badlogic.gdx.utils.QuadTreeFloat
-
- All Implemented Interfaces:
Pool.Poolable
public class QuadTreeFloat extends java.lang.Object implements Pool.Poolable
A quad tree that stores a float for each point.
-
-
Field Summary
Fields Modifier and Type Field Description intcountThe number of elements stored invalues(3 values per quad tree entry).intdepthstatic intDISTSQRfloatheightintmaxDepthintmaxValuesQuadTreeFloatneQuadTreeFloatnwQuadTreeFloatseQuadTreeFloatswstatic intVALUEfloat[]valuesFor each entry, stores the value, x, and y.floatwidthfloatxstatic intXfloatystatic intY
-
Constructor Summary
Constructors Constructor Description QuadTreeFloat()Creates a quad tree with 16 for maxValues and 8 for maxDepth.QuadTreeFloat(int maxValues, int maxDepth)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(float value, float valueX, float valueY)protected intgrowValues()booleannearest(float x, float y, FloatArray result)voidquery(float centerX, float centerY, float radius, FloatArray results)voidquery(Rectangle rect, FloatArray results)voidreset()Resets the object for reuse.voidsetBounds(float x, float y, float width, float height)
-
-
-
Field Detail
-
VALUE
public static final int VALUE
- See Also:
- Constant Field Values
-
X
public static final int X
- See Also:
- Constant Field Values
-
Y
public static final int Y
- See Also:
- Constant Field Values
-
DISTSQR
public static final int DISTSQR
- See Also:
- Constant Field Values
-
maxValues
public final int maxValues
-
maxDepth
public final int maxDepth
-
x
public float x
-
y
public float y
-
width
public float width
-
height
public float height
-
depth
public int depth
-
nw
@Null public QuadTreeFloat nw
-
ne
@Null public QuadTreeFloat ne
-
sw
@Null public QuadTreeFloat sw
-
se
@Null public QuadTreeFloat se
-
values
public float[] values
For each entry, stores the value, x, and y.
-
count
public int count
The number of elements stored invalues(3 values per quad tree entry).
-
-
Constructor Detail
-
QuadTreeFloat
public QuadTreeFloat()
Creates a quad tree with 16 for maxValues and 8 for maxDepth.
-
QuadTreeFloat
public QuadTreeFloat(int maxValues, int maxDepth)- Parameters:
maxValues- The maximum number of values stored in each quad tree node. When exceeded, the node is split into 4 child nodes. If the maxDepth has been reached, more than maxValues may be stored.maxDepth- The maximum depth of the tree nodes. Nodes at the maxDepth will not be split and may store more than maxValues number of entries.
-
-
Method Detail
-
setBounds
public void setBounds(float x, float y, float width, float height)
-
add
public void add(float value, float valueX, float valueY)
-
growValues
protected int growValues()
-
query
public void query(float centerX, float centerY, float radius, FloatArray results)
-
query
public void query(Rectangle rect, FloatArray results)
-
nearest
public boolean nearest(float x, float y, FloatArray result)- Parameters:
result- For the entry nearest to the specified point, the value, x, y, and square of the distance to the value are added to this array after it is cleared. SeeVALUE,X,Y, andDISTSQR.- Returns:
- false if no entry was found because the quad tree was empty or the specified point is farther than the larger of the quad tree's width or height from an entry. If false is returned the result array is empty.
-
reset
public void reset()
Description copied from interface:Pool.PoolableResets the object for reuse. Object references should be nulled and fields may be set to default values.- Specified by:
resetin interfacePool.Poolable
-
-