From ab55fb27c3c9cc954df05c06c734402ac4661284 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 2 Jul 2019 13:38:04 +0200 Subject: [PATCH 1/3] Fix a GCC 9 warning: assimp/include/assimp/material.inl: In member function 'aiReturn aiMaterial::Get(const char*, unsigned int, unsigned int, aiColor3D&) const': assimp/include/assimp/material.inl:176:33: error: implicitly-declared 'aiColor3D& aiColor3D::operator=(const aiColor3D&)' is deprecated [-Werror=deprecated-copy] 176 | pOut = aiColor3D(c.r,c.g,c.b); --- include/assimp/types.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/assimp/types.h b/include/assimp/types.h index 748e4851f..331b8cd03 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -161,7 +161,14 @@ struct aiColor3D explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {} aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {} - /** Component-wise comparison */ + aiColor3D &operator=(const aiColor3D &o) { + r = o.r; + g = o.g; + b = o.b; + return *this; + } + + /** Component-wise comparison */ // TODO: add epsilon? bool operator == (const aiColor3D& other) const {return r == other.r && g == other.g && b == other.b;} From 1fc232effae7385c310fa228ad2014eea51c49eb Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 2 Jul 2019 21:46:52 +0200 Subject: [PATCH 2/3] closes https://github.com/assimp/assimp/issues/2368: just fix it --- code/FBX/FBXConverter.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/code/FBX/FBXConverter.cpp b/code/FBX/FBXConverter.cpp index ccbfc9b40..9906fcdf8 100644 --- a/code/FBX/FBXConverter.cpp +++ b/code/FBX/FBXConverter.cpp @@ -1255,7 +1255,7 @@ namespace Assimp { // mapping from output indices to DOM indexing, needed to resolve weights std::vector reverseMapping; - + std::map translateIndexMap; if (process_weights) { reverseMapping.resize(count_vertices); } @@ -1363,6 +1363,7 @@ namespace Assimp { if (reverseMapping.size()) { reverseMapping[cursor] = in_cursor; + translateIndexMap[in_cursor] = cursor; } out_mesh->mVertices[cursor] = vertices[in_cursor]; @@ -1394,6 +1395,42 @@ namespace Assimp { ConvertWeights(out_mesh, model, mesh, node_global_transform, index, &reverseMapping); } + std::vector animMeshes; + for (const BlendShape* blendShape : mesh.GetBlendShapes()) { + for (const BlendShapeChannel* blendShapeChannel : blendShape->BlendShapeChannels()) { + const std::vector& shapeGeometries = blendShapeChannel->GetShapeGeometries(); + for (size_t i = 0; i < shapeGeometries.size(); i++) { + aiAnimMesh* animMesh = aiCreateAnimMesh(out_mesh); + const ShapeGeometry* shapeGeometry = shapeGeometries.at(i); + const std::vector& vertices = shapeGeometry->GetVertices(); + const std::vector& normals = shapeGeometry->GetNormals(); + const std::vector& indices = shapeGeometry->GetIndices(); + animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name())); + for (size_t j = 0; j < indices.size(); j++) { + const unsigned int o_index = indices.at(j); + //unsigned int index = translateIndexMap[indices.at(j)]; + unsigned int index = indices.at(j); + aiVector3D vertex = vertices.at(j); + aiVector3D normal = normals.at(j); + unsigned int count = 0; + const unsigned int* outIndices = mesh.ToOutputVertexIndex(index, count); + for (unsigned int k = 0; k < count; k++) { + //unsigned int index = outIndices[k]; + unsigned int index = translateIndexMap[outIndices[k]]; + + animMesh->mVertices[index] += vertex; + if (animMesh->mNormals != nullptr) { + animMesh->mNormals[index] += normal; + animMesh->mNormals[index].NormalizeSafe(); + } + } + } + animMesh->mWeight = shapeGeometries.size() > 1 ? blendShapeChannel->DeformPercent() / 100.0f : 1.0f; + animMeshes.push_back(animMesh); + } + } + } + return static_cast(meshes.size() - 1); } From 0ec5eb752cce64f98929c9d4892b144910cac0f5 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 3 Jul 2019 12:50:01 +0200 Subject: [PATCH 3/3] Update FBXConverter.cpp Removing dead and unused code. --- code/FBX/FBXConverter.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/code/FBX/FBXConverter.cpp b/code/FBX/FBXConverter.cpp index 9906fcdf8..2c72702c6 100644 --- a/code/FBX/FBXConverter.cpp +++ b/code/FBX/FBXConverter.cpp @@ -1407,15 +1407,12 @@ namespace Assimp { const std::vector& indices = shapeGeometry->GetIndices(); animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name())); for (size_t j = 0; j < indices.size(); j++) { - const unsigned int o_index = indices.at(j); - //unsigned int index = translateIndexMap[indices.at(j)]; unsigned int index = indices.at(j); aiVector3D vertex = vertices.at(j); aiVector3D normal = normals.at(j); unsigned int count = 0; const unsigned int* outIndices = mesh.ToOutputVertexIndex(index, count); for (unsigned int k = 0; k < count; k++) { - //unsigned int index = outIndices[k]; unsigned int index = translateIndexMap[outIndices[k]]; animMesh->mVertices[index] += vertex;