Add hack required for unnamed animated collision shapes (in_dagoth_bridge00.nif)

deque
scrawl 11 years ago
parent 10ef0a34d9
commit 4949aa1fbb

@ -58,13 +58,16 @@ void animateCollisionShapes (std::map<OEngine::Physic::RigidBody*, OEngine::Phys
for (std::map<std::string, int>::iterator shapeIt = shapes.begin();
shapeIt != shapes.end(); ++shapeIt)
{
Ogre::Node* bone = animation->getNode(shapeIt->first);
// FIXME: this will happen for nodes with empty names. Ogre's SkeletonInstance::cloneBoneAndChildren
// will assign an auto-generated name if the bone name was empty. We could use the bone handle instead of
// the bone name, but that is a bit tricky to retrieve.
Ogre::Node* bone;
if (shapeIt->first.empty())
// HACK: see NifSkeletonLoader::buildBones
bone = animation->getNode(" ");
else
bone = animation->getNode(shapeIt->first);
if (bone == NULL)
continue;
throw std::runtime_error("can't find bone");
btCompoundShape* compound = dynamic_cast<btCompoundShape*>(instance.mCompound);

@ -14,10 +14,24 @@ namespace NifOgre
void NIFSkeletonLoader::buildBones(Ogre::Skeleton *skel, const Nif::Node *node, Ogre::Bone *parent)
{
Ogre::Bone *bone;
if(!skel->hasBone(node->name))
bone = skel->createBone(node->name);
if (node->name.empty())
{
// HACK: use " " instead of empty name, otherwise Ogre will replace it with an auto-generated
// name in SkeletonInstance::cloneBoneAndChildren.
static const char* emptyname = " ";
if (!skel->hasBone(emptyname))
bone = skel->createBone(emptyname);
else
bone = skel->createBone();
}
else
bone = skel->createBone();
{
if(!skel->hasBone(node->name))
bone = skel->createBone(node->name);
else
bone = skel->createBone();
}
if(parent) parent->addChild(bone);
mNifToOgreHandleMap[node->recIndex] = bone->getHandle();

Loading…
Cancel
Save