Skip to content

Commit 73114c7

Browse files
committed
Compatibility with ROS Humble
1 parent f22828c commit 73114c7

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

rviz_mesh_tools_plugins/include/rviz_mesh_tools_plugins/ClusterLabelTool.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public Q_SLOTS:
217217
ClusterLabelDisplay* m_display;
218218
std::shared_ptr<ClusterLabelVisual> m_visual;
219219
std::shared_ptr<Geometry> m_meshGeometry;
220-
float m_brushSize = 1.0f;
220+
float m_brushSize;
221221

222222
// Selection Box
223223
Ogre::SceneNode* m_sceneNode;

rviz_mesh_tools_plugins/src/ClusterLabelTool.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace rviz_mesh_tools_plugins
8484
ClusterLabelTool::ClusterLabelTool()
8585
:rviz_common::Tool()
8686
, m_display(nullptr)
87+
, m_brushSize(MIN_BRUSH_SIZE)
8788
, m_selectionCircle(nullptr)
8889
, m_selectionMesh(nullptr)
8990
, m_selectionVisibilityBit(0)
@@ -709,7 +710,25 @@ Ogre::Image ClusterLabelTool::renderMeshWithFaceID()
709710
render_texture->update();
710711

711712
// Copy the data to ram
713+
/* NOTE: Since Ogre 1.12.10 (which is available with ROS Jazzy), Ogre::Image has a constructor
714+
* which creates an Image from a given size and PixelFormat.
715+
* This #if-macro is to keep supporting ROS Humble (which uses Ogre 1.12.1) and can
716+
* be removed when support for ROS Humble is dropped.
717+
*/
718+
#if OGRE_VERSION < ((1 << 16) | (12 << 8) | (10))
719+
Ogre::Image img;
720+
const size_t width = render_texture->getWidth();
721+
const size_t height = render_texture->getHeight();
722+
const size_t depth = 1;
723+
Ogre::uchar* mem = OGRE_ALLOC_T(
724+
Ogre::uchar,
725+
Ogre::PixelUtil::getMemorySize(width, height, depth, Ogre::PF_R8G8B8),
726+
Ogre::MEMCATEGORY_GENERAL
727+
);
728+
img.loadDynamicImage(mem, width, height, depth, Ogre::PF_R8G8B8, true);
729+
#else
712730
Ogre::Image img(Ogre::PF_R8G8B8, render_texture->getWidth(), render_texture->getHeight());
731+
#endif
713732
Ogre::PixelBox pixels = img.getPixelBox();
714733
render_texture->copyContentsToMemory(pixels, pixels);
715734

0 commit comments

Comments
 (0)