Store the skeleton name with the mesh resource loader instead of a flag

This commit is contained in:
Chris Robinson 2012-07-18 17:26:51 -07:00
parent 04b244cf9e
commit 626dcd54dc

View file

@ -509,7 +509,7 @@ class NIFMeshLoader : Ogre::ManualResourceLoader
std::string mGroup; std::string mGroup;
std::string mShapeName; std::string mShapeName;
std::string mMaterialName; std::string mMaterialName;
bool mHasSkel; std::string mSkelName;
void warn(const std::string &msg) void warn(const std::string &msg)
{ {
@ -535,7 +535,7 @@ class NIFMeshLoader : Ogre::ManualResourceLoader
{ {
// Only set a skeleton when skinning. Unskinned meshes with a skeleton will be // Only set a skeleton when skinning. Unskinned meshes with a skeleton will be
// explicitly attached later. // explicitly attached later.
mesh->setSkeletonName(mName); mesh->setSkeletonName(mSkelName);
// Get the skeleton resource, so vertices can be transformed into the bones' initial state. // Get the skeleton resource, so vertices can be transformed into the bones' initial state.
Ogre::SkeletonManager *skelMgr = Ogre::SkeletonManager::getSingletonPtr(); Ogre::SkeletonManager *skelMgr = Ogre::SkeletonManager::getSingletonPtr();
@ -579,7 +579,7 @@ class NIFMeshLoader : Ogre::ManualResourceLoader
srcVerts = newVerts; srcVerts = newVerts;
srcNorms = newNorms; srcNorms = newNorms;
} }
else if(!mHasSkel) else if(mSkelName.length() == 0)
{ {
// No skinning and no skeleton, so just transform the vertices and // No skinning and no skeleton, so just transform the vertices and
// normals into position. // normals into position.
@ -752,10 +752,9 @@ class NIFMeshLoader : Ogre::ManualResourceLoader
public: public:
NIFMeshLoader() NIFMeshLoader()
: mHasSkel(false)
{ } { }
NIFMeshLoader(const std::string &name, const std::string &group, bool hasSkel) NIFMeshLoader(const std::string &name, const std::string &group, const std::string skelName)
: mName(name), mGroup(group), mHasSkel(hasSkel) : mName(name), mGroup(group), mSkelName(skelName)
{ } { }
virtual void loadResource(Ogre::Resource *resource) virtual void loadResource(Ogre::Resource *resource)
@ -765,8 +764,8 @@ public:
if(!mShapeName.length()) if(!mShapeName.length())
{ {
if(mHasSkel) if(mSkelName.length() > 0)
mesh->setSkeletonName(mName); mesh->setSkeletonName(mSkelName);
return; return;
} }
@ -874,7 +873,7 @@ MeshPairList NIFLoader::load(std::string name, const std::string &group)
bool hasSkel = NIFSkeletonLoader::createSkeleton(name, group, node); bool hasSkel = NIFSkeletonLoader::createSkeleton(name, group, node);
NIFMeshLoader meshldr(name, group, hasSkel); NIFMeshLoader meshldr(name, group, (hasSkel ? name : std::string()));
meshldr.createMeshes(node, meshes); meshldr.createMeshes(node, meshes);
return meshes; return meshes;