mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-11-04 06:26:42 +00:00 
			
		
		
		
	Listen to render window updates and properly activate/deactivate occlusion queries pre/post update.
This commit is contained in:
		
							parent
							
								
									15e51b76de
								
							
						
					
					
						commit
						5334934612
					
				
					 5 changed files with 26 additions and 10 deletions
				
			
		| 
						 | 
					@ -31,9 +31,9 @@ namespace MWRender
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Refraction::~Refraction()
 | 
					    Refraction::~Refraction()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        mRenderTarget->removeListener(this);
 | 
				
			||||||
        Ogre::TextureManager::getSingleton().remove("WaterRefraction");
 | 
					        Ogre::TextureManager::getSingleton().remove("WaterRefraction");
 | 
				
			||||||
        mParentCamera->getSceneManager()->destroyCamera(mCamera);
 | 
					        mParentCamera->getSceneManager()->destroyCamera(mCamera);
 | 
				
			||||||
        mRenderTarget->removeListener(this);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void Refraction::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
 | 
					    void Refraction::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,8 @@ namespace MWRender
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void Refraction::setWaterPlane(Ogre::Plane plane)
 | 
					    void Refraction::setWaterPlane(Ogre::Plane plane)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        mNearClipPlane = Ogre::Plane(-plane.normal, - (plane.d + 5) );
 | 
					        /// \todo
 | 
				
			||||||
 | 
					        mNearClipPlane = Ogre::Plane( -Ogre::Vector3(0,1,0), 0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,6 +62,8 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
 | 
				
			||||||
    mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5);
 | 
					    mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5);
 | 
				
			||||||
    mRendering.setWindowEventListener(this);
 | 
					    mRendering.setWindowEventListener(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mRendering.getWindow()->addListener(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mCompositors = new Compositors(mRendering.getViewport());
 | 
					    mCompositors = new Compositors(mRendering.getViewport());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mWater = 0;
 | 
					    mWater = 0;
 | 
				
			||||||
| 
						 | 
					@ -174,6 +176,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RenderingManager::~RenderingManager ()
 | 
					RenderingManager::~RenderingManager ()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    mRendering.getWindow()->removeListener(this);
 | 
				
			||||||
    mRendering.removeWindowEventListener(this);
 | 
					    mRendering.removeWindowEventListener(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    delete mPlayer;
 | 
					    delete mPlayer;
 | 
				
			||||||
| 
						 | 
					@ -337,10 +340,6 @@ void RenderingManager::update (float duration, bool paused)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mOcclusionQuery->update(duration);
 | 
					    mOcclusionQuery->update(duration);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // deactivate queries to make sure we aren't getting false results from several misc render targets
 | 
					 | 
				
			||||||
    // (will be reactivated at the bottom of this method)
 | 
					 | 
				
			||||||
    mOcclusionQuery->setActive(false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    mVideoPlayer->update ();
 | 
					    mVideoPlayer->update ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mRendering.update(duration);
 | 
					    mRendering.update(duration);
 | 
				
			||||||
| 
						 | 
					@ -396,10 +395,20 @@ void RenderingManager::update (float duration, bool paused)
 | 
				
			||||||
        orig = Ogre::Vector3(orig.x, orig.z, -orig.y);
 | 
					        orig = Ogre::Vector3(orig.x, orig.z, -orig.y);
 | 
				
			||||||
        mWater->update(duration, orig);
 | 
					        mWater->update(duration, orig);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void RenderingManager::preRenderTargetUpdate(const RenderTargetEvent &evt)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
    mOcclusionQuery->setActive(true);
 | 
					    mOcclusionQuery->setActive(true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void RenderingManager::postRenderTargetUpdate(const RenderTargetEvent &evt)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // deactivate queries to make sure we aren't getting false results from several misc render targets
 | 
				
			||||||
 | 
					    // (will be reactivated at the bottom of this method)
 | 
				
			||||||
 | 
					    mOcclusionQuery->setActive(false);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store)
 | 
					void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    const MWWorld::Store<ESM::Land> &lands =
 | 
					    const MWWorld::Store<ESM::Land> &lands =
 | 
				
			||||||
| 
						 | 
					@ -886,7 +895,7 @@ void RenderingManager::applyCompositors()
 | 
				
			||||||
        mCompositors->addCompositor("gbufferFinalizer", 2);
 | 
					        mCompositors->addCompositor("gbufferFinalizer", 2);
 | 
				
			||||||
        mCompositors->setCompositorEnabled("gbufferFinalizer", true);
 | 
					        mCompositors->setCompositorEnabled("gbufferFinalizer", true);
 | 
				
			||||||
        */
 | 
					        */
 | 
				
			||||||
}
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //if (mWater)
 | 
					    //if (mWater)
 | 
				
			||||||
        //mWater->assignTextures();
 | 
					        //mWater->assignTextures();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <boost/filesystem.hpp>
 | 
					#include <boost/filesystem.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <OgreRenderTargetListener.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "renderinginterface.hpp"
 | 
					#include "renderinginterface.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "objects.hpp"
 | 
					#include "objects.hpp"
 | 
				
			||||||
| 
						 | 
					@ -47,7 +49,7 @@ namespace MWRender
 | 
				
			||||||
    class GlobalMap;
 | 
					    class GlobalMap;
 | 
				
			||||||
    class VideoPlayer;
 | 
					    class VideoPlayer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RenderingManager: private RenderingInterface, public Ogre::WindowEventListener {
 | 
					class RenderingManager: private RenderingInterface, public Ogre::WindowEventListener, public Ogre::RenderTargetListener {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private:
 | 
					  private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -137,6 +139,10 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
 | 
				
			||||||
    void disableLights(bool sun); ///< @param sun whether or not to really disable the sunlight (otherwise just set diffuse to 0)
 | 
					    void disableLights(bool sun); ///< @param sun whether or not to really disable the sunlight (otherwise just set diffuse to 0)
 | 
				
			||||||
    void enableLights(bool sun);
 | 
					    void enableLights(bool sun);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
 | 
				
			||||||
 | 
					    void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }
 | 
					    bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }
 | 
				
			||||||
    OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }
 | 
					    OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -185,6 +185,7 @@ Water::Water (Ogre::Camera *camera, RenderingManager* rend, const ESM::Cell* cel
 | 
				
			||||||
    mRendering(rend),
 | 
					    mRendering(rend),
 | 
				
			||||||
    mWaterTimer(0.f),
 | 
					    mWaterTimer(0.f),
 | 
				
			||||||
    mReflection(NULL),
 | 
					    mReflection(NULL),
 | 
				
			||||||
 | 
					    mRefraction(NULL),
 | 
				
			||||||
    mSimulation(NULL)
 | 
					    mSimulation(NULL)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    mSimulation = new RippleSimulation(mSceneMgr);
 | 
					    mSimulation = new RippleSimulation(mSceneMgr);
 | 
				
			||||||
| 
						 | 
					@ -317,7 +318,7 @@ void Water::setHeight(const float height)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    mTop = height;
 | 
					    mTop = height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mWaterPlane = Plane(Vector3::UNIT_Y, height);
 | 
					    mWaterPlane = Plane(Vector3::UNIT_Y, -height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (mReflection)
 | 
					    if (mReflection)
 | 
				
			||||||
        mReflection->setWaterPlane(mWaterPlane);
 | 
					        mReflection->setWaterPlane(mWaterPlane);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -211,7 +211,6 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
 | 
				
			||||||
    mRoot->initialise(false);
 | 
					    mRoot->initialise(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // create a hidden 1x1 background window to keep resources when recreating the secondary (real) window
 | 
					    // create a hidden 1x1 background window to keep resources when recreating the secondary (real) window
 | 
				
			||||||
    /// \todo Why does this break occlusion queries? :(
 | 
					 | 
				
			||||||
    /*
 | 
					    /*
 | 
				
			||||||
    NameValuePairList params_;
 | 
					    NameValuePairList params_;
 | 
				
			||||||
    params_.insert(std::make_pair("title", title));
 | 
					    params_.insert(std::make_pair("title", title));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue