diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/lldrawable.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llvieweroctree.cpp | 50 | ||||
-rw-r--r-- | indra/newview/llvieweroctree.h | 19 | ||||
-rw-r--r-- | indra/newview/llviewerregion.cpp | 98 | ||||
-rw-r--r-- | indra/newview/llviewerregion.h | 1 | ||||
-rw-r--r-- | indra/newview/llvocache.cpp | 49 | ||||
-rw-r--r-- | indra/newview/llvocache.h | 2 | ||||
-rw-r--r-- | indra/newview/llworld.cpp | 1 |
8 files changed, 116 insertions, 117 deletions
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index c782fbfe7e..1b7a98ba54 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -1473,19 +1473,6 @@ void LLSpatialBridge::shiftPos(const LLVector4a& vec) void LLSpatialBridge::cleanupReferences() { - LLPointer<LLVOCacheEntry> dummy_entry; - if (mDrawable && mDrawable->isDead() && mDrawable->getEntry()->hasVOCacheEntry()) - { - //create a dummy entry to insert the entire LLSpatialBridge to the vo_cache partition so it can be reloaded. - - dummy_entry = new LLVOCacheEntry(); - dummy_entry->setOctreeEntry(mEntry); - dummy_entry->addChild((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry()); - //llassert(!mDrawable->getParent()); - - //mDrawable->mParent = this; - } - LLDrawable::cleanupReferences(); if (mDrawable) { diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index b6e0674a95..7f502a6c51 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -675,6 +675,8 @@ void LLViewerOctreeCull::traverse(const OctreeNode* n) } } +//------------------------------------------ +//agent space group culling S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group) { return mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]); @@ -685,6 +687,14 @@ S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLviewerOctreeGrou return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); } +S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]); +} +//------------------------------------------ + +//------------------------------------------ +//agent space object set culling S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group) { return mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]); @@ -695,15 +705,47 @@ S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLviewerOctreeGro return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); } -S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group) { - return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]); + return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); } +//------------------------------------------ -S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group) +//------------------------------------------ +//local regional space group culling +S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group) { - return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); + return mCamera->AABBInRegionFrustumNoFarClip(group->mBounds[0], group->mBounds[1]); +} + +S32 LLViewerOctreeCull::AABBInRegionFrustumGroupBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInRegionFrustum(group->mBounds[0], group->mBounds[1]); +} + +S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLviewerOctreeGroup* group, const LLVector3& shift) +{ + return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist); +} +//------------------------------------------ + +//------------------------------------------ +//local regional space object culling +S32 LLViewerOctreeCull::AABBInRegionFrustumObjectBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInRegionFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); +} + +S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group) +{ + return mCamera->AABBInRegionFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]); +} + +S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLviewerOctreeGroup* group, const LLVector3& shift) +{ + return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist); } +//------------------------------------------ //virtual bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLviewerOctreeGroup* group) diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index b89014119c..f6ad3ac327 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -280,13 +280,26 @@ public: virtual bool earlyFail(LLviewerOctreeGroup* group); virtual void traverse(const OctreeNode* n); - S32 AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group); + //agent space group cull + S32 AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group); S32 AABBSphereIntersectGroupExtents(const LLviewerOctreeGroup* group); - S32 AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group); - S32 AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group); S32 AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group); + + //agent space object set cull + S32 AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group); + S32 AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group); S32 AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group); + //local region space group cull + S32 AABBInRegionFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group); + S32 AABBInRegionFrustumGroupBounds(const LLviewerOctreeGroup* group); + S32 AABBRegionSphereIntersectGroupExtents(const LLviewerOctreeGroup* group, const LLVector3& shift); + + //local region space object set cull + S32 AABBInRegionFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group); + S32 AABBInRegionFrustumObjectBounds(const LLviewerOctreeGroup* group); + S32 AABBRegionSphereIntersectObjectExtents(const LLviewerOctreeGroup* group, const LLVector3& shift); + virtual S32 frustumCheck(const LLviewerOctreeGroup* group) = 0; virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) = 0; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index ab692308b0..33e8348660 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -87,6 +87,7 @@ const F32 CAP_REQUEST_TIMEOUT = 18; const S32 MAX_CAP_REQUEST_ATTEMPTS = 30; LLViewerRegion* LLViewerRegion::sCurRegionp = NULL; +BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE; typedef std::map<std::string, std::string> CapabilityMap; @@ -141,7 +142,6 @@ public: LLVOCacheEntry::vocache_entry_map_t mCacheMap; //all cached entries LLVOCacheEntry::vocache_entry_set_t mActiveSet; //all active entries; LLVOCacheEntry::vocache_entry_set_t mWaitingSet; //entries waiting for LLDrawable to be generated. - std::set< LLPointer<LLVOCacheEntry> > mDummyEntries; //dummy vo cache entries, for LLSpatialBridge use. std::set< LLviewerOctreeGroup* > mVisibleGroups; //visible groupa LLVOCachePartition* mVOCachePartition; LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //must-be-created visible entries wait for objects creation. @@ -841,17 +841,8 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d { return; } - if(entry->isDummy()) - { - mImpl->mDummyEntries.insert(entry); //keep a copy to prevent from being deleted. - addToVOCacheTree(entry); - } - else if(!drawablep->getParent()) //root node - { - addToVOCacheTree(entry); - mImpl->mVisibleEntries.erase(entry); - } - else //child node + + if(drawablep->getParent()) //child object { LLViewerOctreeEntry* parent_oct_entry = drawablep->getParent()->getEntry(); if(parent_oct_entry && parent_oct_entry->hasVOCacheEntry()) @@ -860,7 +851,19 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d parent->addChild(entry); } } + else //insert to vo cache tree. + { + //shift to the local regional space from agent space + const LLVector3 pos = drawablep->getVObj()->getPositionRegion(); + LLVector4a vec(pos[0], pos[1], pos[2]); + LLVector4a shift; + shift.setSub(vec, entry->getPositionGroup()); + entry->shift(shift); + + addToVOCacheTree(entry); + } + mImpl->mVisibleEntries.erase(entry); mImpl->mActiveSet.erase(entry); mImpl->mWaitingSet.erase(entry); entry->setState(LLVOCacheEntry::INACTIVE); @@ -878,7 +881,10 @@ void LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group) void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry) { - static BOOL vo_cache_culling_enabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled"); + if(!sVOCacheCullingEnabled) + { + return; + } if(mDead || !entry || !entry->getEntry()) { @@ -954,12 +960,13 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time) //process visible entries max_time *= 0.5f; //only use up to half available time to update entries. +#if 1 for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();) { LLVOCacheEntry* vo_entry = *iter; vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate); - if(vo_entry->getState() < LLVOCacheEntry::WAITING && !vo_entry->isDummy()) + if(vo_entry->getState() < LLVOCacheEntry::WAITING) { mImpl->mWaitingList.insert(vo_entry); } @@ -987,12 +994,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time) if(!vo_entry->getNumOfChildren()) { - if(vo_entry->isDummy()) - { - mImpl->mDummyEntries.erase(vo_entry); - iter = mImpl->mVisibleEntries.erase(iter); - } - else if(vo_entry->getState() >= LLVOCacheEntry::WAITING) + if(vo_entry->getState() >= LLVOCacheEntry::WAITING) { iter = mImpl->mVisibleEntries.erase(iter); } @@ -1011,6 +1013,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time) // break; //} } +#endif //process visible groups std::set< LLviewerOctreeGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin(); @@ -1027,11 +1030,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time) if((*i)->hasVOCacheEntry()) { LLVOCacheEntry* vo_entry = (LLVOCacheEntry*)(*i)->getVOCacheEntry(); - if(vo_entry->isDummy()) - { - addVisibleCacheEntry(vo_entry); //for LLSpatialBridge. - continue; - } vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate); mImpl->mWaitingList.insert(vo_entry); @@ -1118,6 +1116,11 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time) F32 LLViewerRegion::killInvisibleObjects(F32 max_time) { + if(!sVOCacheCullingEnabled) + { + return max_time; + } + std::vector<LLDrawable*> delete_list; for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin(); iter != mImpl->mActiveSet.end(); ++iter) @@ -1695,13 +1698,6 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id) { - static BOOL vo_cache_culling_enabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled"); - - if(!vo_cache_culling_enabled) - { - return NULL; - } - LLVOCacheEntry* entry = getCacheEntry(local_id); removeFromVOCacheTree(entry); @@ -1741,44 +1737,6 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U8 &cache_miss_type) } addVisibleCacheEntry(entry); -#if 0 - if(entry->isBridgeChild()) //bridge child - { - addVisibleCacheEntry(entry); - } - else - { - U32 parent_id = entry->getParentID(); - if(parent_id > 0) //has parent - { - LLVOCacheEntry* parent = getCacheEntry(parent_id); - - if(parent) //parent cached - { - parent->addChild(entry); - - if(parent->isState(LLVOCacheEntry::INACTIVE)) - { - //addToVOCacheTree(parent); - addVisibleCacheEntry(parent); - } - else //parent visible - { - addVisibleCacheEntry(parent); - } - } - else //parent not cached. This should not happen, but just in case... - { - addVisibleCacheEntry(entry); - } - } - else //root node - { - //addToVOCacheTree(entry); - addVisibleCacheEntry(entry); - } - } -#endif return true; } else diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 9a47227f1c..dbc59cee8f 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -392,6 +392,7 @@ public: LLDynamicArray<LLUUID> mMapAvatarIDs; static LLViewerRegion* sCurRegionp; + static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not. private: LLViewerRegionImpl * mImpl; diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 8ea79dbae6..59645fdbe9 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -424,24 +424,6 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool setVisible(); } -U32 LLVOCacheEntry::getParentID() -{ - if(!(mState & CHILD)) - { - return 0; //not a child - } - - U32 parent_id = 0; - LLDataPackerBinaryBuffer* dp = getDP(); - if(dp) - { - dp->reset(); - dp->unpackU32(parent_id, "ParentID"); - dp->reset(); - } - return parent_id; -} - //------------------------------------------------------------------- //LLVOCachePartition //------------------------------------------------------------------- @@ -471,24 +453,31 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry) class LLVOCacheOctreeCull : public LLViewerOctreeCull { public: - LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp) : LLViewerOctreeCull(camera), mRegionp(regionp) {} + LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift) : LLViewerOctreeCull(camera), mRegionp(regionp) + { + mLocalShift = shift; + } virtual S32 frustumCheck(const LLviewerOctreeGroup* group) { - S32 res = AABBInFrustumNoFarClipGroupBounds(group); + //S32 res = AABBInRegionFrustumGroupBounds(group); + + S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group); if (res != 0) { - res = llmin(res, AABBSphereIntersectGroupExtents(group)); + res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift)); } return res; } virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) { - S32 res = AABBInFrustumNoFarClipObjectBounds(group); + //S32 res = AABBInRegionFrustumObjectBounds(group); + + S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group); if (res != 0) { - res = llmin(res, AABBSphereIntersectObjectExtents(group)); + res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift)); } return res; } @@ -500,10 +489,16 @@ public: private: LLViewerRegion* mRegionp; + LLVector3 mLocalShift; //shift vector from agent space to local region space. }; S32 LLVOCachePartition::cull(LLCamera &camera) { + if(!LLViewerRegion::sVOCacheCullingEnabled) + { + return 0; + } + if(mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame()) { return 0; //already visited. @@ -511,8 +506,12 @@ S32 LLVOCachePartition::cull(LLCamera &camera) mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame(); ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); - - LLVOCacheOctreeCull culler(&camera, mRegionp); + + //localize the camera + LLVector3 region_agent = mRegionp->getOriginAgent(); + camera.calcRegionFrustumPlanes(region_agent); + + LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent); culler.traverse(mOctree); return 0; diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index 4d058ffdac..f5cc5d2f75 100644 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -98,7 +98,6 @@ public: S32 getHitCount() const { return mHitCount; } S32 getCRCChangeCount() const { return mCRCChangeCount; } S32 getMinVisFrameRange()const; - U32 getParentID(); void calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update); void setSceneContribution(F32 scene_contrib) {mSceneContrib = scene_contrib;} @@ -118,7 +117,6 @@ public: LLVOCacheEntry* getChild(S32 i) {return mChildrenList[i];} S32 getNumOfChildren() {return mChildrenList.size();} void clearChildrenList() {mChildrenList.clear();} - bool isDummy() {return !mBuffer;} public: typedef std::map<U32, LLPointer<LLVOCacheEntry> > vocache_entry_map_t; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index aed2835e4a..7a7d6a7b43 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -110,6 +110,7 @@ LLWorld::LLWorld() : gGL.getTexUnit(0)->bind(mDefaultWaterTexturep); mDefaultWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); + LLViewerRegion::sVOCacheCullingEnabled = (BOOL)gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled"); } |