MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / init

Method init

src/collision/broadphase/DynamicAABBTree.cpp:52–75  ·  view source on GitHub ↗

Initialize the tree

Source from the content-addressed store, hash-verified

50
51// Initialize the tree
52void DynamicAABBTree::init() {
53
54 mRootNodeID = TreeNode::NULL_TREE_NODE;
55 mNbNodes = 0;
56 mNbAllocatedNodes = GLOBAL_ALIGNMENT;
57
58 // Allocate memory for the nodes of the tree
59 mNodes = static_cast<TreeNode*>(mAllocator.allocate(static_cast<size_t>(mNbAllocatedNodes) * sizeof(TreeNode)));
60 assert(mNodes);
61
62 // Construct the nodes
63 for (int32 i=0; i < mNbAllocatedNodes; i++) {
64 new (mNodes + i) TreeNode();
65 }
66
67 // Initialize the allocated nodes
68 for (int32 i=0; i<mNbAllocatedNodes - 1; i++) {
69 mNodes[i].nextNodeID = i + 1;
70 mNodes[i].height = -1;
71 }
72 mNodes[mNbAllocatedNodes - 1].nextNodeID = TreeNode::NULL_TREE_NODE;
73 mNodes[mNbAllocatedNodes - 1].height = -1;
74 mFreeNodeID = 0;
75}
76
77// Clear all the nodes and reset the tree
78void DynamicAABBTree::reset() {

Callers

nothing calls this directly

Calls 1

allocateMethod · 0.45

Tested by

no test coverage detected