Commit 146d7c26 authored by hybrid's avatar hybrid

Fix bone-vertex IDs to be correctly indexing into the global vertex array....

Fix bone-vertex IDs to be correctly indexing into the global vertex array. Before, mixed mesh/bone sections broke the correct relation. Thanks to Auria for finding and fixing the bug.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3539 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 28dd2521
...@@ -55,6 +55,7 @@ IAnimatedMesh* CB3DMeshFileLoader::createMesh(io::IReadFile* f) ...@@ -55,6 +55,7 @@ IAnimatedMesh* CB3DMeshFileLoader::createMesh(io::IReadFile* f)
B3DFile = f; B3DFile = f;
AnimatedMesh = new scene::CSkinnedMesh(); AnimatedMesh = new scene::CSkinnedMesh();
ShowWarning = true; // If true a warning is issued if too many textures are used ShowWarning = true; // If true a warning is issued if too many textures are used
VerticesStart=0;
if ( load() ) if ( load() )
{ {
...@@ -198,6 +199,7 @@ bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *inJoint) ...@@ -198,6 +199,7 @@ bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *inJoint)
} }
else if ( strncmp( B3dStack.getLast().name, "MESH", 4 ) == 0 ) else if ( strncmp( B3dStack.getLast().name, "MESH", 4 ) == 0 )
{ {
VerticesStart=BaseVertices.size();
if (!readChunkMESH(joint)) if (!readChunkMESH(joint))
return false; return false;
} }
...@@ -236,12 +238,10 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint) ...@@ -236,12 +238,10 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint)
os::Printer::log("read ChunkMESH"); os::Printer::log("read ChunkMESH");
#endif #endif
const s32 vertices_Start=BaseVertices.size(); //B3Ds have Vertex ID's local within the mesh I don't want this s32 brushID;
B3DFile->read(&brushID, sizeof(brushID));
s32 brush_id;
B3DFile->read(&brush_id, sizeof(brush_id));
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
brush_id = os::Byteswap::byteswap(brush_id); brushID = os::Byteswap::byteswap(brushID);
#endif #endif
NormalsInFile=false; NormalsInFile=false;
...@@ -266,13 +266,13 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint) ...@@ -266,13 +266,13 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint)
{ {
scene::SSkinMeshBuffer *meshBuffer = AnimatedMesh->addMeshBuffer(); scene::SSkinMeshBuffer *meshBuffer = AnimatedMesh->addMeshBuffer();
if (brush_id!=-1) if (brushID!=-1)
{ {
loadTextures(Materials[brush_id]); loadTextures(Materials[brushID]);
meshBuffer->Material=Materials[brush_id].Material; meshBuffer->Material=Materials[brushID].Material;
} }
if(readChunkTRIS(meshBuffer,AnimatedMesh->getMeshBuffers().size()-1, vertices_Start)==false) if(readChunkTRIS(meshBuffer,AnimatedMesh->getMeshBuffers().size()-1, VerticesStart)==false)
return false; return false;
if (!NormalsInFile) if (!NormalsInFile)
...@@ -293,7 +293,7 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint) ...@@ -293,7 +293,7 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint)
for ( i = 0; i<(s32)meshBuffer->getVertexCount(); ++i ) for ( i = 0; i<(s32)meshBuffer->getVertexCount(); ++i )
{ {
meshBuffer->getVertex(i)->Normal.normalize(); meshBuffer->getVertex(i)->Normal.normalize();
BaseVertices[vertices_Start+i].Normal=meshBuffer->getVertex(i)->Normal; BaseVertices[VerticesStart+i].Normal=meshBuffer->getVertex(i)->Normal;
} }
} }
} }
...@@ -562,6 +562,7 @@ bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *inJoint) ...@@ -562,6 +562,7 @@ bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *inJoint)
globalVertexID = os::Byteswap::byteswap(globalVertexID); globalVertexID = os::Byteswap::byteswap(globalVertexID);
strength = os::Byteswap::byteswap(strength); strength = os::Byteswap::byteswap(strength);
#endif #endif
globalVertexID += VerticesStart;
if (AnimatedVertices_VertexID[globalVertexID]==-1) if (AnimatedVertices_VertexID[globalVertexID]==-1)
{ {
......
...@@ -123,6 +123,10 @@ private: ...@@ -123,6 +123,10 @@ private:
CSkinnedMesh* AnimatedMesh; CSkinnedMesh* AnimatedMesh;
io::IReadFile* B3DFile; io::IReadFile* B3DFile;
//B3Ds have Vertex ID's local within the mesh I don't want this
// Variable needs to be class member due to recursion in calls
u32 VerticesStart;
bool NormalsInFile; bool NormalsInFile;
bool HasVertexColors; bool HasVertexColors;
bool ShowWarning; bool ShowWarning;
......
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