From 740fd6deb384f6424207c2c8076dd9fb5697c9fc Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Mon, 12 Apr 2021 15:07:11 +0200 Subject: [PATCH] PlantFlagTool::makeFlag(): reload mesh resource A Reset also resets the ResourceManager, such that the mesh resource is not available anymore and createEntity() will fail. Fixes ros-visualization/rviz#1618 --- rviz_plugin_tutorials/src/plant_flag_tool.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rviz_plugin_tutorials/src/plant_flag_tool.cpp b/rviz_plugin_tutorials/src/plant_flag_tool.cpp index ea2689b1..9862be56 100644 --- a/rviz_plugin_tutorials/src/plant_flag_tool.cpp +++ b/rviz_plugin_tutorials/src/plant_flag_tool.cpp @@ -194,6 +194,12 @@ int PlantFlagTool::processMouseEvent( rviz::ViewportMouseEvent& event ) // This is a helper function to create a new flag in the Ogre scene and save its scene node in a list. void PlantFlagTool::makeFlag( const Ogre::Vector3& position ) { + if( rviz::loadMeshFromResource( flag_resource_ ).isNull() ) + { + ROS_ERROR( "PlantFlagTool: failed to load model resource '%s'.", flag_resource_.c_str() ); + return; + } + Ogre::SceneNode* node = scene_manager_->getRootSceneNode()->createChildSceneNode(); Ogre::Entity* entity = scene_manager_->createEntity( flag_resource_ ); node->attachObject( entity );