summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2012-06-11 12:53:36 -0500
committerDave Parks <davep@lindenlab.com>2012-06-11 12:53:36 -0500
commit184d5ee79d4f4b56cd042ded16c6546fa46de611 (patch)
treeb5ef5c1940e8bd590d5d336943265061ec050321 /indra/newview
parent0e0e3a4929b1238488702327d36135b4f6737365 (diff)
MAINT-646 Get rid of a hotspot in LLViewerObjectList::update, fix for error in llpolymorph
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llpolymorph.cpp2
-rw-r--r--indra/newview/llviewerobject.cpp9
-rw-r--r--indra/newview/llviewerobject.h5
-rw-r--r--indra/newview/llviewerobjectlist.cpp66
-rw-r--r--indra/newview/llviewerobjectlist.h4
5 files changed, 66 insertions, 20 deletions
diff --git a/indra/newview/llpolymorph.cpp b/indra/newview/llpolymorph.cpp
index 69109a9ab1..d25d1420ee 100644
--- a/indra/newview/llpolymorph.cpp
+++ b/indra/newview/llpolymorph.cpp
@@ -647,7 +647,7 @@ void LLPolyMorphTarget::applyMask(U8 *maskTextureData, S32 width, S32 height, S3
LLVector4a* clothing_weight = &clothing_weights[out_vert];
LLVector4a t;
t.setSub(*clothing_weight, clothing_offset);
- clothing_weight->setSelectWithMask(clothing_mask, clothing_offset, *clothing_weight);
+ clothing_weight->setSelectWithMask(clothing_mask, t, *clothing_weight);
}
}
}
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 2dbfb4e2ce..d6c407ef91 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -199,6 +199,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
mID(id),
mLocalID(0),
mTotalCRC(0),
+ mListIndex(-1),
mTEImages(NULL),
mGLName(0),
mbCanSelect(TRUE),
@@ -4801,9 +4802,11 @@ void LLViewerObject::deleteParticleSource()
// virtual
void LLViewerObject::updateDrawable(BOOL force_damped)
{
- if (mDrawable.notNull() &&
- !mDrawable->isState(LLDrawable::ON_MOVE_LIST) &&
- isChanged(MOVED))
+ if (!isChanged(MOVED))
+ { //most common case, having an empty if case here makes for better branch prediction
+ }
+ else if (mDrawable.notNull() &&
+ !mDrawable->isState(LLDrawable::ON_MOVE_LIST))
{
BOOL damped_motion =
!isChanged(SHIFTED) && // not shifted between regions this frame and...
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index dc102b666f..30c3d03635 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -229,6 +229,8 @@ public:
const LLUUID &getID() const { return mID; }
U32 getLocalID() const { return mLocalID; }
U32 getCRC() const { return mTotalCRC; }
+ S32 getListIndex() const { return mListIndex; }
+ void setListIndex(S32 idx) { mListIndex = idx; }
virtual BOOL isFlexible() const { return FALSE; }
virtual BOOL isSculpted() const { return FALSE; }
@@ -589,6 +591,9 @@ public:
// Last total CRC received from sim, used for caching
U32 mTotalCRC;
+ // index into LLViewerObjectList::mActiveObjects or -1 if not in list
+ S32 mListIndex;
+
LLPointer<LLViewerTexture> *mTEImages;
// Selection, picking and rendering variables
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index c8ba2b6f58..4a06685994 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -928,21 +928,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
@@ -952,10 +961,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())
@@ -967,17 +979,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();
@@ -1215,7 +1227,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())
@@ -1392,6 +1404,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);
@@ -1406,13 +1438,17 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp)
if (active)
{
//llinfos << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << llendl;
- mActiveObjects.insert(objectp);
+ llassert(objectp->getListIndex() == -1);
+
+ mActiveObjects.push_back(objectp);
+ objectp->setListIndex(mActiveObjects.size()-1);
+
objectp->setOnActiveList(TRUE);
}
else
{
//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list." << llendl;
- mActiveObjects.erase(objectp);
+ removeFromActiveList(objectp);
objectp->setOnActiveList(FALSE);
}
}
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index c5f2a2c1ee..336fc3cf20 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -118,7 +118,9 @@ public:
void dirtyAllObjectInventory();
+ void removeFromActiveList(LLViewerObject* objectp);
void updateActive(LLViewerObject *objectp);
+
void updateAvatarVisibility();
// Selection related stuff
@@ -195,7 +197,7 @@ protected:
typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
vobj_list_t mObjects;
- std::set<LLPointer<LLViewerObject> > mActiveObjects;
+ std::vector<LLPointer<LLViewerObject> > mActiveObjects;
vobj_list_t mMapObjects;