actorid
scrawl 13 years ago
parent 53d4be5cf6
commit 382fa6ac68

@ -49,6 +49,8 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod
matQueryVisible->setDepthWriteEnabled(false); matQueryVisible->setDepthWriteEnabled(false);
matQueryVisible->setColourWriteEnabled(false); // Uncomment this to visualize the occlusion query matQueryVisible->setColourWriteEnabled(false); // Uncomment this to visualize the occlusion query
matQueryVisible->setDepthCheckEnabled(true); // Occluded by objects matQueryVisible->setDepthCheckEnabled(true); // Occluded by objects
matQueryVisible->setCullingMode(CULL_NONE);
matQueryVisible->setManualCullingMode(MANUAL_CULL_NONE);
mBBNode = mSunNode->getParentSceneNode()->createChildSceneNode(); 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) 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 // 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) // (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 // so we force it here once everything has been rendered
mSunTotalAreaQuery->beginOcclusionQuery(); mSunTotalAreaQuery->beginOcclusionQuery();
mSunTotalAreaQuery->endOcclusionQuery(); mSunTotalAreaQuery->endOcclusionQuery();
mSunVisibleAreaQuery->beginOcclusionQuery(); mSunVisibleAreaQuery->beginOcclusionQuery();
mSunVisibleAreaQuery->endOcclusionQuery(); mSunVisibleAreaQuery->endOcclusionQuery();
}
}
} }
void OcclusionQuery::update() void OcclusionQuery::update()
@ -201,7 +205,7 @@ void OcclusionQuery::update()
for (std::vector<ObjectInfo>::iterator it=mObjectsInfo.begin(); for (std::vector<ObjectInfo>::iterator it=mObjectsInfo.begin();
it!=mObjectsInfo.end(); ++it) 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 ); mRendering->getScene()->getMovableObject((*it).name, (*it).typeName)->setRenderQueueGroup( (*it).oldRenderqueue );
} }

@ -378,13 +378,11 @@ namespace Physic
MyRayResultCallback resultCallback1; MyRayResultCallback resultCallback1;
resultCallback1.m_collisionFilterMask = COL_WORLD; resultCallback1.m_collisionFilterMask = COL_WORLD;
dynamicsWorld->rayTest(from, to, resultCallback1); dynamicsWorld->rayTest(from, to, resultCallback1);
resultCallback1.sort();
std::vector< std::pair<float, btCollisionObject*> > results = resultCallback1.results; std::vector< std::pair<float, btCollisionObject*> > results = resultCallback1.results;
MyRayResultCallback resultCallback2; MyRayResultCallback resultCallback2;
resultCallback2.m_collisionFilterMask = COL_ACTOR_INTERNAL|COL_ACTOR_EXTERNAL; resultCallback2.m_collisionFilterMask = COL_ACTOR_INTERNAL|COL_ACTOR_EXTERNAL;
dynamicsWorld->rayTest(from, to, resultCallback2); dynamicsWorld->rayTest(from, to, resultCallback2);
resultCallback2.sort();
std::vector< std::pair<float, btCollisionObject*> > actorResults = resultCallback2.results; std::vector< std::pair<float, btCollisionObject*> > actorResults = resultCallback2.results;
std::vector< std::pair<float, std::string> > results2; std::vector< std::pair<float, std::string> > results2;
@ -401,6 +399,8 @@ namespace Physic
results2.push_back( std::make_pair( (*it).first, static_cast<PairCachingGhostObject&>(*(*it).second).mName ) ); results2.push_back( std::make_pair( (*it).first, static_cast<PairCachingGhostObject&>(*(*it).second).mName ) );
} }
std::sort(results2.begin(), results2.end(), MyRayResultCallback::cmp);
return results2; return results2;
} }
}}; }};

@ -239,18 +239,13 @@ namespace Physic
return rayResult.m_hitFraction; return rayResult.m_hitFraction;
} }
static bool cmp( const std::pair<float, btCollisionObject*>& i, const std::pair<float, btCollisionObject*>& j ) static bool cmp( const std::pair<float, std::string>& i, const std::pair<float, std::string>& j )
{ {
if( i.first > j.first ) return false; if( i.first > j.first ) return false;
if( j.first > i.first ) return true; if( j.first > i.first ) return true;
return false; return false;
} }
void sort()
{
std::sort(results.begin(), results.end(), cmp);
}
std::vector < std::pair<float, btCollisionObject*> > results; std::vector < std::pair<float, btCollisionObject*> > results;
}; };

Loading…
Cancel
Save