Class BoundsOctree<T>
- Namespace
- VoxelPlayground.Utility
- Assembly
- GamePlay.dll
public class BoundsOctree<T>
Type Parameters
T
- Inheritance
-
objectBoundsOctree<T>
Constructors
BoundsOctree(float, Vector3, float, float)
Constructor for the bounds octree.
public BoundsOctree(float initialWorldSize, Vector3 initialWorldPos, float minNodeSize, float loosenessVal)
Parameters
initialWorldSizefloatSize of the sides of the initial node, in metres. 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 (metres).
loosenessValfloatClamped between 1 and 2. Values > 1 let nodes overlap.
Properties
Count
public int Count { get; }
Property Value
- int
Methods
Add(T, Bounds)
Add an object.
public void Add(T obj, Bounds objBounds)
Parameters
objTObject to add.
objBoundsBounds3D bounding box around 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()
GetColliding(List<T>, Bounds)
Returns an array of objects that intersect with the specified bounds, if any. Otherwise returns an empty array. See also: IsColliding.
public void GetColliding(List<T> collidingWith, Bounds checkBounds)
Parameters
collidingWithList<T>list to store intersections.
checkBoundsBoundsbounds to check.
GetColliding(List<T>, Ray, float)
Returns an array of objects that intersect with the specified ray, if any. Otherwise returns an empty array. See also: IsColliding.
public void GetColliding(List<T> collidingWith, Ray checkRay, float maxDistance = Infinity)
Parameters
collidingWithList<T>list to store intersections.
checkRayRayray to check.
maxDistancefloatdistance to check.
GetMaxBounds()
public Bounds GetMaxBounds()
Returns
GetWithinFrustum(Camera)
public List<T> GetWithinFrustum(Camera cam)
Parameters
camCamera
Returns
- List<T>
IsColliding(Bounds)
Check if the specified bounds intersect with anything in the tree. See also: GetColliding.
public bool IsColliding(Bounds checkBounds)
Parameters
checkBoundsBoundsbounds to check.
Returns
- bool
True if there was a collision.
IsColliding(Ray, float)
Check if the specified ray intersects with anything in the tree. See also: GetColliding.
public bool IsColliding(Ray checkRay, float maxDistance)
Parameters
checkRayRayray to check.
maxDistancefloatdistance to check.
Returns
- bool
True if there was a collision.
Remove(T, Bounds)
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, Bounds objBounds)
Parameters
objTObject to remove.
objBoundsBounds3D bounding box around 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.