-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix misc point cloud ogre helper bounds issues #1644
base: noetic-devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -480,6 +480,7 @@ void PointCloud::addPoints(Point* points, uint32_t num_points) | |
|
||
Ogre::AxisAlignedBox aabb; | ||
aabb.setNull(); | ||
Ogre::Vector3 point_size_offset(width_/2.0, height_/2.0, depth_/2.0); | ||
uint32_t current_vertex_count = 0; | ||
bounding_radius_ = 0.0f; | ||
uint32_t vertex_size = 0; | ||
|
@@ -539,8 +540,8 @@ void PointCloud::addPoints(Point* points, uint32_t num_points) | |
root->convertColourValue(p.color, &color); | ||
} | ||
|
||
aabb.merge(p.position); | ||
bounding_radius_ = std::max(bounding_radius_, p.position.squaredLength()); | ||
aabb.merge(p.position + point_size_offset); | ||
aabb.merge(p.position - point_size_offset); | ||
|
||
float x = p.position.x; | ||
float y = p.position.y; | ||
|
@@ -571,6 +572,7 @@ void PointCloud::addPoints(Point* points, uint32_t num_points) | |
op->vertexData->vertexCount = current_vertex_count - op->vertexData->vertexStart; | ||
rend->setBoundingBox(aabb); | ||
bounding_box_.merge(aabb); | ||
bounding_radius_ = Ogre::Math::boundingRadiusFromAABB(bounding_box_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid Only later they introduced |
||
ROS_ASSERT(op->vertexData->vertexCount + op->vertexData->vertexStart <= | ||
rend->getBuffer()->getNumVertices()); | ||
|
||
|
@@ -620,13 +622,12 @@ void PointCloud::popPoints(uint32_t num_points) | |
|
||
// reset bounds | ||
bounding_box_.setNull(); | ||
bounding_radius_ = 0.0f; | ||
for (uint32_t i = 0; i < point_count_; ++i) | ||
{ | ||
Point& p = points_[i]; | ||
bounding_box_.merge(p.position); | ||
bounding_radius_ = std::max(bounding_radius_, p.position.squaredLength()); | ||
} | ||
bounding_radius_ = Ogre::Math::boundingRadiusFromAABB(bounding_box_); | ||
|
||
shrinkRenderables(); | ||
|
||
|
@@ -801,18 +802,12 @@ Ogre::HardwareVertexBufferSharedPtr PointCloudRenderable::getBuffer() | |
|
||
Ogre::Real PointCloudRenderable::getBoundingRadius() const | ||
{ | ||
return Ogre::Math::Sqrt(std::max(mBox.getMaximum().squaredLength(), mBox.getMinimum().squaredLength())); | ||
return Ogre::Math::boundingRadiusFromAABB(mBox); | ||
} | ||
|
||
Ogre::Real PointCloudRenderable::getSquaredViewDepth(const Ogre::Camera* cam) const | ||
{ | ||
Ogre::Vector3 vMin, vMax, vMid, vDist; | ||
vMin = mBox.getMinimum(); | ||
vMax = mBox.getMaximum(); | ||
vMid = ((vMax - vMin) * 0.5) + vMin; | ||
vDist = cam->getDerivedPosition() - vMid; | ||
|
||
return vDist.squaredLength(); | ||
return getWorldBoundingBox().squaredDistance(cam->getDerivedPosition()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous code attempted to compute the (squared) distance of the cam to the center of the bbox. |
||
} | ||
|
||
void PointCloudRenderable::getWorldTransforms(Ogre::Matrix4* xform) const | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree that the point size should be considered, I suggest doing so once in the end.
Also, you should adapt the bounding box(es) as soon as the point size changed via
setDimensions()
.