Contents
Class KDTree<T>
java.lang.Object
com.hypixel.hytale.component.spatial.KDTree<T>
- Type Parameters:
T- the type of data stored in the structure.
- All Implemented Interfaces:
SpatialStructure<T>
A KD-Tree implementation of a spatial structure.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclosest(org.joml.Vector3dc point) Gets the data closest to a point, ornullif there is no data in the structure.voidGets all data that is within a specified spherical radius of a point, defined by center and radius.voidcollectBox(org.joml.Vector3dc min, org.joml.Vector3dc max, List<T> results) Gets all data that is within a specified axis-aligned box, defined by min and max positions.voidcollectCylinder(org.joml.Vector3dc center, double radius, double height, List<T> results) Gets all data that is within a specified cylindrical area, defined by a center point, radius, and height.dump()voidGets all data that is within a specified radius of a point in order of closest to furthest.voidordered3DAxis(org.joml.Vector3dc center, double xSearchRadius, double ySearchRadius, double zSearchRadius, List<T> results) Gets all data that is within specified radius along each axis of a point.voidrebuild(SpatialData<T> spatialData) Builds the structure using the provided data.intsize()
-
Constructor Details
-
KDTree
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceSpatialStructure<T>- Returns:
- the number of pieces of data in the structure.
-
rebuild
Description copied from interface:SpatialStructureBuilds the structure using the provided data. This clears any existing data in the structure.- Specified by:
rebuildin interfaceSpatialStructure<T>- Parameters:
spatialData- The data to build the structure with.
-
closest
Description copied from interface:SpatialStructureGets the data closest to a point, ornullif there is no data in the structure.- Specified by:
closestin interfaceSpatialStructure<T>- Parameters:
point- The point to search from.- Returns:
- the data closest to the provided point, or
nullif there is no data in the structure.
-
collect
Description copied from interface:SpatialStructureGets all data that is within a specified spherical radius of a point, defined by center and radius.- Specified by:
collectin interfaceSpatialStructure<T>- Parameters:
center- The center of the sphere.radius- The radius of the sphere.results- The list to populate with results.
-
collectCylinder
public void collectCylinder(@Nonnull org.joml.Vector3dc center, double radius, double height, @Nonnull List<T> results) Description copied from interface:SpatialStructureGets all data that is within a specified cylindrical area, defined by a center point, radius, and height.- Specified by:
collectCylinderin interfaceSpatialStructure<T>- Parameters:
center- The center point of the cylinder's base.radius- The radius of the cylinder.height- The height of the cylinder.results- The list to populate with results.
-
collectBox
public void collectBox(@Nonnull org.joml.Vector3dc min, @Nonnull org.joml.Vector3dc max, @Nonnull List<T> results) Description copied from interface:SpatialStructureGets all data that is within a specified axis-aligned box, defined by min and max positions.- Specified by:
collectBoxin interfaceSpatialStructure<T>- Parameters:
min- The minimum corner of the box (inclusive).max- The maximum corner of the box (inclusive).results- The list to populate with results.
-
ordered
Description copied from interface:SpatialStructureGets all data that is within a specified radius of a point in order of closest to furthest.If the use case doesn't require the order then please use
SpatialStructure.collect(Vector3dc, double, List)instead.- Specified by:
orderedin interfaceSpatialStructure<T>- Parameters:
center- The center point from which to search.radius- The radius of the search.results- The list to populate with results, ordered from closest to furthest.
-
ordered3DAxis
public void ordered3DAxis(@Nonnull org.joml.Vector3dc center, double xSearchRadius, double ySearchRadius, double zSearchRadius, @Nonnull List<T> results) Description copied from interface:SpatialStructureGets all data that is within specified radius along each axis of a point.- Specified by:
ordered3DAxisin interfaceSpatialStructure<T>- Parameters:
center- The center point from which to search.xSearchRadius- The search radius along the X axis.ySearchRadius- The search radius along the Y axis.zSearchRadius- The search radius along the Z axis.results- The output list to store data within the specified radius, ordered from closest to furthest.
-
dump
- Specified by:
dumpin interfaceSpatialStructure<T>- Returns:
- an information dump of this spatial structure, for debugging purposes.
-