Merge pull request #15609 from sabrina-shanman/crash_hfm_tangents

(BUGZ-298) Fix crash calculating tangents without texcoords
This commit is contained in:
Shannon Romano 2019-05-22 13:36:44 -07:00 committed by GitHub
commit 19503d45ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -42,8 +42,8 @@ void CalculateBlendshapeTangentsTask::run(const baker::BakeContextPointer& conte
continue;
}
// Check if we can and should calculate tangents (we need normals to calculate the tangents)
if (normals.empty()) {
// Check if we can calculate tangents (we need normals and texcoords to calculate the tangents)
if (normals.empty() || normals.size() != (size_t)mesh.texCoords.size()) {
continue;
}
tangentsOut.resize(normals.size());

View file

@ -27,10 +27,10 @@ void CalculateMeshTangentsTask::run(const baker::BakeContextPointer& context, co
auto& tangentsOut = tangentsPerMeshOut[tangentsPerMeshOut.size()-1];
// Check if we already have tangents and therefore do not need to do any calculation
// Otherwise confirm if we have the normals needed, and need to calculate the tangents
// Otherwise confirm if we have the normals and texcoords needed
if (!tangentsIn.empty()) {
tangentsOut = tangentsIn.toStdVector();
} else if (!normals.empty()) {
} else if (!normals.empty() && mesh.vertices.size() == mesh.texCoords.size()) {
tangentsOut.resize(normals.size());
baker::calculateTangents(mesh,
[&mesh, &normals, &tangentsOut](int firstIndex, int secondIndex, glm::vec3* outVertices, glm::vec2* outTexCoords, glm::vec3& outNormal) {