From 788bee73c145a77f42ca76a7176aa03c14f0ffdf Mon Sep 17 00:00:00 2001
From: Amorilia <amorilia@users.sourceforge.net>
Date: Sat, 11 Feb 2006 02:47:18 +0000
Subject: [PATCH] reverted skeleton root calculation (now GetParent() tries to
 return a node the old strategy works again, and actually it even works better
 :-) )

---
 nif_attrs.h | 44 ++++++++++----------------------------------
 1 file changed, 10 insertions(+), 34 deletions(-)

diff --git a/nif_attrs.h b/nif_attrs.h
index ec361eec..f8bd7999 100644
--- a/nif_attrs.h
+++ b/nif_attrs.h
@@ -1218,45 +1218,21 @@ public:
 		// We want to get the closest common ancestor between the _owner and the bones
 		// So start with a list of ancestors of the first bone (this is just a random choice)
 		blk_ref block = bones[0];
-		list<blk_ref> pars = block->GetParents();
-		blk_ref nodepar = blk_ref();
-		for ( list<blk_ref>::const_iterator it = pars.begin(); it != pars.end(); it++ )
-			if ( (*it)->GetBlockType() == "NiNode" ) {
-				nodepar = *it;
-				break;
-			};
+		blk_ref par = block->GetParent();
 		list<blk_ref> bone_pars;
-		while ( nodepar.is_null() == false ) {
-			bone_pars.push_front(nodepar);
-			pars = nodepar->GetParents();
-			nodepar = blk_ref();
-			for ( list<blk_ref>::const_iterator it = pars.begin(); it != pars.end(); it++ )
-				if ( (*it)->GetBlockType() == "NiNode" ) {
-					nodepar = *it;
-					break;
-				};
+		while ( par.is_null() == false ) {
+			bone_pars.push_front(par);
+			par = par->GetParent();
 		};
 		// Now do the same with the owner.
-		block = _owner->GetParent(); // TriShape
-		pars = block->GetParents();
-		nodepar = blk_ref();
-		for ( list<blk_ref>::const_iterator it = pars.begin(); it != pars.end(); it++ )
-			if ( (*it)->GetBlockType() == "NiNode" ) {
-				nodepar = *it;
-				break;
-			};
+		block = _owner;
+		par = block->GetParent();
 		list<blk_ref> owner_pars;
-		while ( nodepar.is_null() == false ) {
-			owner_pars.push_front(nodepar);
-			pars = nodepar->GetParents();
-			nodepar = blk_ref();
-			for ( list<blk_ref>::const_iterator it = pars.begin(); it != pars.end(); it++ )
-				if ( (*it)->GetBlockType() == "NiNode" ) {
-					nodepar = *it;
-					break;
-				};
+		while ( par.is_null() == false ) {
+			owner_pars.push_front(par);
+			par = par->GetParent();
 		};
-		// Now find closest common NiNode ancestor.
+		// Now find closest common ancestor.
 		if ( owner_pars.empty() || bone_pars.empty() )
 			throw runtime_error("Skinning instance has no common parent with the bones it refers to (invalid NIF file?). Cannot set skeleton root.");
 		blk_ref skelroot;
-- 
GitLab