1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-05 17:45:34 +00:00

Fixing issues from last commit: restored input and occlusion queries

This commit is contained in:
scrawl 2013-02-05 20:26:13 +01:00
parent c4d518132f
commit 31f760ccce
7 changed files with 30 additions and 16 deletions

View file

@ -53,9 +53,10 @@ namespace MWInput
, mUIYMultiplier (Settings::Manager::getFloat("ui y multiplier", "Input")) , mUIYMultiplier (Settings::Manager::getFloat("ui y multiplier", "Input"))
, mPreviewPOVDelay(0.f) , mPreviewPOVDelay(0.f)
, mTimeIdle(0.f) , mTimeIdle(0.f)
, mCreated(false)
{ {
create(); create();
changeInputMode(false);
} }
@ -138,10 +139,6 @@ namespace MWInput
mControlSwitch["playermagic"] = true; mControlSwitch["playermagic"] = true;
mControlSwitch["playerviewswitch"] = true; mControlSwitch["playerviewswitch"] = true;
mControlSwitch["vanitymode"] = true; mControlSwitch["vanitymode"] = true;
changeInputMode(false);
mCreated = true;
} }
void InputManager::destroy() void InputManager::destroy()
@ -153,7 +150,6 @@ namespace MWInput
mInputManager->destroyInputObject(mKeyboard); mInputManager->destroyInputObject(mKeyboard);
mInputManager->destroyInputObject(mMouse); mInputManager->destroyInputObject(mMouse);
OIS::InputManager::destroyInputSystem(mInputManager); OIS::InputManager::destroyInputSystem(mInputManager);
mCreated = false;
} }
InputManager::~InputManager() InputManager::~InputManager()
@ -250,13 +246,12 @@ namespace MWInput
case A_ToggleHUD: case A_ToggleHUD:
mWindows.toggleHud(); mWindows.toggleHud();
break; break;
} }
} }
} }
void InputManager::update(float dt, bool loading) void InputManager::update(float dt, bool loading)
{ {
if (!mCreated) return;
// Tell OIS to handle all input events // Tell OIS to handle all input events
mKeyboard->capture(); mKeyboard->capture();
mMouse->capture(); mMouse->capture();

View file

@ -131,8 +131,6 @@ namespace MWInput
std::string mUserFile; std::string mUserFile;
bool mCreated;
bool mDragDrop; bool mDragDrop;
bool mInvertY; bool mInvertY;

View file

@ -15,7 +15,7 @@ using namespace Ogre;
OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNode* sunNode) : OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNode* sunNode) :
mSunTotalAreaQuery(0), mSunVisibleAreaQuery(0), mSingleObjectQuery(0), mActiveQuery(0), mSunTotalAreaQuery(0), mSunVisibleAreaQuery(0), mSingleObjectQuery(0), mActiveQuery(0),
mDoQuery(0), mSunVisibility(0), mQuerySingleObjectStarted(false), mTestResult(false), 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) mBBNode(0), mActive(false)
{ {
mRendering = renderer; mRendering = renderer;
@ -94,6 +94,9 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod
OcclusionQuery::~OcclusionQuery() OcclusionQuery::~OcclusionQuery()
{ {
mRendering->getScene()->removeRenderObjectListener (this);
mRendering->getScene()->removeRenderQueueListener(this);
RenderSystem* renderSystem = Root::getSingleton().getRenderSystem(); RenderSystem* renderSystem = Root::getSingleton().getRenderSystem();
if (mSunTotalAreaQuery) renderSystem->destroyHardwareOcclusionQuery(mSunTotalAreaQuery); if (mSunTotalAreaQuery) renderSystem->destroyHardwareOcclusionQuery(mSunTotalAreaQuery);
if (mSunVisibleAreaQuery) renderSystem->destroyHardwareOcclusionQuery(mSunVisibleAreaQuery); if (mSunVisibleAreaQuery) renderSystem->destroyHardwareOcclusionQuery(mSunVisibleAreaQuery);
@ -109,6 +112,7 @@ void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass
const LightList* pLightList, bool suppressRenderStateChanges) const LightList* pLightList, bool suppressRenderStateChanges)
{ {
if (!mActive) return; if (!mActive) return;
// The following code activates and deactivates the occlusion queries // The following code activates and deactivates the occlusion queries
// so that the queries only include the rendering of the intended meshes // 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 // Each occlusion query should only last a single rendering
if (mActiveQuery != NULL) if (mActiveQuery != NULL)
{ {
std::cout << "ending query (notifyRenderSingleObject)" << std::endl;
mActiveQuery->endOcclusionQuery(); mActiveQuery->endOcclusionQuery();
mActiveQuery = NULL; mActiveQuery = NULL;
} }
@ -123,6 +128,7 @@ void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass
// Open a new occlusion query // Open a new occlusion query
if (mDoQuery == true) if (mDoQuery == true)
{ {
std::cout << "opening new query" << std::endl;
if (rend == mBBQueryTotal) if (rend == mBBQueryTotal)
{ {
mActiveQuery = mSunTotalAreaQuery; mActiveQuery = mSunTotalAreaQuery;
@ -208,6 +214,7 @@ void OcclusionQuery::update(float duration)
&& !mSunVisibleAreaQuery->isStillOutstanding() && !mSunVisibleAreaQuery->isStillOutstanding()
&& !mSingleObjectQuery->isStillOutstanding()) && !mSingleObjectQuery->isStillOutstanding())
{ {
std::cout << "update(), nothing is outstanding"<< std::endl;
unsigned int totalPixels; unsigned int totalPixels;
unsigned int visiblePixels; unsigned int visiblePixels;
@ -243,6 +250,8 @@ void OcclusionQuery::occlusionTest(const Ogre::Vector3& position, Ogre::SceneNod
assert( !occlusionTestPending() assert( !occlusionTestPending()
&& "Occlusion test still pending"); && "Occlusion test still pending");
std::cout << "Occlusion test called " << std::endl;
mBBQuerySingleObject->setVisible(true); mBBQuerySingleObject->setVisible(true);
mObjectNode->setPosition(position); 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() ); mObjectNode->setScale( Vector3(1,1,1)*(position - mRendering->getCamera()->getRealPosition()).length() );
mQuerySingleObjectRequested = true; mQuerySingleObjectRequested = true;
mDoQuery = true;
} }
bool OcclusionQuery::occlusionTestPending() bool OcclusionQuery::occlusionTestPending()

View file

@ -95,7 +95,6 @@ namespace MWRender
bool mSupported; bool mSupported;
bool mDoQuery; bool mDoQuery;
bool mDoQuery2;
bool mQuerySingleObjectRequested; bool mQuerySingleObjectRequested;
bool mQuerySingleObjectStarted; bool mQuerySingleObjectStarted;

View file

@ -326,6 +326,10 @@ void RenderingManager::update (float duration, bool paused)
{ {
if (mRecreateWindowInNextFrame) if (mRecreateWindowInNextFrame)
{ {
mRecreateWindowInNextFrame = false;
mRendering.removeWindowEventListener(this);
mRendering.getWindow()->removeListener(this);
MWBase::Environment::get().getInputManager()->destroy(); MWBase::Environment::get().getInputManager()->destroy();
OEngine::Render::WindowSettings windowSettings; OEngine::Render::WindowSettings windowSettings;
@ -338,8 +342,15 @@ void RenderingManager::update (float duration, bool paused)
mRendering.recreateWindow("OpenMW", windowSettings); mRendering.recreateWindow("OpenMW", windowSettings);
MWBase::Environment::get().getInputManager()->create(); 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; Ogre::Vector3 orig, dest;
mPlayer->setCameraDistance(); mPlayer->setCameraDistance();
if (!mPlayer->getPosition(orig, dest)) { if (!mPlayer->getPosition(orig, dest)) {

View file

@ -418,7 +418,7 @@ void Water::applyRTT()
mReflection = NULL; mReflection = NULL;
// Create rendertarget for reflection // 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")) if (Settings::Manager::getBool("shader", "Water"))
{ {

View file

@ -288,12 +288,12 @@ void OgreRenderer::adjustViewport()
void OgreRenderer::setWindowEventListener(Ogre::WindowEventListener* listener) void OgreRenderer::setWindowEventListener(Ogre::WindowEventListener* listener)
{ {
//Ogre::WindowEventUtilities::addWindowEventListener(mWindow, listener); Ogre::WindowEventUtilities::addWindowEventListener(mWindow, listener);
} }
void OgreRenderer::removeWindowEventListener(Ogre::WindowEventListener* listener) void OgreRenderer::removeWindowEventListener(Ogre::WindowEventListener* listener)
{ {
//Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, listener); Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, listener);
} }
void OgreRenderer::setFov(float fov) void OgreRenderer::setFov(float fov)