1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 10:09:39 +00:00
This commit is contained in:
scrawl 2012-03-26 21:52:38 +02:00
parent 4ee03cd61f
commit bb3f3ce1db
3 changed files with 29 additions and 14 deletions

View file

@ -12,7 +12,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), mDoQuery(0), mSunVisibility(0), mQuerySingleObjectStarted(false),
mQuerySingleObjectRequested(false), mResponding(true), mDelay(0) mQuerySingleObjectRequested(false), mResponding(true), mDelay(0), mWasVisible(false), mObjectWasVisible(false)
{ {
mRendering = renderer; mRendering = renderer;
mSunNode = sunNode; mSunNode = sunNode;
@ -93,7 +93,7 @@ OcclusionQuery::~OcclusionQuery()
bool OcclusionQuery::supported() bool OcclusionQuery::supported()
{ {
if (!mResponding) std::cout << "Occlusion query timed out" << std::endl; //if (!mResponding) std::cout << "Occlusion query timed out" << std::endl;
return mSupported && mResponding; return mSupported && mResponding;
} }
@ -129,6 +129,7 @@ void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass
mQuerySingleObjectStarted = true; mQuerySingleObjectStarted = true;
mQuerySingleObjectRequested = false; mQuerySingleObjectRequested = false;
mActiveQuery = mSingleObjectQuery; mActiveQuery = mSingleObjectQuery;
mObjectWasVisible = true;
} }
if (mActiveQuery != NULL) if (mActiveQuery != NULL)
@ -136,18 +137,29 @@ 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 && mDoQuery) /**
* for every beginOcclusionQuery(), we want a respective pullOcclusionQuery() and vice versa
* this also means that results can be wrong at other places if we pull, but beginOcclusionQuery() was never called
* this can happen for example if the object that is tested is outside of the view frustum
* to prevent this, check if the queries have been performed after everything has been rendered and if not, start them manually
*/
if (queueGroupId == RENDER_QUEUE_SKIES_LATE)
{ {
// for some reason our single object query returns wrong results when the sun query was never executed if (mWasVisible == false && mDoQuery)
// (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();
mSunTotalAreaQuery->beginOcclusionQuery(); mSunVisibleAreaQuery->beginOcclusionQuery();
mSunTotalAreaQuery->endOcclusionQuery(); mSunVisibleAreaQuery->endOcclusionQuery();
mSunVisibleAreaQuery->beginOcclusionQuery(); }
mSunVisibleAreaQuery->endOcclusionQuery(); if (mObjectWasVisible == false && mQuerySingleObjectRequested)
{
mSingleObjectQuery->beginOcclusionQuery();
mSingleObjectQuery->endOcclusionQuery();
mQuerySingleObjectStarted = true;
mQuerySingleObjectRequested = false;
}
} }
} }
@ -159,6 +171,7 @@ void OcclusionQuery::update(float duration)
if (mDelay >= 2) mResponding = false; if (mDelay >= 2) mResponding = false;
mWasVisible = false; mWasVisible = false;
mObjectWasVisible = false;
// Adjust the position of the sun billboards according to camera viewing distance // Adjust the position of the sun billboards according to camera viewing distance
// we need to do this to make sure that _everything_ can occlude the sun // we need to do this to make sure that _everything_ can occlude the sun

View file

@ -78,6 +78,7 @@ namespace MWRender
std::vector<ObjectInfo> mObjectsInfo; std::vector<ObjectInfo> mObjectsInfo;
bool mWasVisible; bool mWasVisible;
bool mObjectWasVisible;
bool mResponding; bool mResponding;

View file

@ -294,7 +294,8 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
} }
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env) : SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env) :
mGlare(0), mGlareFade(0) mGlare(0), mGlareFade(0), mCloudBlendFactor(0),
mCloudOpacity(0), mCloudColour(1,1,1), mSkyColour(1,1,1), mCloudSpeed(0), mStarsOpacity(0)
{ {
mEnvironment = env; mEnvironment = env;
mViewport = pCamera->getViewport(); mViewport = pCamera->getViewport();