diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index 33c8c449d..495c6ba50 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -66,11 +66,6 @@ BulletNifLoader::~BulletNifLoader() { } -void BulletNifLoader::setAnimatedNodes(const std::set &animatedNodes) -{ - mAnimatedNodes = animatedNodes; -} - osg::ref_ptr BulletNifLoader::load(const Nif::NIFFilePtr nif) { mShape = new BulletShape; @@ -110,7 +105,20 @@ osg::ref_ptr BulletNifLoader::load(const Nif::NIFFilePtr nif) else { bool autogenerated = hasAutoGeneratedCollision(node); - handleNode(node, 0, autogenerated, false, autogenerated); + bool isAnimated = false; + + // files with the name convention xmodel.nif usually have keyframes stored in a separate file xmodel.kf (see Animation::addAnimSource). + // assume all nodes in the file will be animated + std::string filename = nif->getFilename(); + size_t slashpos = filename.find_last_of("/\\"); + if (slashpos == std::string::npos) + slashpos = 0; + if (slashpos+1 < filename.size() && (filename[slashpos+1] == 'x' || filename[slashpos+1] == 'X')) + { + isAnimated = true; + } + + handleNode(node, 0, autogenerated, isAnimated, autogenerated); if (mCompoundShape) { @@ -192,9 +200,6 @@ void BulletNifLoader::handleNode(const Nif::Node *node, int flags, && (node->controller->flags & Nif::NiNode::ControllerFlag_Active)) isAnimated = true; - if (mAnimatedNodes.find(node->name) != mAnimatedNodes.end()) - isAnimated = true; - isCollisionNode = isCollisionNode || (node->recType == Nif::RC_RootCollisionNode); // Don't collide with AvoidNode shapes diff --git a/components/nifbullet/bulletnifloader.hpp b/components/nifbullet/bulletnifloader.hpp index 0865b134a..52428cc74 100644 --- a/components/nifbullet/bulletnifloader.hpp +++ b/components/nifbullet/bulletnifloader.hpp @@ -91,8 +91,6 @@ public: abort(); } - void setAnimatedNodes(const std::set& animatedNodes); - osg::ref_ptr load(const Nif::NIFFilePtr file); private: @@ -108,8 +106,6 @@ private: btTriangleMesh* mStaticMesh; - std::set mAnimatedNodes; - osg::ref_ptr mShape; }; diff --git a/components/nifbullet/bulletshapemanager.cpp b/components/nifbullet/bulletshapemanager.cpp index e53a351cf..57848ab81 100644 --- a/components/nifbullet/bulletshapemanager.cpp +++ b/components/nifbullet/bulletshapemanager.cpp @@ -34,20 +34,7 @@ osg::ref_ptr BulletShapeManager::createInstance(const std:: // TODO: add support for non-NIF formats - std::string kfname = normalized; - if(kfname.size() > 4 && kfname.compare(kfname.size()-4, 4, ".nif") == 0) - kfname.replace(kfname.size()-4, 4, ".kf"); - std::set animatedNodes; - if (mVFS->exists(kfname)) - { - osg::ref_ptr keyframes = mSceneManager->getKeyframes(kfname); - for (NifOsg::KeyframeHolder::KeyframeControllerMap::const_iterator it = keyframes->mKeyframeControllers.begin(); - it != keyframes->mKeyframeControllers.end(); ++it) - animatedNodes.insert(it->first); - } - BulletNifLoader loader; - loader.setAnimatedNodes(animatedNodes); // might be worth sharing NIFFiles with SceneManager in some way shape = loader.load(Nif::NIFFilePtr(new Nif::NIFFile(file, normalized)));