summaryrefslogtreecommitdiff
path: root/indra/newview/llvocache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rwxr-xr-xindra/newview/llvocache.cpp73
1 files changed, 55 insertions, 18 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 93daf2e171..60d78890b5 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);
@@ -406,15 +414,17 @@ public:
base_group->getOctreeNode()->getParent()) //never occlusion cull the root node
{
LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
- if(group->needsUpdate())
+ if(group->needsUpdate())//needs to issue new occlusion culling check.
{
- return false; //needs to issue new occlusion culling check.
+ mPartition->addOccluders(group);
+ return true;
}
group->checkOcclusion();
if (group->isOcclusionState(LLSpatialGroup::OCCLUDED))
{
+ mPartition->addOccluders(group);
return true;
}
}
@@ -452,23 +462,14 @@ public:
virtual void processGroup(LLviewerOctreeGroup* base_group)
{
- if(mUseObjectCacheOcclusion && base_group->getOctreeNode()->getParent())
- {
- LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
- if (group->needsUpdate() || group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1)
- {
- ((LLOcclusionCullingGroup*)group)->doOcclusion(mCamera);
- group->setVisible();
- return; //wait for occlusion culling results
- }
- }
mRegionp->addVisibleGroup(base_group);
}
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 +487,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, &region_agent);
+ mOccludedGroups.clear();
+ }
+
return 0;
}
+void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp)
+{
+ LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp;
+
+ const U32 MIN_WAIT_TIME = 19; //wait 19 frames to issue a new occlusion request
+ U32 last_issued_time = group->getLastOcclusionIssuedTime();
+ if(!group->needsUpdate() && gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME)
+ {
+ return;
+ }
+
+ if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION))
+ {
+ group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
+ mOccludedGroups.insert(group);
+ }
+}
+
+void LLVOCachePartition::processOccluders(LLCamera* camera, const LLVector3* region_agent)
+{
+ for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
+ {
+ LLOcclusionCullingGroup* group = *iter;
+ group->doOcclusion(camera, region_agent);
+ group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
+ }
+}
+
//-------------------------------------------------------------------
//LLVOCache
//-------------------------------------------------------------------