summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerobjectlist.cpp
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2012-07-17 16:52:19 +0000
committerDon Kjer <don@lindenlab.com>2012-07-17 16:52:19 +0000
commitcff3469d46d297fbec34bc0d648588e900cd255c (patch)
treed768ddbc8712c9e81387ae4b03dd8227229a0fe1 /indra/newview/llviewerobjectlist.cpp
parent5a473a42a63d3277c65bb3bc96e49f020508cfe8 (diff)
parent509408f393b8eb58799678adde801675a4d4d600 (diff)
Merge viewer-development -> viewer-horde-fixes
Diffstat (limited to 'indra/newview/llviewerobjectlist.cpp')
-rw-r--r--indra/newview/llviewerobjectlist.cpp97
1 files changed, 79 insertions, 18 deletions
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index e4ce670a43..8de839e092 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -931,21 +931,30 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
LLViewerObject *objectp = NULL;
// Make a copy of the list in case something in idleUpdate() messes with it
- std::vector<LLViewerObject*> idle_list;
-
+ static std::vector<LLViewerObject*> idle_list;
+
+ U32 idle_count = 0;
+
static LLFastTimer::DeclareTimer idle_copy("Idle Copy");
{
LLFastTimer t(idle_copy);
- idle_list.reserve( mActiveObjects.size() );
-
- for (std::set<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
+
+ for (std::vector<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
active_iter != mActiveObjects.end(); active_iter++)
{
objectp = *active_iter;
if (objectp)
{
- idle_list.push_back( objectp );
+ if (idle_count >= idle_list.size())
+ {
+ idle_list.push_back( objectp );
+ }
+ else
+ {
+ idle_list[idle_count] = objectp;
+ }
+ ++idle_count;
}
else
{ // There shouldn't be any NULL pointers in the list, but they have caused
@@ -955,10 +964,13 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
}
}
+ std::vector<LLViewerObject*>::iterator idle_end = idle_list.begin()+idle_count;
+
if (gSavedSettings.getBOOL("FreezeTime"))
{
+
for (std::vector<LLViewerObject*>::iterator iter = idle_list.begin();
- iter != idle_list.end(); iter++)
+ iter != idle_end; iter++)
{
objectp = *iter;
if (objectp->isAvatar())
@@ -970,17 +982,17 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
else
{
for (std::vector<LLViewerObject*>::iterator idle_iter = idle_list.begin();
- idle_iter != idle_list.end(); idle_iter++)
+ idle_iter != idle_end; idle_iter++)
{
objectp = *idle_iter;
- if (!objectp->idleUpdate(agent, world, frame_time))
+ if (objectp->idleUpdate(agent, world, frame_time))
{
- // If Idle Update returns false, kill object!
- kill_list.push_back(objectp);
+ num_active_objects++;
}
else
{
- num_active_objects++;
+ // If Idle Update returns false, kill object!
+ kill_list.push_back(objectp);
}
}
for (std::vector<LLViewerObject*>::iterator kill_iter = kill_list.begin();
@@ -1218,7 +1230,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
{
//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list in cleanupReferences." << llendl;
objectp->setOnActiveList(FALSE);
- mActiveObjects.erase(objectp);
+ removeFromActiveList(objectp);
}
if (objectp->isOnMap())
@@ -1395,6 +1407,26 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer)
mNumDeadObjects = 0;
}
+void LLViewerObjectList::removeFromActiveList(LLViewerObject* objectp)
+{
+ S32 idx = objectp->getListIndex();
+ if (idx != -1)
+ { //remove by moving last element to this object's position
+ llassert(mActiveObjects[idx] == objectp);
+
+ objectp->setListIndex(-1);
+
+ S32 last_index = mActiveObjects.size()-1;
+
+ if (idx != last_index)
+ {
+ mActiveObjects[idx] = mActiveObjects[last_index];
+ mActiveObjects[idx]->setListIndex(idx);
+ mActiveObjects.pop_back();
+ }
+ }
+}
+
void LLViewerObjectList::updateActive(LLViewerObject *objectp)
{
LLMemType mt(LLMemType::MTYPE_OBJECT);
@@ -1409,13 +1441,29 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp)
if (active)
{
//llinfos << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << llendl;
- mActiveObjects.insert(objectp);
- objectp->setOnActiveList(TRUE);
+ S32 idx = objectp->getListIndex();
+ if (idx <= -1)
+ {
+ mActiveObjects.push_back(objectp);
+ objectp->setListIndex(mActiveObjects.size()-1);
+ objectp->setOnActiveList(TRUE);
+ }
+ else
+ {
+ llassert(idx < mActiveObjects.size());
+ llassert(mActiveObjects[idx] == objectp);
+
+ if (idx >= mActiveObjects.size() ||
+ mActiveObjects[idx] != objectp)
+ {
+ llwarns << "Invalid object list index detected!" << llendl;
+ }
+ }
}
else
{
//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list." << llendl;
- mActiveObjects.erase(objectp);
+ removeFromActiveList(objectp);
objectp->setOnActiveList(FALSE);
}
}
@@ -1489,6 +1537,10 @@ void LLViewerObjectList::onPhysicsFlagsFetchFailure(const LLUUID& object_id)
mPendingPhysicsFlags.erase(object_id);
}
+static LLFastTimer::DeclareTimer FTM_SHIFT_OBJECTS("Shift Objects");
+static LLFastTimer::DeclareTimer FTM_PIPELINE_SHIFT("Pipeline Shift");
+static LLFastTimer::DeclareTimer FTM_REGION_SHIFT("Region Shift");
+
void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
{
if (gHeadlessClient) return;
@@ -1501,6 +1553,8 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
return;
}
+ LLFastTimer t(FTM_SHIFT_OBJECTS);
+
LLViewerObject *objectp;
for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
{
@@ -1517,8 +1571,15 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
}
}
- gPipeline.shiftObjects(offset);
- LLWorld::getInstance()->shiftRegions(offset);
+ {
+ LLFastTimer t(FTM_PIPELINE_SHIFT);
+ gPipeline.shiftObjects(offset);
+ }
+
+ {
+ LLFastTimer t(FTM_REGION_SHIFT);
+ LLWorld::getInstance()->shiftRegions(offset);
+ }
}
void LLViewerObjectList::repartitionObjects()