Skip to content

Commit 4ddbd1b

Browse files
committed
Fix getUnknownLeafCenters to return true leaf centers
1 parent 45cbcaf commit 4ddbd1b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

octomap/include/octomap/OcTreeBaseImpl.hxx

+7-4
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,19 @@ namespace octomap {
10491049
if (depth == 0)
10501050
depth = tree_depth;
10511051

1052+
point3d pmin_clamped = this->keyToCoord(this->coordToKey(pmin, depth), depth);
1053+
point3d pmax_clamped = this->keyToCoord(this->coordToKey(pmax, depth), depth);
1054+
10521055
float diff[3];
10531056
unsigned int steps[3];
10541057
float step_size = this->resolution * pow(2, tree_depth-depth);
10551058
for (int i=0;i<3;++i) {
1056-
diff[i] = pmax(i) - pmin(i);
1059+
diff[i] = pmax_clamped(i) - pmin_clamped(i);
10571060
steps[i] = floor(diff[i] / step_size);
10581061
// std::cout << "bbx " << i << " size: " << diff[i] << " " << steps[i] << " steps\n";
10591062
}
10601063

1061-
point3d p = pmin;
1064+
point3d p = pmin_clamped;
10621065
NODE* res;
10631066
for (unsigned int x=0; x<steps[0]; ++x) {
10641067
p.x() += step_size;
@@ -1072,9 +1075,9 @@ namespace octomap {
10721075
node_centers.push_back(p);
10731076
}
10741077
}
1075-
p.z() = pmin.z();
1078+
p.z() = pmin_clamped.z();
10761079
}
1077-
p.y() = pmin.y();
1080+
p.y() = pmin_clamped.y();
10781081
}
10791082
}
10801083

0 commit comments

Comments
 (0)