summaryrefslogtreecommitdiff
path: root/indra/newview/llvocache.cpp
diff options
context:
space:
mode:
authorXiaohong Bao <bao@lindenlab.com>2013-10-17 20:21:17 -0600
committerXiaohong Bao <bao@lindenlab.com>2013-10-17 20:21:17 -0600
commitc8228b65f8a4a94220c92d89d1529ed484f6e84a (patch)
tree6a52a0bfadd158a428279d07bf2a8a54ce4f62be /indra/newview/llvocache.cpp
parent2b4dfefda216a0333426ac2a8f06d23ee6ef0aee (diff)
fix for SH-4569: Objects are not culled by size in the distance
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rwxr-xr-xindra/newview/llvocache.cpp41
1 files changed, 32 insertions, 9 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 89a49ff1ed..4d598c8845 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -548,10 +548,11 @@ class LLVOCacheOctreeCull : public LLViewerOctreeCull
{
public:
LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp,
- const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part)
+ const LLVector3& shift, bool use_object_cache_occlusion, F32 projection_area_cutoff, LLVOCachePartition* part)
: LLViewerOctreeCull(camera),
mRegionp(regionp),
- mPartition(part)
+ mPartition(part),
+ mProjectionAreaCutOff(projection_area_cutoff)
{
mLocalShift = shift;
mUseObjectCacheOcclusion = use_object_cache_occlusion;
@@ -605,6 +606,14 @@ public:
{
res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift));
}
+
+ if(res != 0)
+ {
+ //check if the objects projection large enough
+ const LLVector4a* exts = group->getObjectExtents();
+ res = checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff);
+ }
+
return res;
}
@@ -648,6 +657,7 @@ private:
LLVOCachePartition* mPartition;
LLViewerRegion* mRegionp;
LLVector3 mLocalShift; //shift vector from agent space to local region space.
+ F32 mProjectionAreaCutOff;
bool mUseObjectCacheOcclusion;
};
@@ -655,8 +665,8 @@ private:
class LLVOCacheOctreeBackCull : public LLViewerOctreeCull
{
public:
- LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius)
- : LLViewerOctreeCull(camera), mRegionp(regionp)
+ LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius, F32 projection_area_cutoff)
+ : LLViewerOctreeCull(camera), mRegionp(regionp), mProjectionAreaCutOff(projection_area_cutoff)
{
mLocalShift = shift;
mSphereRadius = back_sphere_radius;
@@ -671,7 +681,13 @@ public:
virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group)
{
const LLVector4a* exts = group->getObjectExtents();
- return backSphereCheck(exts[0], exts[1]);
+ if(backSphereCheck(exts[0], exts[1]))
+ {
+ //check if the objects projection large enough
+ const LLVector4a* exts = group->getObjectExtents();
+ return checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff);
+ }
+ return false;
}
virtual void processGroup(LLViewerOctreeGroup* base_group)
@@ -691,9 +707,10 @@ private:
F32 mSphereRadius;
LLViewerRegion* mRegionp;
LLVector3 mLocalShift; //shift vector from agent space to local region space.
+ F32 mProjectionAreaCutOff;
};
-void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius)
+void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius, F32 projection_area_cutoff)
{
if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
{
@@ -714,7 +731,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad
//localize the camera
LLVector3 region_agent = mRegionp->getOriginAgent();
- LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius);
+ LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius, projection_area_cutoff);
culler.traverse(mOctree);
mBackSlectionEnabled--;
@@ -730,6 +747,7 @@ 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");
if(!LLViewerRegion::sVOCacheCullingEnabled)
{
@@ -753,6 +771,11 @@ 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;
+
if(!mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
{
U32 seed = llmax(mLODPeriod >> 1, (U32)4);
@@ -765,7 +788,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
}
if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash)
{
- selectBackObjects(camera, back_sphere_radius);//process back objects selection
+ selectBackObjects(camera, back_sphere_radius, projection_threshold);//process back objects selection
return 0; //nothing changed, reduce frequency of culling
}
}
@@ -783,7 +806,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
LLVector3 region_agent = mRegionp->getOriginAgent();
camera.calcRegionFrustumPlanes(region_agent);
- LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, this);
+ LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, projection_threshold, this);
culler.traverse(mOctree);
if(mRegionp->getNumOfVisibleGroups() > 0)