From 76128c4357bc36acd54575153516c6d337fe4263 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Mon, 5 Aug 2019 12:04:29 -0700
Subject: SL-10566 Use vector for some high-traffic, low-item count containers
 instead of list.

Provide method of storing joint indices sep from weight data for faster runtime processing.
---
 indra/llcharacter/llcharacter.cpp      |  2 +-
 indra/llcharacter/lljoint.cpp          | 14 +++++++-------
 indra/llcharacter/lljoint.h            |  4 ++--
 indra/llcharacter/llkeyframemotion.cpp |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

(limited to 'indra/llcharacter')

diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp
index 4df975ecc5..b764ef0c7e 100644
--- a/indra/llcharacter/llcharacter.cpp
+++ b/indra/llcharacter/llcharacter.cpp
@@ -252,7 +252,7 @@ void LLCharacter::dumpCharacter( LLJoint* joint )
 	LL_INFOS() << "DEBUG: " << joint->getName() << " (" << (joint->getParent()?joint->getParent()->getName():std::string("ROOT")) << ")" << LL_ENDL;
 
 	// recurse
-	for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin();
+	for (LLJoint::joints_t::iterator iter = joint->mChildren.begin();
 		 iter != joint->mChildren.end(); ++iter)
 	{
 		LLJoint* child_joint = *iter;
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index e2f512f86e..36ecf8cb4b 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -209,7 +209,7 @@ void LLJoint::touch(U32 flags)
 			child_flags |= POSITION_DIRTY;
 		}
 
-		for (child_list_t::iterator iter = mChildren.begin();
+		for (joints_t::iterator iter = mChildren.begin();
 			 iter != mChildren.end(); ++iter)
 		{
 			LLJoint* joint = *iter;
@@ -251,7 +251,7 @@ LLJoint *LLJoint::findJoint( const std::string &name )
 	if (name == getName())
 		return this;
 
-	for (child_list_t::iterator iter = mChildren.begin();
+	for (joints_t::iterator iter = mChildren.begin();
 		 iter != mChildren.end(); ++iter)
 	{
 		LLJoint* joint = *iter;
@@ -286,7 +286,7 @@ void LLJoint::addChild(LLJoint* joint)
 //--------------------------------------------------------------------
 void LLJoint::removeChild(LLJoint* joint)
 {
-	child_list_t::iterator iter = std::find(mChildren.begin(), mChildren.end(), joint);
+	joints_t::iterator iter = std::find(mChildren.begin(), mChildren.end(), joint);
 	if (iter != mChildren.end())
 	{
 		mChildren.erase(iter);
@@ -303,10 +303,10 @@ void LLJoint::removeChild(LLJoint* joint)
 //--------------------------------------------------------------------
 void LLJoint::removeAllChildren()
 {
-	for (child_list_t::iterator iter = mChildren.begin();
+	for (joints_t::iterator iter = mChildren.begin();
 		 iter != mChildren.end();)
 	{
-		child_list_t::iterator curiter = iter++;
+		joints_t::iterator curiter = iter++;
 		LLJoint* joint = *curiter;
 		mChildren.erase(curiter);
 		joint->mXform.setParent(NULL);
@@ -985,7 +985,7 @@ void LLJoint::updateWorldMatrixChildren()
 	{
 		updateWorldMatrix();
 	}
-	for (child_list_t::iterator iter = mChildren.begin();
+	for (joints_t::iterator iter = mChildren.begin();
 		 iter != mChildren.end(); ++iter)
 	{
 		LLJoint* joint = *iter;
@@ -1031,7 +1031,7 @@ void LLJoint::clampRotation(LLQuaternion old_rot, LLQuaternion new_rot)
 {
 	LLVector3 main_axis(1.f, 0.f, 0.f);
 
-	for (child_list_t::iterator iter = mChildren.begin();
+	for (joints_t::iterator iter = mChildren.begin();
 		 iter != mChildren.end(); ++iter)
 	{
 		LLJoint* joint = *iter;
diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h
index 8112d246f2..aa997a4cf7 100644
--- a/indra/llcharacter/lljoint.h
+++ b/indra/llcharacter/lljoint.h
@@ -139,8 +139,8 @@ public:
 	S32				mJointNum;
 
 	// child joints
-	typedef std::list<LLJoint*> child_list_t;
-	child_list_t mChildren;
+	typedef std::vector<LLJoint*> joints_t;
+	joints_t mChildren;
 
 	// debug statics
 	static S32		sNumTouches;
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index 5d323ed5d6..cde38c8091 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -2321,7 +2321,7 @@ void LLKeyframeMotion::onLoadComplete(LLVFS *vfs,
 	LLCharacter* character = *char_iter;
 
 	// look for an existing instance of this motion
-	LLKeyframeMotion* motionp = dynamic_cast<LLKeyframeMotion*> (character->findMotion(asset_uuid));
+	LLKeyframeMotion* motionp = static_cast<LLKeyframeMotion*> (character->findMotion(asset_uuid));
 	if (motionp)
 	{
 		if (0 == status)
-- 
cgit v1.2.3


From 71af0a2a9e9f90d1e336f8a30f642bb5e19ef658 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Tue, 6 Aug 2019 14:41:55 -0700
Subject: Fix shutdown crash in teardown of joint heirarchy.

Ifdef'd code for potential skinning speed up to avoid lots of int<->float conversions (expensive and static for min space investment)
as updating rigged VBs shows up as a profiling bottleneck for Low rendering (where we actually use CPU skinning).
---
 indra/llcharacter/lljoint.cpp | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

(limited to 'indra/llcharacter')

diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index 36ecf8cb4b..a685df5925 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -303,16 +303,17 @@ void LLJoint::removeChild(LLJoint* joint)
 //--------------------------------------------------------------------
 void LLJoint::removeAllChildren()
 {
-	for (joints_t::iterator iter = mChildren.begin();
-		 iter != mChildren.end();)
+	for (LLJoint* joint : mChildren)
 	{
-		joints_t::iterator curiter = iter++;
-		LLJoint* joint = *curiter;
-		mChildren.erase(curiter);
-		joint->mXform.setParent(NULL);
-		joint->mParent = NULL;
-		joint->touch();
+		if (joint)
+        {
+		    joint->mXform.setParent(NULL);
+		    joint->mParent = NULL;
+		    joint->touch();
+            //delete joint;
+        }
 	}
+    mChildren.clear();
 }
 
 
-- 
cgit v1.2.3