Skip to content

Commit

Permalink
Fix loading render engine plugins in GUI (#1694)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Silvio <[email protected]>
  • Loading branch information
iche033 authored and traversaro committed Oct 19, 2022
1 parent bd1c5b6 commit 35ce83a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions include/ignition/gazebo/rendering/RenderUtil.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/gui/plugins/scene_manager/GzSceneManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Entity> newEntities;

Expand Down Expand Up @@ -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<std::mutex> lock(this->dataPtr->newRemovedEntityMutex);
Expand Down
12 changes: 9 additions & 3 deletions src/rendering/RenderUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2496,16 +2496,22 @@ 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()
{
// Already initialized
if (nullptr != this->dataPtr->scene)
return;

ignition::common::SystemPaths pluginPath;
pluginPath.SetPluginPathEnv(kRenderPluginPathEnv);
rendering::setPluginPaths(pluginPath.PluginPaths());
this->InitRenderEnginePluginPaths();

std::map<std::string, std::string> params;
if (this->dataPtr->useCurrentGLContext)
Expand Down

0 comments on commit 35ce83a

Please sign in to comment.