diff options
Diffstat (limited to 'indra/newview/llviewerobjectlist.cpp')
-rw-r--r-- | indra/newview/llviewerobjectlist.cpp | 97 |
1 files changed, 18 insertions, 79 deletions
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index ea20950b36..28298cedf9 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -914,30 +914,21 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) LLViewerObject *objectp = NULL; // Make a copy of the list in case something in idleUpdate() messes with it - static std::vector<LLViewerObject*> idle_list; - - U32 idle_count = 0; - + std::vector<LLViewerObject*> idle_list; + static LLFastTimer::DeclareTimer idle_copy("Idle Copy"); { LLFastTimer t(idle_copy); - - for (std::vector<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin(); + idle_list.reserve( mActiveObjects.size() ); + + for (std::set<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin(); active_iter != mActiveObjects.end(); active_iter++) { objectp = *active_iter; if (objectp) { - if (idle_count >= idle_list.size()) - { - idle_list.push_back( objectp ); - } - else - { - idle_list[idle_count] = objectp; - } - ++idle_count; + idle_list.push_back( objectp ); } else { // There shouldn't be any NULL pointers in the list, but they have caused @@ -947,13 +938,10 @@ 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_end; iter++) + iter != idle_list.end(); iter++) { objectp = *iter; if (objectp->isAvatar()) @@ -965,17 +953,17 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) else { for (std::vector<LLViewerObject*>::iterator idle_iter = idle_list.begin(); - idle_iter != idle_end; idle_iter++) + idle_iter != idle_list.end(); idle_iter++) { objectp = *idle_iter; - if (objectp->idleUpdate(agent, world, frame_time)) + if (!objectp->idleUpdate(agent, world, frame_time)) { - num_active_objects++; + // If Idle Update returns false, kill object! + kill_list.push_back(objectp); } else { - // If Idle Update returns false, kill object! - kill_list.push_back(objectp); + num_active_objects++; } } for (std::vector<LLViewerObject*>::iterator kill_iter = kill_list.begin(); @@ -1213,7 +1201,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp) { //llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list in cleanupReferences." << llendl; objectp->setOnActiveList(FALSE); - removeFromActiveList(objectp); + mActiveObjects.erase(objectp); } if (objectp->isOnMap()) @@ -1390,26 +1378,6 @@ 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); @@ -1424,29 +1392,13 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp) if (active) { //llinfos << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << llendl; - 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; - } - } + mActiveObjects.insert(objectp); + objectp->setOnActiveList(TRUE); } else { //llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list." << llendl; - removeFromActiveList(objectp); + mActiveObjects.erase(objectp); objectp->setOnActiveList(FALSE); } } @@ -1520,10 +1472,6 @@ 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) { // This is called when we shift our origin when we cross region boundaries... @@ -1535,8 +1483,6 @@ 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) { @@ -1553,15 +1499,8 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset) } } - { - LLFastTimer t(FTM_PIPELINE_SHIFT); - gPipeline.shiftObjects(offset); - } - - { - LLFastTimer t(FTM_REGION_SHIFT); - LLWorld::getInstance()->shiftRegions(offset); - } + gPipeline.shiftObjects(offset); + LLWorld::getInstance()->shiftRegions(offset); } void LLViewerObjectList::repartitionObjects() |