Fix crash calculating tangents without texcoords

This commit is contained in:
sabrina-shanman 2019-05-22 11:57:08 -07:00
parent 930018a924
commit 3849450c66
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) {