diff options
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rwxr-xr-x | indra/newview/llvocache.cpp | 69 |
1 files changed, 39 insertions, 30 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index b1c7423b49..2ff2d0f341 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -35,8 +35,6 @@ #include "pipeline.h" #include "llagentcamera.h" -F32 LLVOCacheEntry::sBackDistanceSquared = 0.f; -F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f; U32 LLVOCacheEntry::sMinFrameRange = 0; BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE; @@ -341,43 +339,53 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const //static void LLVOCacheEntry::updateDebugSettings() { - //distance to keep objects = back_dist_factor * draw_distance - static LLCachedControl<F32> back_dist_factor(gSavedSettings,"BackDistanceFactor"); - - //squared tan(projection angle of the bbox), default is 10 (degree) - static LLCachedControl<F32> squared_back_angle(gSavedSettings,"BackProjectionAngleSquared"); - //the number of frames invisible objects stay in memory static LLCachedControl<U32> inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime"); sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum +} - sBackDistanceSquared = back_dist_factor * gAgentCamera.mDrawDistance; - sBackDistanceSquared *= sBackDistanceSquared; +//static +F32 LLVOCacheEntry::getSquaredObjectScreenAreaThreshold() +{ + static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOff"); - sBackAngleTanSquared = squared_back_angle; + //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; + + return projection_threshold; } -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; @@ -744,8 +752,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion"); - static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); - static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF"); + static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius"); if(!LLViewerRegion::sVOCacheCullingEnabled) { @@ -770,10 +777,8 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); //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(); + if(!mCullHistory && LLViewerRegion::isViewerCameraStatic()) { U32 seed = llmax(mLODPeriod >> 1, (U32)4); @@ -832,6 +837,10 @@ void LLVOCachePartition::processOccluders(LLCamera* camera) { return; } + if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) + { + return; //no need for those cameras. + } LLVector3 region_agent = mRegionp->getOriginAgent(); LLVector4a shift(region_agent[0], region_agent[1], region_agent[2]); @@ -856,7 +865,7 @@ void LLVOCachePartition::resetOccluders() for(std::set<LLVOCacheGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { LLVOCacheGroup* group = *iter; - group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS); + group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); } mOccludedGroups.clear(); sNeedsOcclusionCheck = FALSE; |