From 382fa6ac688097eb2980067255f4b8fe9395f3cd Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 25 Mar 2012 22:53:00 +0200 Subject: [PATCH] fixes --- apps/openmw/mwrender/occlusionquery.cpp | 10 +++++++--- libs/openengine/bullet/physic.cpp | 4 ++-- libs/openengine/bullet/physic.hpp | 7 +------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwrender/occlusionquery.cpp b/apps/openmw/mwrender/occlusionquery.cpp index 66086a90b..b5f3f9c10 100644 --- a/apps/openmw/mwrender/occlusionquery.cpp +++ b/apps/openmw/mwrender/occlusionquery.cpp @@ -49,6 +49,8 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod matQueryVisible->setDepthWriteEnabled(false); matQueryVisible->setColourWriteEnabled(false); // Uncomment this to visualize the occlusion query matQueryVisible->setDepthCheckEnabled(true); // Occluded by objects + matQueryVisible->setCullingMode(CULL_NONE); + matQueryVisible->setManualCullingMode(MANUAL_CULL_NONE); mBBNode = mSunNode->getParentSceneNode()->createChildSceneNode(); @@ -133,16 +135,18 @@ void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass void OcclusionQuery::renderQueueEnded(uint8 queueGroupId, const String& invocation, bool& repeatThisInvocation) { - if (queueGroupId == RENDER_QUEUE_SKIES_LATE && mWasVisible == false) + if (queueGroupId == RENDER_QUEUE_SKIES_LATE && mWasVisible == false && mDoQuery) { // for some reason our single object query returns wrong results when the sun query was never executed // (which can happen when we are in interiors, or when the sun is outside of the view frustum and gets culled) // so we force it here once everything has been rendered + mSunTotalAreaQuery->beginOcclusionQuery(); mSunTotalAreaQuery->endOcclusionQuery(); mSunVisibleAreaQuery->beginOcclusionQuery(); mSunVisibleAreaQuery->endOcclusionQuery(); - } + + } } void OcclusionQuery::update() @@ -201,7 +205,7 @@ void OcclusionQuery::update() for (std::vector::iterator it=mObjectsInfo.begin(); it!=mObjectsInfo.end(); ++it) { - if (!mRendering->getScene()->hasMovableObject((*it).name, (*it).typeName)) return; + if (!mRendering->getScene()->hasMovableObject((*it).name, (*it).typeName)) break; mRendering->getScene()->getMovableObject((*it).name, (*it).typeName)->setRenderQueueGroup( (*it).oldRenderqueue ); } diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index e6a7393cc..b1cd9eade 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -378,13 +378,11 @@ namespace Physic MyRayResultCallback resultCallback1; resultCallback1.m_collisionFilterMask = COL_WORLD; dynamicsWorld->rayTest(from, to, resultCallback1); - resultCallback1.sort(); std::vector< std::pair > results = resultCallback1.results; MyRayResultCallback resultCallback2; resultCallback2.m_collisionFilterMask = COL_ACTOR_INTERNAL|COL_ACTOR_EXTERNAL; dynamicsWorld->rayTest(from, to, resultCallback2); - resultCallback2.sort(); std::vector< std::pair > actorResults = resultCallback2.results; std::vector< std::pair > results2; @@ -401,6 +399,8 @@ namespace Physic results2.push_back( std::make_pair( (*it).first, static_cast(*(*it).second).mName ) ); } + std::sort(results2.begin(), results2.end(), MyRayResultCallback::cmp); + return results2; } }}; diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index 3ecae7c0c..f6c52cbf9 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -239,18 +239,13 @@ namespace Physic return rayResult.m_hitFraction; } - static bool cmp( const std::pair& i, const std::pair& j ) + static bool cmp( const std::pair& i, const std::pair& j ) { if( i.first > j.first ) return false; if( j.first > i.first ) return true; return false; } - void sort() - { - std::sort(results.begin(), results.end(), cmp); - } - std::vector < std::pair > results; };