summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerobjectlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerobjectlist.cpp')
-rw-r--r--indra/newview/llviewerobjectlist.cpp156
1 files changed, 109 insertions, 47 deletions
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 54ccfb9aae..37a9675278 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -49,6 +49,8 @@
#include "llstring.h"
#include "llhudnametag.h"
#include "lldrawable.h"
+#include "llflexibleobject.h"
+#include "llviewertextureanim.h"
#include "xform.h"
#include "llsky.h"
#include "llviewercamera.h"
@@ -78,11 +80,9 @@
extern F32 gMinObjectDistance;
extern BOOL gAnimateTextures;
-void dialog_refresh_all();
+#define MAX_CONCURRENT_PHYSICS_REQUESTS 256
-#define CULL_VIS
-//#define ORPHAN_SPAM
-//#define IGNORE_DEAD
+void dialog_refresh_all();
// Global lists of objects - should go away soon.
LLViewerObjectList gObjectList;
@@ -926,26 +926,35 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
const F64 frame_time = LLFrameTimer::getElapsedSeconds();
- std::vector<LLViewerObject*> kill_list;
- S32 num_active_objects = 0;
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 );
+ llassert(objectp->isActive());
+
+ 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,12 @@ 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,27 +981,22 @@ 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 Idle Update returns false, kill object!
- kill_list.push_back(objectp);
- }
- else
- {
- num_active_objects++;
- }
- }
- for (std::vector<LLViewerObject*>::iterator kill_iter = kill_list.begin();
- kill_iter != kill_list.end(); kill_iter++)
- {
- objectp = *kill_iter;
- killObject(objectp);
+ llassert(objectp->isActive());
+ objectp->idleUpdate(agent, world, frame_time);
}
+
+ //update flexible objects
+ LLVolumeImplFlexible::updateClass();
+
+ //update animated textures
+ LLViewerTextureAnim::updateClass();
}
+
+
fetchObjectCosts();
fetchPhysicsFlags();
@@ -1057,7 +1063,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
*/
LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size());
- LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(num_active_objects);
+ LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(idle_count);
LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled);
LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled);
}
@@ -1078,8 +1084,6 @@ void LLViewerObjectList::fetchObjectCosts()
LLSD id_list;
U32 object_index = 0;
- U32 count = 0;
-
for (
std::set<LLUUID>::iterator iter = mStaleObjectCost.begin();
iter != mStaleObjectCost.end();
@@ -1096,7 +1100,7 @@ void LLViewerObjectList::fetchObjectCosts()
mStaleObjectCost.erase(iter++);
- if (count++ >= 450)
+ if (object_index >= MAX_CONCURRENT_PHYSICS_REQUESTS)
{
break;
}
@@ -1141,7 +1145,7 @@ void LLViewerObjectList::fetchPhysicsFlags()
for (
std::set<LLUUID>::iterator iter = mStalePhysicsFlags.begin();
iter != mStalePhysicsFlags.end();
- ++iter)
+ )
{
// Check to see if a request for this object
// has already been made.
@@ -1151,12 +1155,14 @@ void LLViewerObjectList::fetchPhysicsFlags()
mPendingPhysicsFlags.insert(*iter);
id_list[object_index++] = *iter;
}
- }
- // id_list should now contain all
- // requests in mStalePhysicsFlags before, so clear
- // it now
- mStalePhysicsFlags.clear();
+ mStalePhysicsFlags.erase(iter++);
+
+ if (object_index >= MAX_CONCURRENT_PHYSICS_REQUESTS)
+ {
+ break;
+ }
+ }
if ( id_list.size() > 0 )
{
@@ -1218,7 +1224,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 +1401,27 @@ 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,16 +1436,35 @@ 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);
}
}
+
+ llassert(objectp->isActive() || objectp->getListIndex() == -1);
+
}
void LLViewerObjectList::updateObjectCost(LLViewerObject* object)
@@ -1489,6 +1535,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)
{
// This is called when we shift our origin when we cross region boundaries...
@@ -1500,6 +1550,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)
{
@@ -1516,8 +1568,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()
@@ -1721,7 +1780,10 @@ void LLViewerObjectList::generatePickList(LLCamera &camera)
LLViewerObject* last_objectp = NULL;
for (S32 face_num = 0; face_num < drawablep->getNumFaces(); face_num++)
{
- LLViewerObject* objectp = drawablep->getFace(face_num)->getViewerObject();
+ LLFace * facep = drawablep->getFace(face_num);
+ if (!facep) continue;
+
+ LLViewerObject* objectp = facep->getViewerObject();
if (objectp && objectp != last_objectp)
{