Fixing issues from last commit: restored input and occlusion queries

actorid
scrawl 12 years ago
parent c4d518132f
commit 31f760ccce

@ -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();

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

@ -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()

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

@ -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)) {

@ -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"))
{

@ -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)

Loading…
Cancel
Save