diff options
author | Xiaohong Bao <bao@lindenlab.com> | 2013-06-24 11:44:36 -0600 |
---|---|---|
committer | Xiaohong Bao <bao@lindenlab.com> | 2013-06-24 11:44:36 -0600 |
commit | 6bb64e79985f0b724dd5b07703666e307a54a98b (patch) | |
tree | 9fd53fecb74135b51339a432e6de9b6f72e04771 /indra/newview/llvocache.cpp | |
parent | fe3cfb30d504155850ddf3752d2f55e6311990d6 (diff) | |
parent | d95d69cbc4063fae1d93ce2f0c4d22d3ef9c8edd (diff) |
Automated merge with http://bitbucket.org/lindenlab/viewer-interesting
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rwxr-xr-x | indra/newview/llvocache.cpp | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 93daf2e171..f23375adfa 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -244,6 +244,13 @@ U32 LLVOCacheEntry::getMinFrameRange()const void LLVOCacheEntry::addChild(LLVOCacheEntry* entry) { llassert(entry != NULL); + llassert(entry->getParentID() == mLocalID); + llassert(entry->getEntry() != NULL); + + if(!entry || !entry->getEntry() || entry->getParentID() != mLocalID) + { + return; + } mChildrenList.push_back(entry); } @@ -392,9 +399,10 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) class LLVOCacheOctreeCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion) + LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part) : LLViewerOctreeCull(camera), - mRegionp(regionp) + mRegionp(regionp), + mPartition(part) { mLocalShift = shift; mUseObjectCacheOcclusion = (use_object_cache_occlusion && LLPipeline::sUseOcclusion); @@ -415,6 +423,7 @@ public: if (group->isOcclusionState(LLSpatialGroup::OCCLUDED)) { + mPartition->addOccluders(group); return true; } } @@ -466,9 +475,10 @@ public: } private: - LLViewerRegion* mRegionp; - LLVector3 mLocalShift; //shift vector from agent space to local region space. - bool mUseObjectCacheOcclusion; + LLVOCachePartition* mPartition; + LLViewerRegion* mRegionp; + LLVector3 mLocalShift; //shift vector from agent space to local region space. + bool mUseObjectCacheOcclusion; }; S32 LLVOCachePartition::cull(LLCamera &camera) @@ -486,12 +496,48 @@ S32 LLVOCachePartition::cull(LLCamera &camera) LLVector3 region_agent = mRegionp->getOriginAgent(); camera.calcRegionFrustumPlanes(region_agent); - LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion); + mOccludedGroups.clear(); + + LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion, this); culler.traverse(mOctree); + if(!mOccludedGroups.empty()) + { + processOccluders(&camera); + mOccludedGroups.clear(); + } + return 0; } +void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) +{ + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp; + + const U32 MIN_WAIT_TIME = 16; //wait 16 frames to issue a new occlusion request + U32 last_issued_time = group->getLastOcclusionIssuedTime(); + if(gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME) + { + return; + } + + if(group && !group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) + { + group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + mOccludedGroups.insert(group); + } +} + +void LLVOCachePartition::processOccluders(LLCamera* camera) +{ + for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) + { + LLOcclusionCullingGroup* group = *iter; + group->doOcclusion(camera); + group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + } +} + //------------------------------------------------------------------- //LLVOCache //------------------------------------------------------------------- |