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-e03cc46cb475master
parent
81bd54f2fd
commit
0812b44901
|
@ -137,6 +137,7 @@ namespace scene
|
||||||
//! List of child joints
|
//! List of child joints
|
||||||
core::array<SJoint*> Children;
|
core::array<SJoint*> Children;
|
||||||
|
|
||||||
|
//! List of attached meshes
|
||||||
core::array<u32> AttachedMeshes;
|
core::array<u32> AttachedMeshes;
|
||||||
|
|
||||||
//! Animation keys causing translation change
|
//! 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;
|
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);
|
os::Printer::log("X loader: Weight id out of range", ELL_WARNING);
|
||||||
id=0;
|
id=0;
|
||||||
|
@ -233,7 +228,7 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
|
@ -290,13 +285,10 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
|
||||||
buffer->Indices.push_back( verticesLink[ mesh->Indices[id] ] );
|
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;
|
u32 id = Weight.vertex_id;
|
||||||
|
|
||||||
|
@ -309,7 +301,7 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
|
||||||
Weight.vertex_id=verticesLink[id];
|
Weight.vertex_id=verticesLink[id];
|
||||||
Weight.buffer_id=verticesLinkBuffer[id];
|
Weight.buffer_id=verticesLinkBuffer[id];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -884,12 +876,16 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
|
||||||
const u32 jointStart = joint->Weights.size();
|
const u32 jointStart = joint->Weights.size();
|
||||||
joint->Weights.reallocate(jointStart+nWeights);
|
joint->Weights.reallocate(jointStart+nWeights);
|
||||||
|
|
||||||
|
mesh.Weights.reallocate( mesh.Weights.size() + nWeights );
|
||||||
|
|
||||||
for (i=0; i<nWeights; ++i)
|
for (i=0; i<nWeights; ++i)
|
||||||
{
|
{
|
||||||
CSkinnedMesh::SWeight *weight=AnimatedMesh->createWeight(joint);
|
CSkinnedMesh::SWeight *weight=AnimatedMesh->createWeight(joint);
|
||||||
|
|
||||||
weight->buffer_id=0;
|
weight->buffer_id=0;
|
||||||
weight->vertex_id=readInt();
|
weight->vertex_id=readInt();
|
||||||
|
|
||||||
|
mesh.Weights.push_back(weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read vertex weights
|
// read vertex weights
|
||||||
|
|
|
@ -76,6 +76,8 @@ public:
|
||||||
s32 AttachedJointID;
|
s32 AttachedJointID;
|
||||||
|
|
||||||
bool HasSkinning;
|
bool HasSkinning;
|
||||||
|
|
||||||
|
core::array<ISkinnedMesh::SWeight*> Weights;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue