Table of Contents

Class BoundsOctree<T>

Namespace
VoxelPlayground.Utility
Assembly
GamePlay.dll
public class BoundsOctree<T>

Type Parameters

T
Inheritance
object
BoundsOctree<T>

Constructors

BoundsOctree(float, Vector3, float, float)

Constructor for the bounds octree.

public BoundsOctree(float initialWorldSize, Vector3 initialWorldPos, float minNodeSize, float loosenessVal)

Parameters

initialWorldSize float

Size of the sides of the initial node, in metres. The octree will never shrink smaller than this.

initialWorldPos Vector3

Position of the centre of the initial node.

minNodeSize float

Nodes will stop splitting if the new nodes would be smaller than this (metres).

loosenessVal float

Clamped 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

obj T

Object to add.

objBounds Bounds

3D 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

collidingWith List<T>

list to store intersections.

checkBounds Bounds

bounds 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

collidingWith List<T>

list to store intersections.

checkRay Ray

ray to check.

maxDistance float

distance to check.

GetMaxBounds()

public Bounds GetMaxBounds()

Returns

Bounds

GetWithinFrustum(Camera)

public List<T> GetWithinFrustum(Camera cam)

Parameters

cam Camera

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

checkBounds Bounds

bounds 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

checkRay Ray

ray to check.

maxDistance float

distance 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

obj T

Object to remove.

objBounds Bounds

3D 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

obj T

Object to remove.

Returns

bool

True if the object was removed successfully.