diff --git a/include/ignition/gazebo/rendering/RenderUtil.hh b/include/ignition/gazebo/rendering/RenderUtil.hh index a757ec5378..444d9c0daa 100644 --- a/include/ignition/gazebo/rendering/RenderUtil.hh +++ b/include/ignition/gazebo/rendering/RenderUtil.hh @@ -201,6 +201,10 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE { /// \brief Clears the set of selected entities and lowlights all of them. public: void DeselectAllEntities(); + /// \brief Init render engine plugins paths. This lets gz-rendering know + /// paths to find render engine plugins + public: void InitRenderEnginePluginPaths(); + /// \brief Helper function to get all child links of a model entity. /// \param[in] _entity Entity to find child links /// \return Vector of child links found for the parent entity diff --git a/src/gui/plugins/scene_manager/GzSceneManager.cc b/src/gui/plugins/scene_manager/GzSceneManager.cc index f04c61d07a..9d0c6b1338 100644 --- a/src/gui/plugins/scene_manager/GzSceneManager.cc +++ b/src/gui/plugins/scene_manager/GzSceneManager.cc @@ -59,6 +59,9 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE { /// \brief Rendering utility public: RenderUtil renderUtil; + /// \brief True if render engine plugins paths are initialized + public: bool renderEnginePluginPathsInit{false}; + /// \brief List of new entities from a gui event public: std::set newEntities; @@ -123,6 +126,12 @@ void GzSceneManager::Update(const UpdateInfo &_info, IGN_PROFILE("GzSceneManager::Update"); + if (!this->dataPtr->renderEnginePluginPathsInit) + { + this->dataPtr->renderUtil.InitRenderEnginePluginPaths(); + this->dataPtr->renderEnginePluginPathsInit = true; + } + this->dataPtr->renderUtil.UpdateECM(_info, _ecm); std::lock_guard lock(this->dataPtr->newRemovedEntityMutex); diff --git a/src/rendering/RenderUtil.cc b/src/rendering/RenderUtil.cc index 415908ff9c..6f4ef07941 100644 --- a/src/rendering/RenderUtil.cc +++ b/src/rendering/RenderUtil.cc @@ -2496,6 +2496,14 @@ bool RenderUtil::HeadlessRendering() const return this->dataPtr->isHeadlessRendering; } +///////////////////////////////////////////////// +void RenderUtil::InitRenderEnginePluginPaths() +{ + ignition::common::SystemPaths pluginPath; + pluginPath.SetPluginPathEnv(kRenderPluginPathEnv); + rendering::setPluginPaths(pluginPath.PluginPaths()); +} + ///////////////////////////////////////////////// void RenderUtil::Init() { @@ -2503,9 +2511,7 @@ void RenderUtil::Init() if (nullptr != this->dataPtr->scene) return; - ignition::common::SystemPaths pluginPath; - pluginPath.SetPluginPathEnv(kRenderPluginPathEnv); - rendering::setPluginPaths(pluginPath.PluginPaths()); + this->InitRenderEnginePluginPaths(); std::map params; if (this->dataPtr->useCurrentGLContext)