Commit 0812b449 authored by lukeph's avatar lukeph

fixed weight bug when more then one mesh in an x file is skinned

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@972 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 81bd54f2
......@@ -137,6 +137,7 @@ namespace scene
//! List of child joints
core::array<SJoint*> Children;
//! List of attached meshes
core::array<u32> AttachedMeshes;
//! Animation keys causing translation change
......
......@@ -200,18 +200,13 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
}
}
for (i=0;i<AnimatedMesh->getAllJoints().size();++i)
for (u32 j=0;j<mesh->Weights.size();++j)
{
ISkinnedMesh::SWeight& Weight = (*mesh->Weights[j]);
ISkinnedMesh::SJoint *Joint=AnimatedMesh->getAllJoints()[i];
for (u32 j=0;j<Joint->Weights.size();++j)
{
ISkinnedMesh::SWeight& Weight = Joint->Weights[j];
u32 id = Weight.vertex_id;
if (id>verticesLink.size())
if (id>=verticesLink.size())
{
os::Printer::log("X loader: Weight id out of range", ELL_WARNING);
id=0;
......@@ -233,7 +228,7 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
}
}
}
}
}
#else
{
......@@ -290,13 +285,10 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
buffer->Indices.push_back( verticesLink[ mesh->Indices[id] ] );
}
for (i=0; i<AnimatedMesh->getAllJoints().size(); ++i)
{
ISkinnedMesh::SJoint *Joint = AnimatedMesh->getAllJoints()[i];
for (u32 j=0;j<Joint->Weights.size();++j)
for (u32 j=0;j<mesh->Weights.size();++j)
{
ISkinnedMesh::SWeight& Weight = Joint->Weights[j];
ISkinnedMesh::SWeight& Weight = (*mesh->Weights[j]);
u32 id = Weight.vertex_id;
......@@ -309,7 +301,7 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
Weight.vertex_id=verticesLink[id];
Weight.buffer_id=verticesLinkBuffer[id];
}
}
}
#endif
......@@ -884,12 +876,16 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
const u32 jointStart = joint->Weights.size();
joint->Weights.reallocate(jointStart+nWeights);
mesh.Weights.reallocate( mesh.Weights.size() + nWeights );
for (i=0; i<nWeights; ++i)
{
CSkinnedMesh::SWeight *weight=AnimatedMesh->createWeight(joint);
weight->buffer_id=0;
weight->vertex_id=readInt();
mesh.Weights.push_back(weight);
}
// read vertex weights
......
......@@ -76,6 +76,8 @@ public:
s32 AttachedJointID;
bool HasSkinning;
core::array<ISkinnedMesh::SWeight*> Weights;
};
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment