@@ -1088,11 +1088,39 @@ bool MeshVisual::updateVertexCosts(
1088
1088
return false ;
1089
1089
}
1090
1090
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
1092
1114
Ogre::RenderOperation* render_op = m_vertexCostsMesh->getSections ().front ()->getRenderOperation ();
1093
- // Information about the Vertex Colour attribute
1094
1115
const Ogre::VertexDeclaration* v_decl = render_op->vertexData ->vertexDeclaration ;
1095
1116
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
+ }
1096
1124
1097
1125
// Get and lock the hardware vertex buffer of the mesh
1098
1126
Ogre::HardwareVertexBufferSharedPtr vbuf = render_op->vertexData ->vertexBufferBinding ->getBuffer (0 );
@@ -1164,9 +1192,6 @@ bool MeshVisual::addTexture(Texture& texture, uint32_t textureIndex)
1164
1192
{
1165
1193
uint32_t width = texture.width ;
1166
1194
uint32_t height = texture.height ;
1167
- uint32_t step = texture.channels ;
1168
-
1169
- uint32_t dataSize = width * height * step;
1170
1195
1171
1196
Ogre::PixelFormat pixelFormat = getOgrePixelFormatFromRosString (texture.pixelFormat );
1172
1197
0 commit comments