- fbx: bugfix multi-material splitting.

pull/14/head
Alexander Gessler 2012-07-06 16:48:09 +02:00
parent d6e929b670
commit 4bfd5c11d7
1 changed files with 14 additions and 11 deletions

View File

@ -262,11 +262,6 @@ private:
return temp; return temp;
} }
aiMesh* out_mesh = new aiMesh();
meshes.push_back(out_mesh);
meshes_converted[&mesh] = static_cast<unsigned int>(meshes.size()-1);
// one material per mesh maps easily to aiMesh. Multiple material // one material per mesh maps easily to aiMesh. Multiple material
// meshes need to be split. // meshes need to be split.
const std::vector<unsigned int>& mindices = mesh.GetMaterialIndices(); const std::vector<unsigned int>& mindices = mesh.GetMaterialIndices();
@ -274,20 +269,24 @@ private:
const unsigned int base = mindices[0]; const unsigned int base = mindices[0];
BOOST_FOREACH(unsigned int index, mindices) { BOOST_FOREACH(unsigned int index, mindices) {
if(index != base) { if(index != base) {
return ConvertMeshMultiMaterial(out_mesh, mesh, model); return ConvertMeshMultiMaterial(mesh, model);
} }
} }
} }
// faster codepath, just copy the data // faster codepath, just copy the data
temp.push_back(ConvertMeshSingleMaterial(out_mesh, mesh, model)); temp.push_back(ConvertMeshSingleMaterial(mesh, model));
return temp; return temp;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
unsigned int ConvertMeshSingleMaterial(aiMesh* out_mesh, const MeshGeometry& mesh, const Model& model) unsigned int ConvertMeshSingleMaterial(const MeshGeometry& mesh, const Model& model)
{ {
aiMesh* const out_mesh = new aiMesh();
meshes.push_back(out_mesh);
meshes_converted[&mesh] = static_cast<unsigned int>(meshes.size()-1);
const std::vector<aiVector3D>& vertices = mesh.GetVertices(); const std::vector<aiVector3D>& vertices = mesh.GetVertices();
const std::vector<unsigned int>& faces = mesh.GetFaceIndexCounts(); const std::vector<unsigned int>& faces = mesh.GetFaceIndexCounts();
@ -407,7 +406,7 @@ private:
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
std::vector<unsigned int> ConvertMeshMultiMaterial(aiMesh* out_mesh, const MeshGeometry& mesh, const Model& model) std::vector<unsigned int> ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model)
{ {
const std::vector<unsigned int>& mindices = mesh.GetMaterialIndices(); const std::vector<unsigned int>& mindices = mesh.GetMaterialIndices();
ai_assert(mindices.size()); ai_assert(mindices.size());
@ -418,7 +417,7 @@ private:
BOOST_FOREACH(unsigned int index, mindices) { BOOST_FOREACH(unsigned int index, mindices) {
if(had.find(index) != had.end()) { if(had.find(index) != had.end()) {
indices.push_back(ConvertMeshMultiMaterial(out_mesh, mesh, model, index)); indices.push_back(ConvertMeshMultiMaterial(mesh, model, index));
had.insert(index); had.insert(index);
} }
} }
@ -428,8 +427,12 @@ private:
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
unsigned int ConvertMeshMultiMaterial(aiMesh* out_mesh, const MeshGeometry& mesh, const Model& model, unsigned int index) unsigned int ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model, unsigned int index)
{ {
aiMesh* const out_mesh = new aiMesh();
meshes.push_back(out_mesh);
meshes_converted[&mesh] = static_cast<unsigned int>(meshes.size()-1);
const std::vector<unsigned int>& mindices = mesh.GetMaterialIndices(); const std::vector<unsigned int>& mindices = mesh.GetMaterialIndices();
ai_assert(mindices.size()); ai_assert(mindices.size());