|
@@ -149,7 +149,7 @@ class AABBTree |
|
|
NodeLeaf(int parent) |
|
|
NodeLeaf(int parent) |
|
|
{ |
|
|
{ |
|
|
m_parent = parent; |
|
|
m_parent = parent; |
|
|
for (int i = 0; i < child_nb; i++) |
|
|
|
|
|
|
|
|
for (size_t i = 0; i < child_nb; ++i) |
|
|
m_children[i] = 0; |
|
|
m_children[i] = 0; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
@@ -189,7 +189,7 @@ private: |
|
|
bool CleanupEmptyLeaves(int leaf=0) |
|
|
bool CleanupEmptyLeaves(int leaf=0) |
|
|
{ |
|
|
{ |
|
|
int empty_children = 0; |
|
|
int empty_children = 0; |
|
|
for (int i = 0; i < child_nb; i++) |
|
|
|
|
|
|
|
|
for (size_t i = 0; i < child_nb; ++i) |
|
|
{ |
|
|
{ |
|
|
bool child_empty = false; |
|
|
bool child_empty = false; |
|
|
if (m_tree[leaf].m_children[i] != 0) |
|
|
if (m_tree[leaf].m_children[i] != 0) |
|
@@ -198,7 +198,7 @@ private: |
|
|
} |
|
|
} |
|
|
if (empty_children == 4 && leaf != 0) |
|
|
if (empty_children == 4 && leaf != 0) |
|
|
{ |
|
|
{ |
|
|
for (int i = 0; i < child_nb; i++) |
|
|
|
|
|
|
|
|
for (size_t i = 0; i < child_nb; ++i) |
|
|
{ |
|
|
{ |
|
|
int old_leaf = m_tree[leaf].m_children[i]; |
|
|
int old_leaf = m_tree[leaf].m_children[i]; |
|
|
if (old_leaf != 0) |
|
|
if (old_leaf != 0) |
|
@@ -261,7 +261,7 @@ private: |
|
|
if (TestAABBVsAABB(leaf_bb, test_bb)) |
|
|
if (TestAABBVsAABB(leaf_bb, test_bb)) |
|
|
{ |
|
|
{ |
|
|
NodeLeaf& node = m_tree[leaf]; |
|
|
NodeLeaf& node = m_tree[leaf]; |
|
|
for (int i = 0; i < child_nb; i++) |
|
|
|
|
|
|
|
|
for (size_t i = 0; i < child_nb; ++i) |
|
|
{ |
|
|
{ |
|
|
if (node.m_children[i] != 0) |
|
|
if (node.m_children[i] != 0) |
|
|
{ |
|
|
{ |
|
@@ -284,7 +284,7 @@ private: |
|
|
if (TestAABBVsAABB(leaf_bb, element->GetAABB())) |
|
|
if (TestAABBVsAABB(leaf_bb, element->GetAABB())) |
|
|
{ |
|
|
{ |
|
|
bool found_child = false; |
|
|
bool found_child = false; |
|
|
for (int i = 0; i < child_nb; i++) |
|
|
|
|
|
|
|
|
for (size_t i = 0; i < child_nb; ++i) |
|
|
{ |
|
|
{ |
|
|
TB child_bb = GetSubAABB(leaf_bb, i); |
|
|
TB child_bb = GetSubAABB(leaf_bb, i); |
|
|
int child_leaf = m_tree[leaf].m_children[i]; |
|
|
int child_leaf = m_tree[leaf].m_children[i]; |
|
@@ -304,7 +304,7 @@ private: |
|
|
elements.PushUnique(AddElement(element)); |
|
|
elements.PushUnique(AddElement(element)); |
|
|
m_tree[leaf].m_elements.Empty(); |
|
|
m_tree[leaf].m_elements.Empty(); |
|
|
//Add children |
|
|
//Add children |
|
|
for (int j = 0; j < child_nb; j++) |
|
|
|
|
|
|
|
|
for (size_t j = 0; j < child_nb; ++j) |
|
|
m_tree[leaf].m_children[j] = AddLeaf(leaf); |
|
|
m_tree[leaf].m_children[j] = AddLeaf(leaf); |
|
|
//Re-run extracted elements |
|
|
//Re-run extracted elements |
|
|
while (elements.Count()) |
|
|
while (elements.Count()) |
|
|