mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Fixing a crash
This commit is contained in:
parent
2d0e83a2cf
commit
2217847c57
2 changed files with 24 additions and 3 deletions
|
@ -531,6 +531,8 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
|
|||
{
|
||||
sub->addBoneAssignment(*it);
|
||||
}
|
||||
if(mSkel.isNull())
|
||||
needBoneAssignments.push_back(sub);
|
||||
}
|
||||
|
||||
// Helper math functions. Reinventing linear algebra for the win!
|
||||
|
@ -945,6 +947,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
{
|
||||
// Add this vertex set to the bounding box
|
||||
bounds.add(optr, numVerts);
|
||||
if(addShapes)
|
||||
shapes.push_back(copy);
|
||||
|
||||
// Create the submesh
|
||||
|
@ -1066,9 +1069,11 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
|
|||
//FIXME: "Bip01" isn't every time the root bone
|
||||
if (node->name == "Bip01" || node->name == "Root Bone") //root node, create a skeleton
|
||||
{
|
||||
|
||||
addShapes = true;
|
||||
mSkel = SkeletonManager::getSingleton().create(getSkeletonName(), resourceGroup, true);
|
||||
}
|
||||
else if (!mSkel.isNull() && !parentBone)
|
||||
addShapes = false;
|
||||
|
||||
if (!mSkel.isNull()) //if there is a skeleton
|
||||
{
|
||||
|
@ -1143,8 +1148,11 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
|
|||
|
||||
void NIFLoader::loadResource(Resource *resource)
|
||||
{
|
||||
addShapes = false;
|
||||
allanim.clear();
|
||||
shapes.clear();
|
||||
needBoneAssignments.clear();
|
||||
// needBoneAssignments.clear();
|
||||
mBoundingBox.setNull();
|
||||
mesh = 0;
|
||||
mSkel.setNull();
|
||||
|
@ -1311,6 +1319,17 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
|
||||
if (!mSkel.isNull() )
|
||||
{
|
||||
for(std::vector<Ogre::SubMesh*>::iterator iter = needBoneAssignments.begin(); iter != needBoneAssignments.end(); iter++)
|
||||
{
|
||||
int boneIndex = mSkel->getNumBones() - 1;
|
||||
VertexBoneAssignment vba;
|
||||
vba.boneIndex = boneIndex;
|
||||
vba.vertexIndex = 0;
|
||||
vba.weight = 1;
|
||||
|
||||
|
||||
(*iter)->addBoneAssignment(vba);
|
||||
}
|
||||
mesh->_notifySkeleton(mSkel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
|
||||
private:
|
||||
NIFLoader() : mNormaliseNormals(false), resourceGroup("General"), resourceName(""), flip(false),
|
||||
mFlipVertexWinding(false), mOutputAnimFiles(false) {}
|
||||
mFlipVertexWinding(false), mOutputAnimFiles(false), addShapes(false) {}
|
||||
NIFLoader(NIFLoader& n) {}
|
||||
|
||||
void calculateTransform();
|
||||
|
@ -189,6 +189,8 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
std::map<std::string,std::vector<Nif::NiTriShapeCopy>,ciLessBoost> allshapesmap;
|
||||
std::vector<Nif::NiKeyframeData> mAnim;
|
||||
std::vector<Nif::NiTriShapeCopy> mS;
|
||||
std::vector<Ogre::SubMesh*> needBoneAssignments;
|
||||
bool addShapes;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue