summaryrefslogtreecommitdiff
path: root/indra/newview/llvocache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rw-r--r--indra/newview/llvocache.cpp83
1 files changed, 55 insertions, 28 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index b67a6bbacd..bcd9dda652 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -60,8 +60,7 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
mDupeCount(0),
mCRCChangeCount(0),
mState(INACTIVE),
- mRepeatedVisCounter(0),
- mVisFrameRange(64),
+ mMinFrameRange(64),
mSceneContrib(0.f),
mTouched(TRUE),
mParentID(0)
@@ -81,8 +80,7 @@ LLVOCacheEntry::LLVOCacheEntry()
mCRCChangeCount(0),
mBuffer(NULL),
mState(INACTIVE),
- mRepeatedVisCounter(0),
- mVisFrameRange(64),
+ mMinFrameRange(64),
mSceneContrib(0.f),
mTouched(TRUE),
mParentID(0)
@@ -95,8 +93,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
mBuffer(NULL),
mUpdateFlags(-1),
mState(INACTIVE),
- mRepeatedVisCounter(0),
- mVisFrameRange(64),
+ mMinFrameRange(64),
mSceneContrib(0.f),
mTouched(FALSE),
mParentID(0)
@@ -215,35 +212,26 @@ void LLVOCacheEntry::setState(U32 state)
if(getState() == ACTIVE)
{
- const S32 MIN_REAVTIVE_INTERVAL = 20;
+ const S32 MIN_REAVTIVE_INTERVAL = 32;
U32 last_visible = getVisible();
setVisible();
- if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mVisFrameRange)
+ if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mMinFrameRange)
{
- mRepeatedVisCounter++;
+ mMinFrameRange = llmin(mMinFrameRange * 2, 2048);
}
else
{
- mRepeatedVisCounter = 0;
- mVisFrameRange = 64;
- }
-
- if(mRepeatedVisCounter > 2)
- {
- //if repeatedly becomes visible immediately after invisible, enlarge the visible frame range
-
- mRepeatedVisCounter = 0;
- mVisFrameRange *= 2;
+ mMinFrameRange = 64; //reset
}
}
}
//virtual
-S32 LLVOCacheEntry::getMinVisFrameRange()const
+S32 LLVOCacheEntry::getMinFrameRange()const
{
- return mVisFrameRange;
+ return mMinFrameRange;
}
void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
@@ -373,10 +361,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)
@@ -396,16 +385,41 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
class LLVOCacheOctreeCull : public LLViewerOctreeCull
{
public:
- LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift) : LLViewerOctreeCull(camera), mRegionp(regionp)
+ LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion)
+ : LLViewerOctreeCull(camera),
+ mRegionp(regionp)
{
mLocalShift = shift;
+ mUseObjectCacheOcclusion = (use_object_cache_occlusion && LLPipeline::sUseOcclusion);
+ }
+
+ virtual bool earlyFail(LLviewerOctreeGroup* base_group)
+ {
+ if( mUseObjectCacheOcclusion &&
+ base_group->getOctreeNode()->getParent()) //never occlusion cull the root node
+ {
+ LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
+ if(group->needsUpdate())
+ {
+ return false; //needs to issue new occlusion culling check.
+ }
+
+ group->checkOcclusion();
+
+ if (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));
@@ -415,9 +429,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));
@@ -427,16 +441,29 @@ 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;
};
S32 LLVOCachePartition::cull(LLCamera &camera)
{
+ static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion");
+
if(!LLViewerRegion::sVOCacheCullingEnabled)
{
return 0;
@@ -448,7 +475,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera)
LLVector3 region_agent = mRegionp->getOriginAgent();
camera.calcRegionFrustumPlanes(region_agent);
- LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent);
+ LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion);
culler.traverse(mOctree);
return 0;