Skip to content

Commit eb06b0e

Browse files
committed
Refactors inner node occupancy update
Improves the efficiency of the inner node occupancy update process by adding a condition to check for the presence of children before recursively updating occupancy. This avoids unnecessary processing when a node has no children, leading to performance gains, especially in sparse octrees.
1 parent 5fd0538 commit eb06b0e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

octomap/src/IntensityOcTree.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,20 @@ void IntensityOcTree::updateInnerOccupancy()
9797
void IntensityOcTree::updateInnerOccupancyRecurs(IntensityOcTreeNode *node,
9898
unsigned depth)
9999
{
100-
if (!node)
101-
return;
102-
103-
if (depth < this->tree_depth)
100+
if (nodeHasChildren(node))
104101
{
105-
for (unsigned i = 0; i < 8; ++i)
106-
if (nodeChildExists(node, i))
107-
updateInnerOccupancyRecurs(getNodeChild(node, i), depth + 1);
102+
if (depth < this->tree_depth)
103+
{
104+
for (unsigned i = 0; i < 8; ++i)
105+
{
106+
if (nodeChildExists(node, i))
107+
updateInnerOccupancyRecurs(getNodeChild(node, i),
108+
depth + 1);
109+
}
110+
}
111+
node->updateOccupancyChildren();
112+
node->updateIntensityChildren();
108113
}
109-
node->updateOccupancyChildren();
110-
node->updateIntensityChildren();
111114
}
112115

113116

0 commit comments

Comments
 (0)