Attempt to speed up agent idle update by optimizing wearable/visualparam related lookups/iterations a bit more.
Generalized several templates in llstl.h in order to support more containers. Removed several instances of is_in_map/getWearableCount being followed immediately by another lookup with the same key. find is more efficient, as we get an iterator to use instead of a simple boolean.
This commit is contained in:
@@ -1495,7 +1495,7 @@ void LLAgentCamera::updateCamera()
|
||||
|
||||
gAgentAvatarp->mRoot->updateWorldMatrixChildren();
|
||||
|
||||
for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin();
|
||||
/*for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); //Can be an array.
|
||||
iter != gAgentAvatarp->mAttachmentPoints.end(); )
|
||||
{
|
||||
LLVOAvatar::attachment_map_t::iterator curiter = iter++;
|
||||
@@ -1504,7 +1504,11 @@ void LLAgentCamera::updateCamera()
|
||||
attachment_iter != attachment->mAttachedObjects.end();
|
||||
++attachment_iter)
|
||||
{
|
||||
LLViewerObject *attached_object = (*attachment_iter);
|
||||
LLViewerObject *attached_object = (*attachment_iter);*/
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator attachment_iter = gAgentAvatarp->mAttachedObjectsVector.begin();
|
||||
for(;attachment_iter!=gAgentAvatarp->mAttachedObjectsVector.end();++attachment_iter)
|
||||
{{
|
||||
LLViewerObject* attached_object = attachment_iter->first;
|
||||
if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull())
|
||||
{
|
||||
// clear any existing "early" movements of attachment
|
||||
|
||||
@@ -1063,13 +1063,14 @@ void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id)
|
||||
return;
|
||||
}
|
||||
|
||||
if((object_id == cat_id) || !is_in_map(mCategoryMap, cat_id))
|
||||
cat_map_t::iterator it;
|
||||
if((object_id == cat_id) || (it = mCategoryMap.find(cat_id))==mCategoryMap.end())
|
||||
{
|
||||
llwarns << "Could not move inventory object " << object_id << " to "
|
||||
<< cat_id << llendl;
|
||||
return;
|
||||
}
|
||||
LLViewerInventoryCategory* cat = getCategory(object_id);
|
||||
LLViewerInventoryCategory* cat = it->second;
|
||||
if(cat && (cat->getParentUUID() != cat_id))
|
||||
{
|
||||
cat_array_t* cat_array;
|
||||
|
||||
@@ -1006,6 +1006,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
|
||||
mCCSChatTextOverride(false)
|
||||
// </edit>
|
||||
{
|
||||
mAttachedObjectsVector.reserve(MAX_AGENT_ATTACHMENTS);
|
||||
|
||||
static LLCachedControl<bool> const freeze_time("FreezeTime", false);
|
||||
mFreezeTimeLangolier = freeze_time;
|
||||
|
||||
@@ -1115,7 +1117,7 @@ LLVOAvatar::~LLVOAvatar()
|
||||
lldebugs << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << llendl;
|
||||
|
||||
std::for_each(mAttachmentPoints.begin(), mAttachmentPoints.end(), DeletePairedPointer());
|
||||
mAttachmentPoints.clear();
|
||||
//mAttachmentPoints.clear();
|
||||
|
||||
mDead = TRUE;
|
||||
|
||||
@@ -1645,7 +1647,7 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
|
||||
mPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance());
|
||||
|
||||
//stretch bounding box by attachments
|
||||
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
|
||||
/*for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
|
||||
iter != mAttachmentPoints.end();
|
||||
++iter)
|
||||
{
|
||||
@@ -1660,7 +1662,13 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
|
||||
attachment_iter != attachment->mAttachedObjects.end();
|
||||
++attachment_iter)
|
||||
{
|
||||
const LLViewerObject* attached_object = (*attachment_iter);
|
||||
const LLViewerObject* attached_object = (*attachment_iter);*/
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator attachment_iter = mAttachedObjectsVector.begin();
|
||||
for(;attachment_iter!=mAttachedObjectsVector.end();++attachment_iter)
|
||||
{
|
||||
if(attachment_iter->second->getValid())
|
||||
{
|
||||
const LLViewerObject* attached_object = attachment_iter->first;
|
||||
if (attached_object && !attached_object->isHUDAttachment())
|
||||
{
|
||||
LLDrawable* drawable = attached_object->mDrawable;
|
||||
@@ -2494,7 +2502,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
|
||||
if (detailed_update || !sUseImpostors)
|
||||
{
|
||||
LLFastTimer t(FTM_ATTACHMENT_UPDATE);
|
||||
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
|
||||
/*for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
|
||||
iter != mAttachmentPoints.end();
|
||||
++iter)
|
||||
{
|
||||
@@ -2504,7 +2512,12 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
|
||||
attachment_iter != attachment->mAttachedObjects.end();
|
||||
++attachment_iter)
|
||||
{
|
||||
LLViewerObject* attached_object = (*attachment_iter);
|
||||
LLViewerObject* attached_object = (*attachment_iter);*/
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator attachment_iter = mAttachedObjectsVector.begin();
|
||||
for(;attachment_iter!=mAttachedObjectsVector.end();++attachment_iter)
|
||||
{{
|
||||
LLViewerJointAttachment* attachment = attachment_iter->second;
|
||||
LLViewerObject* attached_object = attachment_iter->first;
|
||||
BOOL visibleAttachment = visible || (attached_object &&
|
||||
!(attached_object->mDrawable->getSpatialBridge() &&
|
||||
attached_object->mDrawable->getSpatialBridge()->getRadius() < 2.0));
|
||||
@@ -2964,7 +2977,7 @@ void LLVOAvatar::idleCCSUpdateAttachmentText(bool render_name)
|
||||
if(!mCCSUpdateAttachmentTimer.checkExpirationAndReset(SECS_BETWEEN_UPDATES))
|
||||
return;
|
||||
|
||||
for (attachment_map_t::iterator it=mAttachmentPoints.begin(); it!=mAttachmentPoints.end(); ++it)
|
||||
/*for (attachment_map_t::iterator it=mAttachmentPoints.begin(); it!=mAttachmentPoints.end(); ++it)
|
||||
{
|
||||
// get attached object
|
||||
LLViewerJointAttachment *joint = it->second;
|
||||
@@ -2973,8 +2986,14 @@ void LLVOAvatar::idleCCSUpdateAttachmentText(bool render_name)
|
||||
for(std::vector<LLViewerObject *>::const_iterator parent_it = joint->mAttachedObjects.begin();
|
||||
parent_it != joint->mAttachedObjects.end(); ++parent_it)
|
||||
{
|
||||
LLViewerObject* pObject = (*parent_it);
|
||||
const LLTextureEntry *te = pObject ? pObject->getTE(0) : NULL;
|
||||
LLViewerObject* pObject = (*parent_it);*/
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator parent_it = mAttachedObjectsVector.begin();
|
||||
for(;parent_it!=mAttachedObjectsVector.end();++parent_it)
|
||||
{{
|
||||
LLViewerObject* pObject = parent_it->first;
|
||||
if(!pObject)
|
||||
continue;
|
||||
const LLTextureEntry *te = pObject->getTE(0);
|
||||
if(!te) continue;
|
||||
const LLColor4 &col = te->getColor();
|
||||
if( (fabs(col[0] - 0.012f) < 0.001f) &&
|
||||
@@ -6228,6 +6247,8 @@ const LLViewerJointAttachment *LLVOAvatar::attachObject(LLViewerObject *viewer_o
|
||||
LLSelectMgr::getInstance()->updatePointAt();
|
||||
}
|
||||
|
||||
mAttachedObjectsVector.push_back(std::make_pair(viewer_object,attachment));
|
||||
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@@ -6382,6 +6403,13 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
|
||||
{
|
||||
cleanupAttachedMesh( viewer_object );
|
||||
attachment->removeObject(viewer_object);
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator it = std::find(mAttachedObjectsVector.begin(),mAttachedObjectsVector.end(),std::make_pair(viewer_object,attachment));
|
||||
if(it != mAttachedObjectsVector.end())
|
||||
{
|
||||
(*it) = mAttachedObjectsVector.back();
|
||||
mAttachedObjectsVector.pop_back();
|
||||
}
|
||||
|
||||
lldebugs << "Detaching object " << viewer_object->mID << " from " << attachment->getName() << llendl;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -8755,7 +8783,7 @@ void LLVOAvatar::idleUpdateRenderCost()
|
||||
|
||||
std::set<LLUUID> textures;
|
||||
|
||||
attachment_map_t::const_iterator iter;
|
||||
/*attachment_map_t::const_iterator iter;
|
||||
for (iter = mAttachmentPoints.begin();
|
||||
iter != mAttachmentPoints.end();
|
||||
++iter)
|
||||
@@ -8765,7 +8793,11 @@ void LLVOAvatar::idleUpdateRenderCost()
|
||||
attachment_iter != attachment->mAttachedObjects.end();
|
||||
++attachment_iter)
|
||||
{
|
||||
const LLViewerObject* object = (*attachment_iter);
|
||||
const LLViewerObject* object = (*attachment_iter);*/
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator attachment_iter = mAttachedObjectsVector.begin();
|
||||
for(;attachment_iter!=mAttachedObjectsVector.end();++attachment_iter)
|
||||
{{
|
||||
const LLViewerObject* object = attachment_iter->first;
|
||||
if (object && !object->isHUDAttachment())
|
||||
{
|
||||
LLDrawable* drawable = object->mDrawable;
|
||||
@@ -8817,7 +8849,7 @@ void LLVOAvatar::idleUpdateRenderCost()
|
||||
}
|
||||
|
||||
|
||||
for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
|
||||
/*for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
|
||||
iter != mAttachmentPoints.end();
|
||||
++iter)
|
||||
{
|
||||
@@ -8826,7 +8858,11 @@ void LLVOAvatar::idleUpdateRenderCost()
|
||||
attachment_iter != attachment->mAttachedObjects.end();
|
||||
++attachment_iter)
|
||||
{
|
||||
const LLViewerObject* attached_object = (*attachment_iter);
|
||||
const LLViewerObject* attached_object = (*attachment_iter);*/
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator attachment_iter = mAttachedObjectsVector.begin();
|
||||
for(;attachment_iter!=mAttachedObjectsVector.end();++attachment_iter)
|
||||
{{
|
||||
const LLViewerObject* attached_object = attachment_iter->first;
|
||||
if (attached_object && !attached_object->isHUDAttachment())
|
||||
{
|
||||
textures.clear();
|
||||
|
||||
@@ -745,9 +745,11 @@ protected:
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
S32 getAttachmentCount(); // Warning: order(N) not order(1) // currently used only by -self
|
||||
typedef std::map<S32, LLViewerJointAttachment*> attachment_map_t;
|
||||
//typedef std::map<S32, LLViewerJointAttachment*> attachment_map_t;
|
||||
typedef LLSortedVector<S32, LLViewerJointAttachment*> attachment_map_t;
|
||||
attachment_map_t mAttachmentPoints;
|
||||
std::vector<LLPointer<LLViewerObject> > mPendingAttachment;
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> > mAttachedObjectsVector; //A vector of all current attachments for fast iteration.
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// HUD functions
|
||||
|
||||
@@ -9616,7 +9616,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
|
||||
markVisible(avatar->mDrawable, *viewer_camera);
|
||||
LLVOAvatar::sUseImpostors = FALSE;
|
||||
|
||||
LLVOAvatar::attachment_map_t::iterator iter;
|
||||
/*LLVOAvatar::attachment_map_t::iterator iter;
|
||||
for (iter = avatar->mAttachmentPoints.begin();
|
||||
iter != avatar->mAttachmentPoints.end();
|
||||
++iter)
|
||||
@@ -9626,7 +9626,12 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
|
||||
attachment_iter != attachment->mAttachedObjects.end();
|
||||
++attachment_iter)
|
||||
{
|
||||
if (LLViewerObject* attached_object = (*attachment_iter))
|
||||
if (LLViewerObject* attached_object = (*attachment_iter))*/
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator attachment_iter = avatar->mAttachedObjectsVector.begin();
|
||||
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator end = avatar->mAttachedObjectsVector.end();
|
||||
for(;attachment_iter != end;++attachment_iter)
|
||||
{{
|
||||
if (LLViewerObject* attached_object = attachment_iter->first)
|
||||
{
|
||||
markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user