Class PointOctree<T>
- Namespace
- VoxelPlayground.Utility
- Assembly
- GamePlay.dll
public class PointOctree<T>
Type Parameters
T
- Inheritance
-
objectPointOctree<T>
Constructors
PointOctree(float, Vector3, float)
Constructor for the point octree.
public PointOctree(float initialWorldSize, Vector3 initialWorldPos, float minNodeSize)
Parameters
initialWorldSizefloatSize of the sides of the initial node. The octree will never shrink smaller than this.
initialWorldPosVector3Position of the centre of the initial node.
minNodeSizefloatNodes will stop splitting if the new nodes would be smaller than this.
Properties
Count
public int Count { get; }
Property Value
- int
Methods
Add(T, Vector3)
Add an object.
public void Add(T obj, Vector3 objPos)
Parameters
objTObject to add.
objPosVector3Position of the object.
DrawAllBounds()
Draws node boundaries visually for debugging. Must be called from OnDrawGizmos externally. See also: DrawAllObjects.
public void DrawAllBounds()
DrawAllObjects()
Draws the bounds of all objects in the tree visually for debugging. Must be called from OnDrawGizmos externally. See also: DrawAllBounds.
public void DrawAllObjects()
GetAll()
Return all objects in the tree. If none, returns an empty array (not null).
public ICollection<T> GetAll()
Returns
- ICollection<T>
All objects.
GetNearby(Ray, float)
Returns objects that are within maxDistance of the specified ray.
If none, returns an empty array (not null).
public T[] GetNearby(Ray ray, float maxDistance)
Parameters
rayRayThe ray. Passing as ref to improve performance since it won't have to be copied.
maxDistancefloatMaximum distance from the ray to consider.
Returns
- T[]
Objects within range.
GetNearby(Vector3, float)
Returns objects that are within maxDistance of the specified position.
If none, returns an empty array (not null).
public T[] GetNearby(Vector3 position, float maxDistance)
Parameters
positionVector3The position. Passing as ref to improve performance since it won't have to be copied.
maxDistancefloatMaximum distance from the position to consider.
Returns
- T[]
Objects within range.
GetNearbyNonAlloc(Ray, float, List<T>)
Returns objects that are within maxDistance of the specified ray.
If none, returns false. Uses supplied list for results.
public bool GetNearbyNonAlloc(Ray ray, float maxDistance, List<T> nearBy)
Parameters
rayRayThe ray. Passing as ref to improve performance since it won't have to be copied.
maxDistancefloatMaximum distance from the ray to consider
nearByList<T>Pre-initialized list to populate
Returns
- bool
True if items are found, false if not
GetNearbyNonAlloc(Vector3, float, List<T>)
Returns objects that are within maxDistance of the specified position.
If none, returns false. Uses supplied list for results.
public bool GetNearbyNonAlloc(Vector3 position, float maxDistance, List<T> nearBy)
Parameters
positionVector3maxDistancefloatMaximum distance from the position to consider
nearByList<T>Pre-initialized list to populate
Returns
- bool
True if items are found, false if not
Remove(T, Vector3)
Removes the specified object at the given position. Makes the assumption that the object only exists once in the tree.
public bool Remove(T obj, Vector3 objPos)
Parameters
objTObject to remove.
objPosVector3Position of the object.
Returns
- bool
True if the object was removed successfully.
Remove(T)
Remove an object. Makes the assumption that the object only exists once in the tree.
public bool Remove(T obj)
Parameters
objTObject to remove.
Returns
- bool
True if the object was removed successfully.