summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2012-06-04 11:29:00 -0500
committerDave Parks <davep@lindenlab.com>2012-06-04 11:29:00 -0500
commita78fc68a21d01e54203dd737fece9b47f249ec4c (patch)
tree410dd7c888276cafecde0f05a3b1fba4583bb663 /indra/newview
parentae15778eebafa6c8f69cedd51fe5fe1a5f7b543b (diff)
MAINT-646 Profile based optimization -- add a lookup map for joints to remove hotspot in LLJoint::findJoint
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llvoavatar.cpp17
-rw-r--r--indra/newview/llvoavatar.h4
2 files changed, 20 insertions, 1 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index cdcf2063c3..414ddc0c24 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -803,6 +803,7 @@ LLVOAvatar::~LLVOAvatar()
lldebugs << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << llendl;
mRoot.removeAllChildren();
+ mJointMap.clear();
deleteAndClearArray(mSkeleton);
deleteAndClearArray(mCollisionVolumes);
@@ -1844,6 +1845,7 @@ void LLVOAvatar::buildCharacter()
// remove all of mRoot's children
//-------------------------------------------------------------------------
mRoot.removeAllChildren();
+ mJointMap.clear();
mIsBuilt = FALSE;
//-------------------------------------------------------------------------
@@ -5060,7 +5062,20 @@ const LLUUID& LLVOAvatar::getID() const
// RN: avatar joints are multi-rooted to include screen-based attachments
LLJoint *LLVOAvatar::getJoint( const std::string &name )
{
- LLJoint* jointp = mRoot.findJoint(name);
+ joint_map_t::iterator iter = mJointMap.find(name);
+
+ LLJoint* jointp = NULL;
+
+ if (iter == mJointMap.end())
+ { //search for joint and cache found joint in lookup table
+ LLJoint* jointp = mRoot.findJoint(name);
+ mJointMap[name] = jointp;
+ }
+ else
+ { //return cached pointer
+ jointp = iter->second;
+ }
+
return jointp;
}
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 6a4e09593c..d106086c88 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -320,6 +320,10 @@ public:
LLVector3 mHeadOffset; // current head position
LLViewerJoint mRoot;
+
+ typedef std::map<std::string, LLJoint*> joint_map_t;
+ joint_map_t mJointMap;
+
protected:
static BOOL parseSkeletonFile(const std::string& filename);
void buildCharacter();