Skip to content

Commit

Permalink
Use custom simulation time variants for Ogre
Browse files Browse the repository at this point in the history
This fixes Particle FXs not respecting simulation time
Fixes #556

Signed-off-by: Matias N. Goldberg <[email protected]>
  • Loading branch information
darksylinc committed Mar 26, 2022
1 parent bb1b1c2 commit 8cfd0e1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ogre2/src/Ogre2Scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class ignition::rendering::Ogre2ScenePrivate
using namespace ignition;
using namespace rendering;

static const Ogre::Real kSimulationTime = Ogre::Real(1.0 / 60.0);

//////////////////////////////////////////////////
Ogre2Scene::Ogre2Scene(unsigned int _id, const std::string &_name) :
BaseScene(_id, _name), dataPtr(std::make_unique<Ogre2ScenePrivate>())
Expand Down Expand Up @@ -269,7 +271,11 @@ void Ogre2Scene::StartRendering(Ogre::Camera *_camera)
if (this->LegacyAutoGpuFlush())
{
auto engine = Ogre2RenderEngine::Instance();
engine->OgreRoot()->_fireFrameStarted();

Ogre::FrameEvent evt;
evt.timeSinceLastEvent = 0; // Not used by Ogre so we don't care
evt.timeSinceLastFrame = kSimulationTime;
engine->OgreRoot()->_fireFrameStarted(evt);

this->ogreSceneManager->updateSceneGraph();
}
Expand Down Expand Up @@ -332,7 +338,10 @@ void Ogre2Scene::EndFrame()
auto engine = Ogre2RenderEngine::Instance();
auto ogreRoot = engine->OgreRoot();

ogreRoot->_fireFrameRenderingQueued();
Ogre::FrameEvent evt;
evt.timeSinceLastEvent = 0; // Not used by Ogre so we don't care
evt.timeSinceLastFrame = kSimulationTime;
ogreRoot->_fireFrameRenderingQueued(evt);

auto itor = ogreRoot->getSceneManagerIterator();
while (itor.hasMoreElements())
Expand All @@ -341,7 +350,7 @@ void Ogre2Scene::EndFrame()
sceneManager->clearFrameData();
}

ogreRoot->_fireFrameEnded();
ogreRoot->_fireFrameEnded(evt);
}

//////////////////////////////////////////////////
Expand Down

0 comments on commit 8cfd0e1

Please sign in to comment.