summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerregion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerregion.cpp')
-rw-r--r--indra/newview/llviewerregion.cpp108
1 files changed, 58 insertions, 50 deletions
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index a2ff232d02..85da75510b 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -86,7 +86,6 @@ const F32 CAP_REQUEST_TIMEOUT = 18;
// Even though we gave up on login, keep trying for caps after we are logged in:
const S32 MAX_CAP_REQUEST_ATTEMPTS = 30;
-LLViewerRegion* LLViewerRegion::sCurRegionp = NULL;
BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE;
typedef std::map<std::string, std::string> CapabilityMap;
@@ -94,28 +93,29 @@ typedef std::map<std::string, std::string> CapabilityMap;
class LLViewerRegionImpl {
public:
LLViewerRegionImpl(LLViewerRegion * region, LLHost const & host)
- : mHost(host),
- mCompositionp(NULL),
- mEventPoll(NULL),
- mSeedCapMaxAttempts(MAX_CAP_REQUEST_ATTEMPTS),
- mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN),
- mSeedCapAttempts(0),
- mHttpResponderID(0),
- mLastCameraUpdate(0),
- mLastCameraOrigin(),
- // I'd prefer to set the LLCapabilityListener name to match the region
- // name -- it's disappointing that's not available at construction time.
- // We could instead store an LLCapabilityListener*, making
- // setRegionNameAndZone() replace the instance. Would that pose
- // consistency problems? Can we even request a capability before calling
- // setRegionNameAndZone()?
- // For testability -- the new Michael Feathers paradigm --
- // LLCapabilityListener binds all the globals it expects to need at
- // construction time.
- mCapabilityListener(host.getString(), gMessageSystem, *region,
- gAgent.getID(), gAgent.getSessionID())
- {
- }
+ : mHost(host),
+ mCompositionp(NULL),
+ mEventPoll(NULL),
+ mSeedCapMaxAttempts(MAX_CAP_REQUEST_ATTEMPTS),
+ mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN),
+ mSeedCapAttempts(0),
+ mHttpResponderID(0),
+ mLastCameraUpdate(0),
+ mLastCameraOrigin(),
+ mVOCachePartition(NULL),
+ mLandp(NULL),
+ // I'd prefer to set the LLCapabilityListener name to match the region
+ // name -- it's disappointing that's not available at construction time.
+ // We could instead store an LLCapabilityListener*, making
+ // setRegionNameAndZone() replace the instance. Would that pose
+ // consistency problems? Can we even request a capability before calling
+ // setRegionNameAndZone()?
+ // For testability -- the new Michael Feathers paradigm --
+ // LLCapabilityListener binds all the globals it expects to need at
+ // construction time.
+ mCapabilityListener(host.getString(), gMessageSystem, *region,
+ gAgent.getID(), gAgent.getSessionID())
+ {}
void buildCapabilityNames(LLSD& capabilityNames);
@@ -142,7 +142,7 @@ 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< LLviewerOctreeGroup* > mVisibleGroups; //visible groupa
+ std::set< LLPointer<LLviewerOctreeGroup> > mVisibleGroups; //visible groupa
LLVOCachePartition* mVOCachePartition;
LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //must-be-created visible entries wait for objects creation.
LLVOCacheEntry::vocache_entry_priority_list_t mWaitingList; //transient list storing sorted visible entries waiting for object creation.
@@ -439,7 +439,7 @@ void LLViewerRegion::loadObjectCache()
// Presume success. If it fails, we don't want to try again.
mCacheLoaded = TRUE;
- if(LLVOCache::hasInstance())
+ if(LLVOCache::instanceExists())
{
LLVOCache::getInstance()->readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap) ;
if (mImpl->mCacheMap.empty())
@@ -462,7 +462,7 @@ void LLViewerRegion::saveObjectCache()
return;
}
- if(LLVOCache::hasInstance())
+ if(LLVOCache::instanceExists())
{
const F32 start_time_threshold = 600.0f; //seconds
bool removal_enabled = sVOCacheCullingEnabled && (mRegionTimer.getElapsedTimeF32() > start_time_threshold); //allow to remove invalid objects from object cache file.
@@ -755,7 +755,7 @@ void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry
if(old_entry)
{
- old_entry->copyTo(new_entry);
+ old_entry->moveTo(new_entry);
state = old_entry->getState();
in_vo_tree = (state == LLVOCacheEntry::INACTIVE && old_entry->getGroup() != NULL);
killCacheEntry(old_entry);
@@ -942,18 +942,6 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
mImpl->mVisibleEntries.insert(entry);
}
-void LLViewerRegion::clearVisibleGroup(LLviewerOctreeGroup* group)
-{
- if(mDead)
- {
- return;
- }
-
- llassert(!group->getOctreeNode() || group->isEmpty());
-
- mImpl->mVisibleGroups.erase(group);
-}
-
F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
{
if(mImpl->mVisibleGroups.empty() && mImpl->mVisibleEntries.empty())
@@ -1024,11 +1012,12 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
#endif
//process visible groups
- std::set< LLviewerOctreeGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin();
+ std::set< LLPointer<LLviewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin();
for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
{
- LLviewerOctreeGroup* group = *group_iter;
- if(!group->getOctreeNode() || group->isEmpty())
+ LLPointer<LLviewerOctreeGroup> group = *group_iter;
+ if(group->getNumRefs() < 3 || //group to be deleted
+ !group->getOctreeNode() || group->isEmpty()) //group empty
{
continue;
}
@@ -1050,7 +1039,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
}
}
}
- mImpl->mVisibleGroups.clear();
if(needs_update)
{
@@ -1113,8 +1101,6 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
return did_update;
}
- sCurRegionp = this;
-
//kill invisible objects
max_update_time = killInvisibleObjects(max_update_time);
@@ -1122,9 +1108,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
createVisibleObjects(max_update_time);
mImpl->mVisibleGroups.clear();
- mImpl->mWaitingList.clear();
- sCurRegionp = NULL;
return did_update;
}
@@ -1135,16 +1119,40 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
{
return max_time;
}
+ if(mImpl->mActiveSet.empty())
+ {
+ return max_time;
+ }
+ static LLVOCacheEntry* last_visited_entry = NULL;
+
+ const size_t MAX_UPDATE = 32;
std::vector<LLDrawable*> delete_list;
- for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin();
- iter != mImpl->mActiveSet.end(); ++iter)
- {
+ S32 update_counter = llmin(MAX_UPDATE, mImpl->mActiveSet.size());
+ LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.upper_bound(last_visited_entry);
+
+ for(; update_counter > 0; --update_counter, ++iter)
+ {
+ if(iter == mImpl->mActiveSet.end())
+ {
+ iter = mImpl->mActiveSet.begin();
+ }
+
if(!(*iter)->isRecentlyVisible())
{
killObject((*iter), delete_list);
}
}
+
+ if(iter == mImpl->mActiveSet.end())
+ {
+ last_visited_entry = NULL;
+ }
+ else
+ {
+ last_visited_entry = *iter;
+ }
+
for(S32 i = 0; i < delete_list.size(); i++)
{
gObjectList.killObject(delete_list[i]->getVObj());