mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 08:15:33 +00:00
Be a little more aggressive when looking to skip generating a skeleton
This is needed to handle the insane number of nodes and trishapes in in_prison_ship.nif, as Ogre has a 256-bone limit for skeletons. This is a bit sketchy, but it works.
This commit is contained in:
parent
000236ba80
commit
53eb553c57
1 changed files with 25 additions and 15 deletions
|
@ -454,23 +454,33 @@ void loadResource(Ogre::Resource *resource)
|
||||||
|
|
||||||
bool createSkeleton(const std::string &name, const std::string &group, const Nif::Node *node)
|
bool createSkeleton(const std::string &name, const std::string &group, const Nif::Node *node)
|
||||||
{
|
{
|
||||||
/* If the root node is a NiTriShape, or is a parent to only NiTriShapes, do
|
/* We need to be a little aggressive here, since some NIFs have a crap-ton
|
||||||
* not create a skeleton. */
|
* of nodes and Ogre only supports 256 bones. We will skip a skeleton if:
|
||||||
if(node->recType == Nif::RC_NiTriShape)
|
* There are no bones used for skinning, there are no controllers on non-
|
||||||
return false;
|
* NiTriShape nodes, there are no nodes named "AttachLight", and the tree
|
||||||
|
* consists of NiNode, NiTriShape, and RootCollisionNode types only.
|
||||||
if(node->recType == Nif::RC_NiNode)
|
*/
|
||||||
|
if(!node->boneTrafo)
|
||||||
{
|
{
|
||||||
bool alltrishapes = true;
|
if(node->recType == Nif::RC_NiTriShape)
|
||||||
const Nif::NiNode *ninode = static_cast<const Nif::NiNode*>(node);
|
|
||||||
const Nif::NodeList &children = ninode->children;
|
|
||||||
for(size_t i = 0;i < children.length() && alltrishapes;i++)
|
|
||||||
{
|
|
||||||
if(!children[i].empty() && children[i]->recType != Nif::RC_NiTriShape)
|
|
||||||
alltrishapes = false;
|
|
||||||
}
|
|
||||||
if(alltrishapes)
|
|
||||||
return false;
|
return false;
|
||||||
|
if(node->controller.empty() && node->name != "AttachLight")
|
||||||
|
{
|
||||||
|
if(node->recType == Nif::RC_NiNode || node->recType == Nif::RC_RootCollisionNode)
|
||||||
|
{
|
||||||
|
const Nif::NiNode *ninode = static_cast<const Nif::NiNode*>(node);
|
||||||
|
const Nif::NodeList &children = ninode->children;
|
||||||
|
for(size_t i = 0;i < children.length();i++)
|
||||||
|
{
|
||||||
|
if(!children[i].empty())
|
||||||
|
{
|
||||||
|
if(createSkeleton(name, group, children[i].getPtr()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::SkeletonManager &skelMgr = Ogre::SkeletonManager::getSingleton();
|
Ogre::SkeletonManager &skelMgr = Ogre::SkeletonManager::getSingleton();
|
||||||
|
|
Loading…
Reference in a new issue