diff options
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rwxr-xr-x | indra/newview/llvocache.cpp | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 01666778b1..ada412be8c 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -473,6 +473,31 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child) //------------------------------------------------------------------- //LLVOCachePartition //------------------------------------------------------------------- +LLVOCacheGroup::~LLVOCacheGroup() +{ + if(mOcclusionState[0] & ACTIVE_OCCLUSION) + { + ((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this); + } +} + +//virtual +void LLVOCacheGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) +{ + if (child->getListenerCount() == 0) + { + new LLVOCacheGroup(child, mSpatialPartition); + } + else + { + OCT_ERRS << "LLVOCacheGroup redundancy detected." << LL_ENDL; + } + + unbound(); + + ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); +} + LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) : LLTrace::MemTrackable<LLVOCachePartition>("LLVOCachePartition") { @@ -487,7 +512,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) mCulledTime[i] = 0; mCullHistory[i] = -1; } - new LLOcclusionCullingGroup(mOctree, this); + new LLVOCacheGroup(mOctree, this); } void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry) @@ -615,11 +640,11 @@ private: class LLVOCacheOctreeBackCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp) + LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius) : LLViewerOctreeCull(camera), mRegionp(regionp) { mLocalShift = shift; - mSphereRadius = 20.f; //20m + mSphereRadius = back_sphere_radius; } virtual S32 frustumCheck(const LLviewerOctreeGroup* group) @@ -653,7 +678,7 @@ private: LLVector3 mLocalShift; //shift vector from agent space to local region space. }; -void LLVOCachePartition::selectBackObjects(LLCamera &camera) +void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius) { if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { @@ -674,7 +699,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera) //localize the camera LLVector3 region_agent = mRegionp->getOriginAgent(); - LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp); + LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius); culler.traverse(mOctree); mBackSlectionEnabled--; @@ -689,6 +714,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera) 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"); if(!LLViewerRegion::sVOCacheCullingEnabled) { @@ -720,7 +746,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) } if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash) { - selectBackObjects(camera);//process back objects selection + selectBackObjects(camera, back_sphere_radius);//process back objects selection return 0; //nothing changed, reduce frequency of culling } } @@ -755,11 +781,11 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) { - LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp; + LLVOCacheGroup* group = (LLVOCacheGroup*)gp; if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION)) { - group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS); mOccludedGroups.insert(group); } } @@ -773,9 +799,9 @@ void LLVOCachePartition::processOccluders(LLCamera* camera) LLVector3 region_agent = mRegionp->getOriginAgent(); LLVector4a shift(region_agent[0], region_agent[1], region_agent[2]); - for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) + for(std::set<LLVOCacheGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { - LLOcclusionCullingGroup* group = *iter; + LLVOCacheGroup* group = *iter; group->doOcclusion(camera, &shift); } } @@ -787,15 +813,23 @@ void LLVOCachePartition::resetOccluders() return; } - for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) + for(std::set<LLVOCacheGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter) { - LLOcclusionCullingGroup* group = *iter; - group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION); + LLVOCacheGroup* group = *iter; + group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS); } mOccludedGroups.clear(); sNeedsOcclusionCheck = FALSE; } +void LLVOCachePartition::removeOccluder(LLVOCacheGroup* group) +{ + if(mOccludedGroups.empty()) + { + return; + } + mOccludedGroups.erase(group); +} //------------------------------------------------------------------- //LLVOCache //------------------------------------------------------------------- |