Skip to content
Snippets Groups Projects
Commit 788bee73 authored by Amorilia's avatar Amorilia
Browse files

reverted skeleton root calculation (now GetParent() tries to return a node the...

reverted skeleton root calculation (now GetParent() tries to return a node the old strategy works again, and actually it even works better :-) )
parent 03b1612c
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment