|
|
|
@ -5,6 +5,7 @@
|
|
|
|
|
#include <OgreBillboardSet.h>
|
|
|
|
|
#include <OgreHardwareOcclusionQuery.h>
|
|
|
|
|
#include <OgreEntity.h>
|
|
|
|
|
#include <OgreSubEntity.h>
|
|
|
|
|
|
|
|
|
|
using namespace MWRender;
|
|
|
|
|
using namespace Ogre;
|
|
|
|
@ -12,7 +13,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)
|
|
|
|
|
{
|
|
|
|
|
mRendering = renderer;
|
|
|
|
|
mSunNode = sunNode;
|
|
|
|
@ -82,7 +83,6 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod
|
|
|
|
|
mRendering->getScene()->addRenderObjectListener(this);
|
|
|
|
|
mRendering->getScene()->addRenderQueueListener(this);
|
|
|
|
|
mDoQuery = true;
|
|
|
|
|
mDoQuery2 = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OcclusionQuery::~OcclusionQuery()
|
|
|
|
@ -190,7 +190,6 @@ void OcclusionQuery::update(float duration)
|
|
|
|
|
// Stop occlusion queries until we get their information
|
|
|
|
|
// (may not happen on the same frame they are requested in)
|
|
|
|
|
mDoQuery = false;
|
|
|
|
|
mDoQuery2 = false;
|
|
|
|
|
|
|
|
|
|
if (!mSunTotalAreaQuery->isStillOutstanding()
|
|
|
|
|
&& !mSunVisibleAreaQuery->isStillOutstanding()
|
|
|
|
@ -252,3 +251,40 @@ bool OcclusionQuery::getTestResult()
|
|
|
|
|
|
|
|
|
|
return mTestResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool OcclusionQuery::isPotentialOccluder(Ogre::SceneNode* node)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
for (unsigned int i=0; i < node->numAttachedObjects(); ++i)
|
|
|
|
|
{
|
|
|
|
|
MovableObject* ob = node->getAttachedObject(i);
|
|
|
|
|
std::string type = ob->getMovableType();
|
|
|
|
|
if (type == "Entity")
|
|
|
|
|
{
|
|
|
|
|
Entity* ent = static_cast<Entity*>(ob);
|
|
|
|
|
for (unsigned int j=0; j < ent->getNumSubEntities(); ++j)
|
|
|
|
|
{
|
|
|
|
|
// if any sub entity has a material with depth write off,
|
|
|
|
|
// consider the object as not an occluder
|
|
|
|
|
MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
|
|
|
|
|
|
|
|
|
|
Material::TechniqueIterator techIt = mat->getTechniqueIterator();
|
|
|
|
|
while (techIt.hasMoreElements())
|
|
|
|
|
{
|
|
|
|
|
Technique* tech = techIt.getNext();
|
|
|
|
|
Technique::PassIterator passIt = tech->getPassIterator();
|
|
|
|
|
while (passIt.hasMoreElements())
|
|
|
|
|
{
|
|
|
|
|
Pass* pass = passIt.getNext();
|
|
|
|
|
|
|
|
|
|
if (pass->getDepthWriteEnabled() == false)
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|