Merge branch 'master' into kimkulling_dev
commit
ae7b1f1a77
|
@ -1255,7 +1255,7 @@ namespace Assimp {
|
||||||
|
|
||||||
// mapping from output indices to DOM indexing, needed to resolve weights
|
// mapping from output indices to DOM indexing, needed to resolve weights
|
||||||
std::vector<unsigned int> reverseMapping;
|
std::vector<unsigned int> reverseMapping;
|
||||||
|
std::map<unsigned int, unsigned int> translateIndexMap;
|
||||||
if (process_weights) {
|
if (process_weights) {
|
||||||
reverseMapping.resize(count_vertices);
|
reverseMapping.resize(count_vertices);
|
||||||
}
|
}
|
||||||
|
@ -1363,6 +1363,7 @@ namespace Assimp {
|
||||||
|
|
||||||
if (reverseMapping.size()) {
|
if (reverseMapping.size()) {
|
||||||
reverseMapping[cursor] = in_cursor;
|
reverseMapping[cursor] = in_cursor;
|
||||||
|
translateIndexMap[in_cursor] = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_mesh->mVertices[cursor] = vertices[in_cursor];
|
out_mesh->mVertices[cursor] = vertices[in_cursor];
|
||||||
|
@ -1394,6 +1395,39 @@ namespace Assimp {
|
||||||
ConvertWeights(out_mesh, model, mesh, node_global_transform, index, &reverseMapping);
|
ConvertWeights(out_mesh, model, mesh, node_global_transform, index, &reverseMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<aiAnimMesh*> animMeshes;
|
||||||
|
for (const BlendShape* blendShape : mesh.GetBlendShapes()) {
|
||||||
|
for (const BlendShapeChannel* blendShapeChannel : blendShape->BlendShapeChannels()) {
|
||||||
|
const std::vector<const ShapeGeometry*>& 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<aiVector3D>& vertices = shapeGeometry->GetVertices();
|
||||||
|
const std::vector<aiVector3D>& normals = shapeGeometry->GetNormals();
|
||||||
|
const std::vector<unsigned int>& indices = shapeGeometry->GetIndices();
|
||||||
|
animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name()));
|
||||||
|
for (size_t j = 0; j < indices.size(); 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 = 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<unsigned int>(meshes.size() - 1);
|
return static_cast<unsigned int>(meshes.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,14 @@ struct aiColor3D
|
||||||
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
|
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
|
||||||
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
|
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?
|
// TODO: add epsilon?
|
||||||
bool operator == (const aiColor3D& other) const
|
bool operator == (const aiColor3D& other) const
|
||||||
{return r == other.r && g == other.g && b == other.b;}
|
{return r == other.r && g == other.g && b == other.b;}
|
||||||
|
|
Loading…
Reference in New Issue