Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some FBX multi-material mesh fixes #2546

Merged
merged 1 commit into from
Jul 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions code/FBX/FBXConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1247,10 +1247,10 @@ namespace Assimp {
ai_assert(count_faces);
ai_assert(count_vertices);

// mapping from output indices to DOM indexing, needed to resolve weights
// mapping from output indices to DOM indexing, needed to resolve weights or blendshapes
std::vector<unsigned int> reverseMapping;
std::map<unsigned int, unsigned int> translateIndexMap;
if (process_weights) {
if (process_weights || mesh.GetBlendShapes().size() > 0) {
reverseMapping.resize(count_vertices);
}

Expand Down Expand Up @@ -1407,7 +1407,10 @@ namespace Assimp {
unsigned int count = 0;
const unsigned int* outIndices = mesh.ToOutputVertexIndex(index, count);
for (unsigned int k = 0; k < count; k++) {
unsigned int index = translateIndexMap[outIndices[k]];
unsigned int outIndex = outIndices[k];
if (translateIndexMap.find(outIndex) == translateIndexMap.end())
continue;
unsigned int index = translateIndexMap[outIndex];
animMesh->mVertices[index] += vertex;
if (animMesh->mNormals != nullptr) {
animMesh->mNormals[index] += normal;
Expand All @@ -1421,6 +1424,15 @@ namespace Assimp {
}
}

const size_t numAnimMeshes = animMeshes.size();
if (numAnimMeshes > 0) {
out_mesh->mNumAnimMeshes = static_cast<unsigned int>(numAnimMeshes);
out_mesh->mAnimMeshes = new aiAnimMesh*[numAnimMeshes];
for (size_t i = 0; i < numAnimMeshes; i++) {
out_mesh->mAnimMeshes[i] = animMeshes.at(i);
}
}

return static_cast<unsigned int>(meshes.size() - 1);
}

Expand Down