diff options
author | Xiaohong Bao <bao@lindenlab.com> | 2013-11-13 11:41:29 -0700 |
---|---|---|
committer | Xiaohong Bao <bao@lindenlab.com> | 2013-11-13 11:41:29 -0700 |
commit | 754a671c93f55c3e1cde6cd2ee0771156f7abaf5 (patch) | |
tree | 357fb2d93798f01870654756623eec1dd42949f5 /indra/newview | |
parent | 0eba8e8f23ecbdbfcb9a409dd91a1e2a6c4d3f00 (diff) | |
parent | 58b153cf878370643bd61914538a80e6512c7e5c (diff) |
Automated merge with http://bitbucket.org/lindenlab/viewer-interesting
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/llviewerregion.cpp | 18 | ||||
-rwxr-xr-x | indra/newview/llvocache.cpp | 51 | ||||
-rwxr-xr-x | indra/newview/llvocache.h | 8 |
3 files changed, 57 insertions, 20 deletions
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index ae876c9f2e..f58eeb7e0b 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -956,6 +956,7 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d else //insert to vo cache tree. { entry->updateParentBoundingInfo(); + entry->saveBoundingSphere(); addToVOCacheTree(entry); } @@ -1125,6 +1126,8 @@ void LLViewerRegion::updateVisibleEntries(F32 max_time) // //object projected area threshold F32 projection_threshold = LLVOCacheEntry::getSquaredPixelThreshold(mImpl->mVOCachePartition->isFrontCull()); + F32 dist_threshold = mImpl->mVOCachePartition->isFrontCull() ? gAgentCamera.mDrawDistance : LLVOCacheEntry::sRearFarRadius; + std::set< LLPointer<LLViewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin(); for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter) { @@ -1147,7 +1150,7 @@ void LLViewerRegion::updateVisibleEntries(F32 max_time) continue; } - vo_entry->calcSceneContribution(local_origin, needs_update, last_update); + vo_entry->calcSceneContribution(local_origin, needs_update, last_update, dist_threshold); if(vo_entry->getSceneContribution() > projection_threshold) { mImpl->mWaitingList.insert(vo_entry); @@ -1384,9 +1387,10 @@ void LLViewerRegion::killInvisibleObjects(F32 max_time) LLTimer update_timer; LLVector4a camera_origin; camera_origin.load3(LLViewerCamera::getInstance()->getOrigin().mV); - F32 squared_back_threshold = LLVOCacheEntry::sRearFarRadius; - squared_back_threshold *= squared_back_threshold; - + LLVector4a local_origin; + local_origin.load3((LLViewerCamera::getInstance()->getOrigin() - getOriginAgent()).mV); + F32 back_threshold = LLVOCacheEntry::sRearFarRadius; + bool unstable = sNewObjectCreationThrottle < 0; size_t max_update = unstable ? mImpl->mActiveSet.size() : 64; if(!mInvisibilityCheckHistory && isViewerCameraStatic()) @@ -1405,8 +1409,12 @@ void LLViewerRegion::killInvisibleObjects(F32 max_time) { iter = mImpl->mActiveSet.begin(); } + if((*iter)->getParentID() > 0) + { + continue; //skip child objects, they are removed with their parent. + } - if(!(*iter)->isAnyVisible(camera_origin, squared_back_threshold) && (unstable || (*iter)->mLastCameraUpdated < sLastCameraUpdated)) + if(!(*iter)->isAnyVisible(camera_origin, local_origin, back_threshold) && (unstable || (*iter)->mLastCameraUpdated < sLastCameraUpdated)) { killObject((*iter), delete_list); } diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 3bacf5c319..92a8f7b18e 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -70,7 +70,8 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & mState(INACTIVE), mSceneContrib(0.f), mTouched(TRUE), - mParentID(0) + mParentID(0), + mBSphereRadius(-1.0f) { mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); @@ -90,7 +91,8 @@ LLVOCacheEntry::LLVOCacheEntry() mState(INACTIVE), mSceneContrib(0.f), mTouched(TRUE), - mParentID(0) + mParentID(0), + mBSphereRadius(-1.0f) { mDP.assignBuffer(mBuffer, 0); } @@ -103,7 +105,8 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) mState(INACTIVE), mSceneContrib(0.f), mTouched(FALSE), - mParentID(0) + mParentID(0), + mBSphereRadius(-1.0f) { S32 size = -1; BOOL success; @@ -391,7 +394,7 @@ F32 LLVOCacheEntry::getSquaredPixelThreshold(bool is_front) return projection_threshold; } -bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold) +bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, const LLVector4a& local_camera_origin, F32 dist_threshold) { LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup(); if(!group) @@ -412,19 +415,25 @@ bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 squared_d 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); + + if(mBSphereRadius > 0.f) + { + lookAt.setSub(mBSphereCenter, local_camera_origin); + dist_threshold += mBSphereRadius; + } + else + { + lookAt.setSub(getPositionGroup(), camera_origin); + dist_threshold += getBinRadius(); + } + + vis = (lookAt.dot3(lookAt).getF32() < dist_threshold * dist_threshold); } return vis; } -void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update) +void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update, F32 dist_threshold) { if(!needs_update && getVisible() >= last_update) { @@ -444,12 +453,28 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool else { F32 rad = getBinRadius(); - mSceneContrib = rad * rad / squared_dist; + dist_threshold += rad; + dist_threshold *= dist_threshold; + + if(squared_dist < dist_threshold) + { + mSceneContrib = rad * rad / squared_dist; + } + else + { + mSceneContrib = 0.f; //out of draw distance, not to load + } } setVisible(); } +void LLVOCacheEntry::saveBoundingSphere() +{ + mBSphereCenter = getPositionGroup(); + mBSphereRadius = getBinRadius(); +} + void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scale) { LLVector4a center, newMin, newMax; diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index 9d851288b4..6e10ab86ee 100755 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -85,14 +85,14 @@ public: bool hasState(U32 state) {return mState & state;} U32 getState() const {return mState;} - bool isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold); + bool isAnyVisible(const LLVector4a& camera_origin, const LLVector4a& local_camera_origin, F32 dist_threshold); U32 getLocalID() const { return mLocalID; } U32 getCRC() const { return mCRC; } S32 getHitCount() const { return mHitCount; } S32 getCRCChangeCount() const { return mCRCChangeCount; } - void calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update); + void calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update, F32 dist_threshold); void setSceneContribution(F32 scene_contrib) {mSceneContrib = scene_contrib;} F32 getSceneContribution() const { return mSceneContrib;} @@ -117,6 +117,7 @@ public: void setBoundingInfo(const LLVector3& pos, const LLVector3& scale); //called from processing object update message void updateParentBoundingInfo(); + void saveBoundingSphere(); void setTouched(BOOL touched = TRUE) {mTouched = touched;} BOOL isTouched() const {return mTouched;} @@ -153,6 +154,9 @@ protected: BOOL mTouched; //if set, this entry is valid, otherwise it is invalid. + LLVector4a mBSphereCenter; //bounding sphere center + F32 mBSphereRadius; //bounding sphere radius + public: static U32 sMinFrameRange; static F32 sNearRadiusSquared; |