Octree

Octree

The structure that holds the data for an octree node.

Constructor

new Octree(bounds, parent)

Parameters:
Name Type Description
bounds BoundingBox
parent Octree

Members

bounds :BoundingBox

Bounding box for this node.

children :Array.<Octree>

Array of 8 children per node.

entities :Array.<Entity>

Entities inside the bounds of this node.

leafNodes :Array.<Octree>

Leaf nodes for each octree entity.
This doesn't follow the standard octree implementation, but it allow us to optimize rendering.

occluder :OcclusionData

Collection of useful data for computing occlusion testing.

parent :Octree

Parent node.

Methods

build(entityArray)

Constructs a subtree given an array of entities.

Parameters:
Name Type Description
entityArray Array.<Entity>

calculateOctantBounds()

Calculates one of this tree's 8 octant bounding box

insert(entityArray)

Insert entities into a tree, building new branches if necessary.

Parameters:
Name Type Description
entityArray Array.<Entity>

remove(entityArray)

Removes entities from a tree, deleting brancges if necessary.

Parameters:
Name Type Description
entityArray Array.<Entity>

update(entity)

Updates the tree to account for moving entities.

Parameters:
Name Type Description
entity Entity