more fix to reduce number of rendered triangles per frame.

master
Xiaohong Bao 2013-10-30 23:17:40 -06:00
parent 46c3bf7575
commit 960765e8c7
4 changed files with 42 additions and 28 deletions

View File

@ -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; }

View File

@ -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);
}
}

View File

@ -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)
{
F32 rad = getBinRadius();
vis = (rad * rad / mSceneContrib < sBackDistanceSquared);
}
//any visible
bool vis = group->isAnyRecentlyVisible();
//not ready to remove
if(!vis)
{
vis = (getVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame());
vis = (group->getAnyVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame());
}
//within the back sphere
if(!vis && !mParentID)
{
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;

View File

@ -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; }