diff options
author | Xiaohong Bao <bao@lindenlab.com> | 2013-10-30 23:17:40 -0600 |
---|---|---|
committer | Xiaohong Bao <bao@lindenlab.com> | 2013-10-30 23:17:40 -0600 |
commit | 960765e8c7d49a48e66f2e55e980c60645d9ca37 (patch) | |
tree | 3f83c3212c4732c1e7acbe634c5e2baf1e32f86c | |
parent | 46c3bf7575a0366c20388d19815a5ee8e01cc0c6 (diff) |
more fix to reduce number of rendered triangles per frame.
-rw-r--r-- | indra/newview/llvieweroctree.h | 1 | ||||
-rwxr-xr-x | indra/newview/llviewerregion.cpp | 32 | ||||
-rwxr-xr-x | indra/newview/llvocache.cpp | 32 | ||||
-rwxr-xr-x | indra/newview/llvocache.h | 3 |
4 files changed, 41 insertions, 27 deletions
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index 611f285c8e..b03047cbbe 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -217,6 +217,7 @@ public: BOOL isVisible() const; virtual BOOL isRecentlyVisible() const; S32 getVisible(LLViewerCamera::eCameraID id) const {return mVisible[id];} + S32 getAnyVisible() const {return mAnyVisible;} bool isEmpty() const { return mOctreeNode->isEmpty(); } U32 getState() {return mState; } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index cbce2674a7..a4b7efc56a 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1359,6 +1359,8 @@ BOOL LLViewerRegion::isViewerCameraStatic() F32 LLViewerRegion::killInvisibleObjects(F32 max_time) { + static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); + #if 1 if(!sVOCacheCullingEnabled) { @@ -1369,6 +1371,10 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time) return max_time; } + LLVector4a camera_origin; + camera_origin.load3(LLViewerCamera::getInstance()->getOrigin().mV); + F32 squared_back_threshold = back_sphere_radius * back_sphere_radius; + bool unstable = sNewObjectCreationThrottle < 0; size_t max_update = unstable ? mImpl->mActiveSet.size() : 64; if(!mInvisibilityCheckHistory && isViewerCameraStatic()) @@ -1388,7 +1394,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time) iter = mImpl->mActiveSet.begin(); } - if(!(*iter)->isRecentlyVisible() && (unstable || (*iter)->mLastCameraUpdated < sLastCameraUpdated)) + if(!(*iter)->isAnyVisible(camera_origin, squared_back_threshold) && (unstable || (*iter)->mLastCameraUpdated < sLastCameraUpdated)) { killObject((*iter), delete_list); } @@ -1425,18 +1431,18 @@ void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& if(!drawablep->getParent()) { - LLViewerObject::const_child_list_t& child_list = drawablep->getVObj()->getChildren(); - for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); - iter != child_list.end(); iter++) - { - LLViewerObject* child = *iter; - if(child->mDrawable->isRecentlyVisible()) - { - //set the parent group visible if any of its children visible. - ((LLViewerOctreeEntryData*)drawablep)->setVisible(); - return; - } - } + //LLViewerObject::const_child_list_t& child_list = drawablep->getVObj()->getChildren(); + //for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); + // iter != child_list.end(); iter++) + //{ + // LLViewerObject* child = *iter; + // if(child->mDrawable->isRecentlyVisible()) + // { + // //set the parent group visible if any of its children visible. + // ((LLViewerOctreeEntryData*)drawablep)->setVisible(); + // return; + // } + //} delete_list.push_back(drawablep); } } diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index b1c7423b49..70b65f14be 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -358,26 +358,34 @@ void LLVOCacheEntry::updateDebugSettings() sBackAngleTanSquared = squared_back_angle; } -bool LLVOCacheEntry::isRecentlyVisible() const +bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold) { - bool vis = LLViewerOctreeEntryData::isRecentlyVisible(); - - if(!vis && getGroup()) + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup(); + if(!group) { - //recently visible to any camera? - vis = ((LLOcclusionCullingGroup*)getGroup())->isAnyRecentlyVisible(); + return false; } - //combination of projected area and squared distance - if(!vis && !mParentID && mSceneContrib > sBackAngleTanSquared) + //any visible + bool vis = group->isAnyRecentlyVisible(); + + //not ready to remove + if(!vis) { - F32 rad = getBinRadius(); - vis = (rad * rad / mSceneContrib < sBackDistanceSquared); + vis = (group->getAnyVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame()); } - if(!vis) + //within the back sphere + if(!vis && !mParentID) { - vis = (getVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame()); + LLVector4a lookAt; + lookAt.setSub(getPositionGroup(), camera_origin); + F32 squared_dist = lookAt.dot3(lookAt).getF32(); + F32 rad = getBinRadius(); + rad *= rad; + + //rough estimation + vis = (squared_dist - rad < squared_dist_threshold); } return vis; diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index 446111620d..ae32fb0cee 100755 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -85,8 +85,7 @@ public: bool hasState(U32 state) {return mState & state;} U32 getState() const {return mState;} - //virtual - bool isRecentlyVisible() const; + bool isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold); U32 getLocalID() const { return mLocalID; } U32 getCRC() const { return mCRC; } |