Skip to main content

BVH2D

Classes

2D Bounding Volume Hierarchy implementation. Based on BVH (3D) implementation

Constants

A non-leaf node have both CHILD_1 and CHILD_2 set, when CHILD_1 is not set - it's a leaf node So we can utilize space of CHILD_2 to store USER_DATA, hence there is overlap in schema

How many words are used for a single NODE in the tree One "word" is 4 bytes for the sake of alignment

How many nodes can be stored in the newly constructed tree before allocation needs to take place

Tree can not contain more than this number of nodes

BVH2D

2D Bounding Volume Hierarchy implementation. Based on BVH (3D) implementation

Kind: global class

bvH2D.root ⇒ number

Kind: instance property of BVH2D

bvH2D.node_capacity ⇒ number

Kind: instance property of BVH2D

bvH2D.node_capacity

Kind: instance property of BVH2D

ParamType
vnumber

bvH2D.trim()

Trim allocated memory region to only contain allocated nodes

Kind: instance method of BVH2D

bvH2D.allocate_node() ⇒ number

Kind: instance method of BVH2D

bvH2D.release_node(id)

Release memory used by the node back into the pool NOTE: Make sure that the node is not "live" (not attached to the hierarchy), otherwise this operation may corrupt the tree

Kind: instance method of BVH2D

ParamType
idnumber

bvH2D.node_is_leaf(id) ⇒ boolean

Kind: instance method of BVH2D

ParamType
idnumber

bvH2D.node_get_user_data(id) ⇒ number

Kind: instance method of BVH2D

ParamType
idnumber

bvH2D.node_set_user_data(id, value)

Kind: instance method of BVH2D

ParamType
idnumber
valuenumber

bvH2D.node_get_child1(id) ⇒ number

Kind: instance method of BVH2D

ParamType
idnumber

bvH2D.node_set_child1(node, child1)

Kind: instance method of BVH2D

ParamType
nodenumber
child1number

bvH2D.node_get_child2(id) ⇒ number

Kind: instance method of BVH2D

ParamType
idnumber

bvH2D.node_set_child2(node, child2)

Kind: instance method of BVH2D

ParamType
nodenumber
child2number

bvH2D.node_get_parent(id) ⇒ number

Kind: instance method of BVH2D

ParamType
idnumber

bvH2D.node_set_parent(node, parent)

Kind: instance method of BVH2D

ParamType
nodenumber
parentnumber

bvH2D.node_get_height(id) ⇒ number

Kind: instance method of BVH2D

ParamType
idnumber

bvH2D.node_set_height(id, height)

Kind: instance method of BVH2D

ParamType
idnumber
heightnumber

bvH2D.node_get_aabb(id, result)

Kind: instance method of BVH2D

ParamType
idnumber
resultArray.<number> | Float32Array

bvH2D.node_set_aabb(id, aabb)

Kind: instance method of BVH2D

ParamType
idnumber
aabbArray.<number> | ArrayLike.<number>

bvH2D.node_move_aabb(id, aabb)

Kind: instance method of BVH2D

ParamType
idnumber
aabbArray.<number>

bvH2D.node_set_aabb_primitive(id, x0, y0, z0, x1, y1, z1)

Kind: instance method of BVH2D

ParamType
idnumber
x0number
y0number
z0number
x1number
y1number
z1number

bvH2D.node_get_surface_area(id) ⇒ number

Kind: instance method of BVH2D

ParamType
idnumber

bvH2D.node_get_combined_surface_area(index_a, index_b) ⇒ number

Kind: instance method of BVH2D

ParamType
index_anumber
index_bnumber

bvH2D.node_set_combined_aabb(destination, index_a, index_b)

Kind: instance method of BVH2D

ParamType
destinationnumber
index_anumber
index_bnumber

bvH2D.insert_leaf(leaf) ⇒ void

Kind: instance method of BVH2D

ParamType
leafnumber

bvH2D.remove_leaf(leaf) ⇒ void

NOTE: Leaf node is not released, make sure to call #release_node separately when you no longer need the leaf node

Kind: instance method of BVH2D

ParamType
leafnumber

bvH2D.release_all()

Release all nodes, this essentially resets the tree to empty state NOTE: For performance reasons, released memory is not reset, this means that attempting to access cleared nodes' memory will yield garbage data

Kind: instance method of BVH2D

bvH2D.traverse(callback, [ctx])

Kind: instance method of BVH2D

ParamType
callbackfunction
[ctx]*

bvH2D.collect_nodes_all(destination, destination_offset) ⇒ number

Kind: instance method of BVH2D

ParamType
destinationArray.<number>
destination_offsetnumber

bvH2D.swap_nodes(a, b) ⇒ boolean

Swap two nodes in memory

Kind: instance method of BVH2D

ParamType
anumber
bnumber

COLUMN_USER_DATA : number

A non-leaf node have both CHILD_1 and CHILD_2 set, when CHILD_1 is not set - it's a leaf node So we can utilize space of CHILD_2 to store USER_DATA, hence there is overlap in schema

Kind: global constant
Read only: true

NULL_NODE : number

Kind: global constant

CAPACITY_GROW_MULTIPLIER : number

Kind: global constant
Read only: true

CAPACITY_GROW_MIN_STEP : number

Kind: global constant
Read only: true

ELEMENT_WORD_COUNT : number

How many words are used for a single NODE in the tree One "word" is 4 bytes for the sake of alignment

Kind: global constant
Read only: true

INITIAL_CAPACITY : number

How many nodes can be stored in the newly constructed tree before allocation needs to take place

Kind: global constant
Read only: true

NODE_CAPACITY_LIMIT : number

Tree can not contain more than this number of nodes

Kind: global constant