summaryrefslogtreecommitdiff
path: root/indra/newview/llvocache.cpp
diff options
context:
space:
mode:
authorXiaohong Bao <bao@lindenlab.com>2013-05-23 18:25:21 -0600
committerXiaohong Bao <bao@lindenlab.com>2013-05-23 18:25:21 -0600
commit16616ae48d86da75b3809fa6be6c846a9d420603 (patch)
tree6af6a40e0d586d2c7f2a7c2bf1b80f321bda173f /indra/newview/llvocache.cpp
parent8026ac0dc9cb98eec6bb34cb6766c4150f876bf8 (diff)
for SH-4145: Interesting: Implement occlusion culling for object cache
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rw-r--r--indra/newview/llvocache.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index eba768fef4..6261540765 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -372,10 +372,11 @@ void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scal
//-------------------------------------------------------------------
LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
{
+ mLODPeriod = 16;
mRegionp = regionp;
mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;
- new LLviewerOctreeGroup(mOctree);
+ new LLOcclusionCullingGroup(mOctree, this);
}
void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry)
@@ -400,11 +401,31 @@ public:
mLocalShift = shift;
}
+ virtual bool earlyFail(LLviewerOctreeGroup* base_group)
+ {
+ LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
+ if(group->needsUpdate())
+ {
+ return false; //needs to issue new occlusion culling check.
+ }
+
+ group->checkOcclusion();
+
+ if (group->getOctreeNode()->getParent() && //never occlusion cull the root node
+ LLPipeline::sUseOcclusion && //ignore occlusion if disabled
+ group->isOcclusionState(LLSpatialGroup::OCCLUDED))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
{
- //S32 res = AABBInRegionFrustumGroupBounds(group);
+ S32 res = AABBInRegionFrustumGroupBounds(group);
- S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
+ //S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
if (res != 0)
{
res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift));
@@ -414,9 +435,9 @@ public:
virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
{
- //S32 res = AABBInRegionFrustumObjectBounds(group);
+ S32 res = AABBInRegionFrustumObjectBounds(group);
- S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
+ //S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
if (res != 0)
{
res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift));
@@ -426,7 +447,15 @@ public:
virtual void processGroup(LLviewerOctreeGroup* base_group)
{
- mRegionp->addVisibleGroup(base_group);
+ 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(group);
}
private: