From 359d0494308451ce1318f0291ebbf0ba58e42f44 Mon Sep 17 00:00:00 2001
From: prep linden <prep@lindenlab.com>
Date: Thu, 17 Mar 2011 17:25:52 -0400
Subject: [PATCH] Added support for handling an asset that contains a skeletal
 node which has no root node for the scene (yuck). Fix for an upload issue
 w/simplebot

---
 indra/newview/llfloatermodelpreview.cpp | 23 ++++++++++++++++++++---
 indra/newview/llvoavatar.cpp            |  4 +++-
 indra/newview/llvovolume.cpp            |  4 +++-
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 6bf9fdfb9b8..190af6deef0 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -1070,7 +1070,6 @@ LLModelLoader::LLModelLoader(std::string filename, S32 lod, LLModelPreview* prev
 	mMasterJointList.push_front("mChest");
 	mMasterJointList.push_front("mNeck");
 	mMasterJointList.push_front("mHead");
-	mMasterJointList.push_front("mSkull");
 	mMasterJointList.push_front("mCollarLeft");
 	mMasterJointList.push_front("mShoulderLeft");
 	mMasterJointList.push_front("mElbowLeft");
@@ -1298,7 +1297,25 @@ void LLModelLoader::run()
 							bool missingSkeletonOrScene = false;
 							
 							//If no skeleton, do a breadth-first search to get at specific joints
-							if ( !pSkeleton )
+							bool rootNode = false;
+							bool skeletonWithNoRootNode = false;
+							
+							//Need to test for a skeleton that does not have a root node
+							//This occurs when your instance controller does not have an associated scene 
+							if ( pSkeleton )
+							{
+								daeElement* pSkeletonRootNode = pSkeleton->getValue().getElement();
+								if ( pSkeletonRootNode )
+								{
+									rootNode = true;
+								}
+								else 
+								{
+									skeletonWithNoRootNode = true;
+								}
+
+							}
+							if ( !pSkeleton || !rootNode )
 							{
 								daeElement* pScene = root->getDescendant("visual_scene");
 								if ( !pScene )
@@ -1482,7 +1499,7 @@ void LLModelLoader::run()
 							//a skinned asset attached to a node in a file that contains an entire skeleton,
 							//but does not use the skeleton).
 							mPreview->setRigValid( doesJointArrayContainACompleteRig( model->mJointList ) );
-							if ( !model->mJointList.empty() && mPreview->isRigValid() ) 
+							if ( !skeletonWithNoRootNode && !model->mJointList.empty() && mPreview->isRigValid() ) 
 							{
 								mResetJoints = true;
 							}
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 5f0e4bcded0..87a2c949b17 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -6032,7 +6032,9 @@ void LLVOAvatar::cleanupAttachedMesh( LLViewerObject* pVO )
 			if ( pSkinData )
 			{
 				const int jointCnt = pSkinData->mJointNames.size();
-				bool fullRig = ( jointCnt>=20 ) ? true : false;
+				//19 is a magic number derived from the master joint list
+				//TODO#  move that joint list into the bone controller and query 
+				bool fullRig = ( jointCnt>=19 ) ? true : false;
 				if ( fullRig )
 				{
 					const int bindCnt = pSkinData->mAlternateBindMatrix.size();							
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 43d8b9d356c..0e6110549e5 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3942,7 +3942,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 						{					
 							const int jointCnt = pSkinData->mJointNames.size();
 							const int pelvisZOffset = pSkinData->mPelvisOffset;
-							bool fullRig = (jointCnt>=20) ? true : false;
+							//19 is a magic number derived from the master joint list
+							//TODO# move that joint list into the bone controller and query 
+							bool fullRig = (jointCnt>=19) ? true : false;
 							if ( fullRig )
 							{
 								for ( int i=0; i<jointCnt; ++i )
-- 
GitLab