diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 95d221933..00849503c 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -53,9 +53,10 @@ namespace MWInput , mUIYMultiplier (Settings::Manager::getFloat("ui y multiplier", "Input")) , mPreviewPOVDelay(0.f) , mTimeIdle(0.f) - , mCreated(false) { create(); + + changeInputMode(false); } @@ -138,10 +139,6 @@ namespace MWInput mControlSwitch["playermagic"] = true; mControlSwitch["playerviewswitch"] = true; mControlSwitch["vanitymode"] = true; - - changeInputMode(false); - - mCreated = true; } void InputManager::destroy() @@ -153,7 +150,6 @@ namespace MWInput mInputManager->destroyInputObject(mKeyboard); mInputManager->destroyInputObject(mMouse); OIS::InputManager::destroyInputSystem(mInputManager); - mCreated = false; } InputManager::~InputManager() @@ -250,13 +246,12 @@ namespace MWInput case A_ToggleHUD: mWindows.toggleHud(); break; - } + } } } void InputManager::update(float dt, bool loading) { - if (!mCreated) return; // Tell OIS to handle all input events mKeyboard->capture(); mMouse->capture(); diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index 100bba4fb..7be35ee0b 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -131,8 +131,6 @@ namespace MWInput std::string mUserFile; - bool mCreated; - bool mDragDrop; bool mInvertY; diff --git a/apps/openmw/mwrender/occlusionquery.cpp b/apps/openmw/mwrender/occlusionquery.cpp index c9e649fe6..8d16d7b7d 100644 --- a/apps/openmw/mwrender/occlusionquery.cpp +++ b/apps/openmw/mwrender/occlusionquery.cpp @@ -15,7 +15,7 @@ using namespace Ogre; OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNode* sunNode) : mSunTotalAreaQuery(0), mSunVisibleAreaQuery(0), mSingleObjectQuery(0), mActiveQuery(0), mDoQuery(0), mSunVisibility(0), mQuerySingleObjectStarted(false), mTestResult(false), - mQuerySingleObjectRequested(false), mWasVisible(false), mObjectWasVisible(false), mDoQuery2(false), + mQuerySingleObjectRequested(false), mWasVisible(false), mObjectWasVisible(false), mBBNode(0), mActive(false) { mRendering = renderer; @@ -94,6 +94,9 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod OcclusionQuery::~OcclusionQuery() { + mRendering->getScene()->removeRenderObjectListener (this); + mRendering->getScene()->removeRenderQueueListener(this); + RenderSystem* renderSystem = Root::getSingleton().getRenderSystem(); if (mSunTotalAreaQuery) renderSystem->destroyHardwareOcclusionQuery(mSunTotalAreaQuery); if (mSunVisibleAreaQuery) renderSystem->destroyHardwareOcclusionQuery(mSunVisibleAreaQuery); @@ -109,6 +112,7 @@ void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass const LightList* pLightList, bool suppressRenderStateChanges) { if (!mActive) return; + // The following code activates and deactivates the occlusion queries // so that the queries only include the rendering of the intended meshes @@ -116,6 +120,7 @@ void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass // Each occlusion query should only last a single rendering if (mActiveQuery != NULL) { + std::cout << "ending query (notifyRenderSingleObject)" << std::endl; mActiveQuery->endOcclusionQuery(); mActiveQuery = NULL; } @@ -123,6 +128,7 @@ void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass // Open a new occlusion query if (mDoQuery == true) { + std::cout << "opening new query" << std::endl; if (rend == mBBQueryTotal) { mActiveQuery = mSunTotalAreaQuery; @@ -208,6 +214,7 @@ void OcclusionQuery::update(float duration) && !mSunVisibleAreaQuery->isStillOutstanding() && !mSingleObjectQuery->isStillOutstanding()) { + std::cout << "update(), nothing is outstanding"<< std::endl; unsigned int totalPixels; unsigned int visiblePixels; @@ -243,6 +250,8 @@ void OcclusionQuery::occlusionTest(const Ogre::Vector3& position, Ogre::SceneNod assert( !occlusionTestPending() && "Occlusion test still pending"); + std::cout << "Occlusion test called " << std::endl; + mBBQuerySingleObject->setVisible(true); mObjectNode->setPosition(position); @@ -250,6 +259,8 @@ void OcclusionQuery::occlusionTest(const Ogre::Vector3& position, Ogre::SceneNod mObjectNode->setScale( Vector3(1,1,1)*(position - mRendering->getCamera()->getRealPosition()).length() ); mQuerySingleObjectRequested = true; + + mDoQuery = true; } bool OcclusionQuery::occlusionTestPending() diff --git a/apps/openmw/mwrender/occlusionquery.hpp b/apps/openmw/mwrender/occlusionquery.hpp index af6f668c1..c7a5757d3 100644 --- a/apps/openmw/mwrender/occlusionquery.hpp +++ b/apps/openmw/mwrender/occlusionquery.hpp @@ -95,7 +95,6 @@ namespace MWRender bool mSupported; bool mDoQuery; - bool mDoQuery2; bool mQuerySingleObjectRequested; bool mQuerySingleObjectStarted; diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 9e50b2bce..afbdbb06f 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -326,6 +326,10 @@ void RenderingManager::update (float duration, bool paused) { if (mRecreateWindowInNextFrame) { + mRecreateWindowInNextFrame = false; + + mRendering.removeWindowEventListener(this); + mRendering.getWindow()->removeListener(this); MWBase::Environment::get().getInputManager()->destroy(); OEngine::Render::WindowSettings windowSettings; @@ -338,8 +342,15 @@ void RenderingManager::update (float duration, bool paused) mRendering.recreateWindow("OpenMW", windowSettings); MWBase::Environment::get().getInputManager()->create(); - mRecreateWindowInNextFrame = false; + mRendering.setWindowEventListener (this); + mRendering.getWindow()->addListener(this); + + // this is necessary, otherwise it would just endlessly wait for the last query and it would never return + delete mOcclusionQuery; + mOcclusionQuery = new OcclusionQuery(&mRendering, mSkyManager->getSunNode()); } + + Ogre::Vector3 orig, dest; mPlayer->setCameraDistance(); if (!mPlayer->getPosition(orig, dest)) { diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 4ff8945ac..867829564 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -418,7 +418,7 @@ void Water::applyRTT() mReflection = NULL; // Create rendertarget for reflection - int rttsize = Settings::Manager::getInt("rtt size", "Water"); + //int rttsize = Settings::Manager::getInt("rtt size", "Water"); if (Settings::Manager::getBool("shader", "Water")) { diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index e0abf420e..c4f35e087 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -288,12 +288,12 @@ void OgreRenderer::adjustViewport() void OgreRenderer::setWindowEventListener(Ogre::WindowEventListener* listener) { - //Ogre::WindowEventUtilities::addWindowEventListener(mWindow, listener); + Ogre::WindowEventUtilities::addWindowEventListener(mWindow, listener); } void OgreRenderer::removeWindowEventListener(Ogre::WindowEventListener* listener) { - //Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, listener); + Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, listener); } void OgreRenderer::setFov(float fov)