Skip to content

Commit

Permalink
Set simulation time to Rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed Apr 3, 2022
1 parent 39a0ce3 commit a735700
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/rendering/RenderUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,8 @@ void RenderUtil::Update()
return;

this->dataPtr->updateMutex.lock();

this->dataPtr->scene->SetTime(this->dataPtr->simTime);
auto newScenes = std::move(this->dataPtr->newScenes);
auto newModels = std::move(this->dataPtr->newModels);
auto newLinks = std::move(this->dataPtr->newLinks);
Expand Down Expand Up @@ -2500,6 +2502,12 @@ void RenderUtil::Init()
this->dataPtr->scene->SetSkyEnabled(this->dataPtr->skyEnabled);
}
}

#if IGNITION_RENDERING_MAJOR_VERSION <= 6
// HACK: Tell ign-rendering6 to listen to SetTime calls
this->dataPtr->scene->SetTime(std::chrono::nanoseconds(-1));
#endif

this->dataPtr->sceneManager.SetScene(this->dataPtr->scene);
if (this->dataPtr->enableSensors)
this->dataPtr->markerManager.SetTopic("/sensors/marker");
Expand Down Expand Up @@ -2574,6 +2582,10 @@ void RenderUtil::SetSceneName(const std::string &_name)
void RenderUtil::SetScene(const rendering::ScenePtr &_scene)
{
this->dataPtr->scene = _scene;
#if IGNITION_RENDERING_MAJOR_VERSION <= 6
// HACK: Tell ign-rendering6 to listen to SetTime calls
this->dataPtr->scene->SetTime(std::chrono::nanoseconds(-1));
#endif
this->dataPtr->sceneManager.SetScene(_scene);
this->dataPtr->engine = _scene == nullptr ? nullptr : _scene->Engine();
}
Expand Down
1 change: 1 addition & 0 deletions src/systems/sensors/Sensors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ void SensorsPrivate::RunOnce()
{
IGN_PROFILE("PreRender");
this->eventManager->Emit<events::PreRender>();
this->scene->SetTime(this->updateTime);
// Update the scene graph manually to improve performance
// We only need to do this once per frame It is important to call
// sensors::RenderingSensor::SetManualSceneUpdate and set it to true
Expand Down

0 comments on commit a735700

Please sign in to comment.