1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 15:39:41 +00:00

Avoid manually updating render targets from within frameRenderingQueued

This commit is contained in:
scrawl 2013-03-05 14:24:29 +01:00
parent 2486ec6cb9
commit fe7b2732d8
9 changed files with 34 additions and 3 deletions

View file

@ -62,6 +62,13 @@ void OMW::Engine::setAnimationVerbose(bool animverbose)
{ {
} }
bool OMW::Engine::frameStarted (const Ogre::FrameEvent& evt)
{
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
MWBase::Environment::get().getWorld()->frameStarted(evt.timeSinceLastFrame);
return true;
}
bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
{ {
try try

View file

@ -105,6 +105,7 @@ namespace OMW
void executeLocalScripts(); void executeLocalScripts();
virtual bool frameRenderingQueued (const Ogre::FrameEvent& evt); virtual bool frameRenderingQueued (const Ogre::FrameEvent& evt);
virtual bool frameStarted (const Ogre::FrameEvent& evt);
/// Load settings from various files, returns the path to the user settings file /// Load settings from various files, returns the path to the user settings file
std::string loadSettings (Settings::Manager & settings); std::string loadSettings (Settings::Manager & settings);

View file

@ -314,6 +314,7 @@ namespace MWBase
/// \todo this does not belong here /// \todo this does not belong here
virtual void playVideo(const std::string& name, bool allowSkipping) = 0; virtual void playVideo(const std::string& name, bool allowSkipping) = 0;
virtual void stopVideo() = 0; virtual void stopVideo() = 0;
virtual void frameStarted (float dt) = 0;
}; };
} }

View file

@ -939,4 +939,9 @@ void RenderingManager::updateWaterRippleEmitterPtr (const MWWorld::Ptr& old, con
mWater->updateEmitterPtr(old, ptr); mWater->updateEmitterPtr(old, ptr);
} }
void RenderingManager::frameStarted(float dt)
{
mWater->frameStarted(dt);
}
} // namespace } // namespace

View file

@ -196,6 +196,7 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
void playVideo(const std::string& name, bool allowSkipping); void playVideo(const std::string& name, bool allowSkipping);
void stopVideo(); void stopVideo();
void frameStarted(float dt);
protected: protected:
virtual void windowResized(Ogre::RenderWindow* rw); virtual void windowResized(Ogre::RenderWindow* rw);

View file

@ -191,7 +191,8 @@ Water::Water (Ogre::Camera *camera, RenderingManager* rend) :
mWaterTimer(0.f), mWaterTimer(0.f),
mReflection(NULL), mReflection(NULL),
mRefraction(NULL), mRefraction(NULL),
mSimulation(NULL) mSimulation(NULL),
mPlayer(0,0)
{ {
mSimulation = new RippleSimulation(mSceneMgr); mSimulation = new RippleSimulation(mSceneMgr);
@ -371,7 +372,12 @@ void Water::update(float dt, Ogre::Vector3 player)
mRendering->getSkyManager ()->setGlareEnabled (!mIsUnderwater); mRendering->getSkyManager ()->setGlareEnabled (!mIsUnderwater);
mSimulation->update(dt, Ogre::Vector2(player.x, player.y)); mPlayer = Ogre::Vector2(player.x, player.y);
}
void Water::frameStarted(float dt)
{
mSimulation->update(dt, mPlayer);
if (mReflection) if (mReflection)
mReflection->update(); mReflection->update();

View file

@ -7,6 +7,7 @@
#include <OgreRenderTargetListener.h> #include <OgreRenderTargetListener.h>
#include <OgreMaterial.h> #include <OgreMaterial.h>
#include <OgreTexture.h> #include <OgreTexture.h>
#include <OgreVector2.h>
#include <components/esm/loadcell.hpp> #include <components/esm/loadcell.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
@ -98,7 +99,7 @@ namespace MWRender {
}; };
/// Water rendering /// Water rendering
class Water : public Ogre::RenderTargetListener, public Ogre::RenderQueueListener, public sh::MaterialInstanceListener class Water : public sh::MaterialInstanceListener
{ {
static const int CELL_SIZE = 8192; static const int CELL_SIZE = 8192;
Ogre::Camera *mCamera; Ogre::Camera *mCamera;
@ -139,6 +140,8 @@ namespace MWRender {
Refraction* mRefraction; Refraction* mRefraction;
RippleSimulation* mSimulation; RippleSimulation* mSimulation;
Ogre::Vector2 mPlayer;
public: public:
Water (Ogre::Camera *camera, RenderingManager* rend); Water (Ogre::Camera *camera, RenderingManager* rend);
~Water(); ~Water();
@ -147,6 +150,7 @@ namespace MWRender {
void toggle(); void toggle();
void update(float dt, Ogre::Vector3 player); void update(float dt, Ogre::Vector3 player);
void frameStarted(float dt);
/// adds an emitter, position will be tracked automatically using its scene node /// adds an emitter, position will be tracked automatically using its scene node
void addEmitter (const MWWorld::Ptr& ptr, float scale = 1.f, float force = 1.f); void addEmitter (const MWWorld::Ptr& ptr, float scale = 1.f, float force = 1.f);

View file

@ -1469,4 +1469,9 @@ namespace MWWorld
{ {
mRendering->stopVideo(); mRendering->stopVideo();
} }
void World::frameStarted (float dt)
{
mRendering->frameStarted(dt);
}
} }

View file

@ -356,6 +356,7 @@ namespace MWWorld
/// \todo this does not belong here /// \todo this does not belong here
virtual void playVideo(const std::string& name, bool allowSkipping); virtual void playVideo(const std::string& name, bool allowSkipping);
virtual void stopVideo(); virtual void stopVideo();
virtual void frameStarted (float dt);
}; };
} }