diff options
Diffstat (limited to 'indra/newview/llviewerregion.cpp')
-rwxr-xr-x | indra/newview/llviewerregion.cpp | 113 |
1 files changed, 74 insertions, 39 deletions
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index cbce2674a7..56e0142dd6 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1047,25 +1047,23 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry) mImpl->mVisibleEntries.insert(entry); } -F32 LLViewerRegion::updateVisibleEntries(F32 max_time) +void LLViewerRegion::updateVisibleEntries(F32 max_time) { if(mDead) { - return max_time; + return; } if(mImpl->mVisibleGroups.empty() && mImpl->mVisibleEntries.empty()) { - return max_time; + return; } if(!sNewObjectCreationThrottle) { - return max_time; + return; } - LLTimer update_timer; - const F32 LARGE_SCENE_CONTRIBUTION = 100.f; //a large number to force to load the object. const LLVector3 camera_origin = LLViewerCamera::getInstance()->getOrigin(); const U32 cur_frame = LLViewerOctreeEntryData::getCurrentFrame(); @@ -1163,28 +1161,24 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time) mImpl->mLastCameraUpdate = cur_frame; } - return max_time - update_timer.getElapsedTimeF32(); + return; } -F32 LLViewerRegion::createVisibleObjects(F32 max_time) +void LLViewerRegion::createVisibleObjects(F32 max_time) { - static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF"); - if(mDead) { - return max_time; + return; } if(mImpl->mWaitingList.empty()) { mImpl->mVOCachePartition->setCullHistory(FALSE); - return max_time; + return; } //object projected area threshold - F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio(); - F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f; - projection_threshold *= projection_threshold; - + F32 projection_threshold = LLVOCacheEntry::getSquaredObjectScreenAreaThreshold(); + S32 throttle = sNewObjectCreationThrottle; BOOL has_new_obj = FALSE; LLTimer update_timer; @@ -1211,7 +1205,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time) mImpl->mVOCachePartition->setCullHistory(has_new_obj); - return max_time - update_timer.getElapsedTimeF32(); + return; } void LLViewerRegion::clearCachedVisibleObjects() @@ -1273,12 +1267,31 @@ void LLViewerRegion::clearCachedVisibleObjects() return; } -BOOL LLViewerRegion::idleUpdate(F32 max_update_time) +//perform some necessary but very light updates. +//to replace the function idleUpdate(...) in case there is no enough time. +void LLViewerRegion::lightIdleUpdate() +{ + if(!sVOCacheCullingEnabled) + { + return; + } + if(mImpl->mCacheMap.empty()) + { + return; + } + + //reset all occluders + mImpl->mVOCachePartition->resetOccluders(); +} + +void LLViewerRegion::idleUpdate(F32 max_update_time) { LLTimer update_timer; + F32 max_time; + + mLastUpdate = LLViewerOctreeEntryData::getCurrentFrame(); - // did_update returns TRUE if we did at least one significant update - BOOL did_update = mImpl->mLandp->idleUpdate(max_update_time); + mImpl->mLandp->idleUpdate(max_update_time); if (mParcelOverlay) { @@ -1288,32 +1301,39 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time) if(!sVOCacheCullingEnabled) { - return did_update; + return; } if(mImpl->mCacheMap.empty()) { - return did_update; + return; } if(mPaused) { mPaused = FALSE; //unpause. } + LLViewerCamera::eCameraID old_camera_id = LLViewerCamera::sCurCameraID; + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; + //reset all occluders mImpl->mVOCachePartition->resetOccluders(); - max_update_time -= update_timer.getElapsedTimeF32(); + max_time = max_update_time - update_timer.getElapsedTimeF32(); //kill invisible objects - max_update_time = killInvisibleObjects(max_update_time); - - max_update_time = updateVisibleEntries(max_update_time); - createVisibleObjects(max_update_time); + killInvisibleObjects(max_time * 0.4f); + max_time = max_update_time - update_timer.getElapsedTimeF32(); + + updateVisibleEntries(max_time); + max_time = max_update_time - update_timer.getElapsedTimeF32(); + + createVisibleObjects(max_time); mImpl->mWaitingList.clear(); mImpl->mVisibleGroups.clear(); - return did_update; + LLViewerCamera::sCurCameraID = old_camera_id; + return; } //update the throttling number for new object creation @@ -1357,18 +1377,24 @@ BOOL LLViewerRegion::isViewerCameraStatic() return sLastCameraUpdated < LLViewerOctreeEntryData::getCurrentFrame(); } -F32 LLViewerRegion::killInvisibleObjects(F32 max_time) +void LLViewerRegion::killInvisibleObjects(F32 max_time) { -#if 1 + static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); + if(!sVOCacheCullingEnabled) { - return max_time; + return; } if(mImpl->mActiveSet.empty()) { - return max_time; + return; } + LLTimer update_timer; + 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,10 +1414,15 @@ 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); } + + if(max_time < update_timer.getElapsedTimeF32()) //time out + { + break; + } } if(iter == mImpl->mActiveSet.end()) @@ -1413,8 +1444,8 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time) } delete_list.clear(); } -#endif - return max_time; + + return; } void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list) @@ -1430,11 +1461,15 @@ void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& iter != child_list.end(); iter++) { LLViewerObject* child = *iter; - if(child->mDrawable->isRecentlyVisible()) + if(child->mDrawable) { - //set the parent group visible if any of its children visible. - ((LLViewerOctreeEntryData*)drawablep)->setVisible(); - return; + LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)child->mDrawable->getGroup(); + if(group && group->isAnyRecentlyVisible()) + { + //set the parent group visible if any of its children visible. + ((LLViewerOctreeEntryData*)drawablep)->setVisible(); + return; + } } } delete_list.push_back(drawablep); |