Skip to content

Commit bf31bc7

Browse files
committed
Backport to ROS Humble
1 parent 17da0ce commit bf31bc7

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

rviz_mesh_tools_plugins/src/MeshVisual.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,11 +1088,39 @@ bool MeshVisual::updateVertexCosts(
10881088
return false;
10891089
}
10901090

1091-
// Get the needed information about the raw vertex buffer
1091+
/* ManualObject::getNumSections and ManualObject::getSection are deprecated
1092+
* in the Ogre version ROS Jazzy (and future versions) uses. Since the new
1093+
* API is not available in the Ogre version used by ROS Humble we use this
1094+
* check to keep Humble support.
1095+
*
1096+
* This can be removed when Humble support is dropped.
1097+
*/
1098+
#if OGRE_VERSION < ((1 << 16) | (12 << 8) | 7)
1099+
Ogre::RenderOperation* render_op = m_vertexCostsMesh->getSection(0)->getRenderOperation();
1100+
const Ogre::VertexDeclaration* v_decl = render_op->vertexData->vertexDeclaration;
1101+
1102+
// findElementBySemantic does not support VES_COLOUR yet
1103+
const Ogre::VertexElement* color_sem = nullptr;
1104+
for (const auto& elem: v_decl->getElements())
1105+
{
1106+
// VET_COLOUR is deprecated in favour of VET_UBYTE4_NORM
1107+
if (Ogre::VET_UBYTE4_NORM == elem.getType())
1108+
{
1109+
color_sem = &elem;
1110+
}
1111+
}
1112+
#else
1113+
// Get the needed Vertex Colour attribute information about the raw vertex buffer
10921114
Ogre::RenderOperation* render_op = m_vertexCostsMesh->getSections().front()->getRenderOperation();
1093-
// Information about the Vertex Colour attribute
10941115
const Ogre::VertexDeclaration* v_decl = render_op->vertexData->vertexDeclaration;
10951116
const Ogre::VertexElement* color_sem = v_decl->findElementBySemantic(Ogre::VES_COLOUR);
1117+
#endif
1118+
1119+
if (nullptr == color_sem)
1120+
{
1121+
RCLCPP_ERROR(rclcpp::get_logger("rviz_mesh_tools_plugins"), "Vertex Cost Mesh has no Vertex Colour attribute!");
1122+
return false;
1123+
}
10961124

10971125
// Get and lock the hardware vertex buffer of the mesh
10981126
Ogre::HardwareVertexBufferSharedPtr vbuf = render_op->vertexData->vertexBufferBinding->getBuffer(0);
@@ -1164,9 +1192,6 @@ bool MeshVisual::addTexture(Texture& texture, uint32_t textureIndex)
11641192
{
11651193
uint32_t width = texture.width;
11661194
uint32_t height = texture.height;
1167-
uint32_t step = texture.channels;
1168-
1169-
uint32_t dataSize = width * height * step;
11701195

11711196
Ogre::PixelFormat pixelFormat = getOgrePixelFormatFromRosString(texture.pixelFormat);
11721197

0 commit comments

Comments
 (0)