Skip to content

Commit cfb3f81

Browse files
author
C. Andy Martin
committed
ogre helpers point_cloud: calculate bounding radius
Instead of calculating the bounding radius of the entire cloud as we go, calculate it once at the end when updating the bounding box by calling Ogre::Math::boundingRadiusFromAABB on the bounding box.
1 parent 5455c25 commit cfb3f81

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/rviz/ogre_helpers/point_cloud.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ void PointCloud::addPoints(Point* points, uint32_t num_points)
540540
}
541541

542542
aabb.merge(p.position);
543-
bounding_radius_ = std::max(bounding_radius_, p.position.squaredLength());
544543

545544
float x = p.position.x;
546545
float y = p.position.y;
@@ -571,6 +570,7 @@ void PointCloud::addPoints(Point* points, uint32_t num_points)
571570
op->vertexData->vertexCount = current_vertex_count - op->vertexData->vertexStart;
572571
rend->setBoundingBox(aabb);
573572
bounding_box_.merge(aabb);
573+
bounding_radius_ = Ogre::Math::boundingRadiusFromAABB(bounding_box_);
574574
ROS_ASSERT(op->vertexData->vertexCount + op->vertexData->vertexStart <=
575575
rend->getBuffer()->getNumVertices());
576576

@@ -620,13 +620,12 @@ void PointCloud::popPoints(uint32_t num_points)
620620

621621
// reset bounds
622622
bounding_box_.setNull();
623-
bounding_radius_ = 0.0f;
624623
for (uint32_t i = 0; i < point_count_; ++i)
625624
{
626625
Point& p = points_[i];
627626
bounding_box_.merge(p.position);
628-
bounding_radius_ = std::max(bounding_radius_, p.position.squaredLength());
629627
}
628+
bounding_radius_ = Ogre::Math::boundingRadiusFromAABB(bounding_box_);
630629

631630
shrinkRenderables();
632631

0 commit comments

Comments
 (0)