FBX Blendshapes: Do not require normals

Some blendshapes don't have normal transformations, but Assimp currently requires that normals
be present. This removes that, and won't populate the normal field.
pull/5776/head
julianknodt 2024-09-09 18:24:05 -07:00
parent 4024726eca
commit a4be5aac0b
2 changed files with 11 additions and 8 deletions

View File

@ -1250,9 +1250,9 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
for (const BlendShapeChannel *blendShapeChannel : blendShape->BlendShapeChannels()) {
const auto& shapeGeometries = blendShapeChannel->GetShapeGeometries();
for (const ShapeGeometry *shapeGeometry : shapeGeometries) {
aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh);
const auto &curVertices = shapeGeometry->GetVertices();
const auto &curNormals = shapeGeometry->GetNormals();
aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh, true, !curNormals.empty());
const auto &curVertices = shapeGeometry->GetVertices();
const auto &curIndices = shapeGeometry->GetIndices();
//losing channel name if using shapeGeometry->Name()
// if blendShapeChannel Name is empty or doesn't have a ".", add geoMetryName;
@ -1268,7 +1268,7 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
for (size_t j = 0; j < curIndices.size(); j++) {
const unsigned int curIndex = curIndices.at(j);
aiVector3D vertex = curVertices.at(j);
aiVector3D normal = curNormals.at(j);
aiVector3D normal = curNormals.empty() ? aiVector3D() : curNormals.at(j);
unsigned int count = 0;
const unsigned int *outIndices = mesh.ToOutputVertexIndex(curIndex, count);
for (unsigned int k = 0; k < count; k++) {
@ -1488,15 +1488,15 @@ unsigned int FBXConverter::ConvertMeshMultiMaterial(const MeshGeometry &mesh, co
for (const BlendShapeChannel *blendShapeChannel : blendShape->BlendShapeChannels()) {
const auto& shapeGeometries = blendShapeChannel->GetShapeGeometries();
for (const ShapeGeometry *shapeGeometry : shapeGeometries) {
aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh);
const auto& curVertices = shapeGeometry->GetVertices();
const auto& curNormals = shapeGeometry->GetNormals();
aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh, true, !curNormals.empty());
const auto& curVertices = shapeGeometry->GetVertices();
const auto& curIndices = shapeGeometry->GetIndices();
animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name()));
for (size_t j = 0; j < curIndices.size(); j++) {
unsigned int curIndex = curIndices.at(j);
aiVector3D vertex = curVertices.at(j);
aiVector3D normal = curNormals.at(j);
aiVector3D normal = curNormals.empty() ? aiVector3D() : curNormals.at(j);
unsigned int count = 0;
const unsigned int *outIndices = mesh.ToOutputVertexIndex(curIndex, count);
for (unsigned int k = 0; k < count; k++) {

View File

@ -685,11 +685,14 @@ ShapeGeometry::ShapeGeometry(uint64_t id, const Element& element, const std::str
DOMError("failed to read Geometry object (class: Shape), no data scope found");
}
const Element& Indexes = GetRequiredElement(*sc, "Indexes", &element);
const Element& Normals = GetRequiredElement(*sc, "Normals", &element);
const Element& Vertices = GetRequiredElement(*sc, "Vertices", &element);
ParseVectorDataArray(m_indices, Indexes);
ParseVectorDataArray(m_vertices, Vertices);
if ((*sc)["Normals"]) {
const Element& Normals = GetRequiredElement(*sc, "Normals", &element);
ParseVectorDataArray(m_normals, Normals);
}
}
// ------------------------------------------------------------------------------------------------