mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 21:03:17 +02:00
Merge pull request #15609 from sabrina-shanman/crash_hfm_tangents
(BUGZ-298) Fix crash calculating tangents without texcoords
This commit is contained in:
commit
19503d45ab
2 changed files with 4 additions and 4 deletions
|
@ -42,8 +42,8 @@ void CalculateBlendshapeTangentsTask::run(const baker::BakeContextPointer& conte
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we can and should calculate tangents (we need normals to calculate the tangents)
|
// Check if we can calculate tangents (we need normals and texcoords to calculate the tangents)
|
||||||
if (normals.empty()) {
|
if (normals.empty() || normals.size() != (size_t)mesh.texCoords.size()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tangentsOut.resize(normals.size());
|
tangentsOut.resize(normals.size());
|
||||||
|
|
|
@ -27,10 +27,10 @@ void CalculateMeshTangentsTask::run(const baker::BakeContextPointer& context, co
|
||||||
auto& tangentsOut = tangentsPerMeshOut[tangentsPerMeshOut.size()-1];
|
auto& tangentsOut = tangentsPerMeshOut[tangentsPerMeshOut.size()-1];
|
||||||
|
|
||||||
// Check if we already have tangents and therefore do not need to do any calculation
|
// 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()) {
|
if (!tangentsIn.empty()) {
|
||||||
tangentsOut = tangentsIn.toStdVector();
|
tangentsOut = tangentsIn.toStdVector();
|
||||||
} else if (!normals.empty()) {
|
} else if (!normals.empty() && mesh.vertices.size() == mesh.texCoords.size()) {
|
||||||
tangentsOut.resize(normals.size());
|
tangentsOut.resize(normals.size());
|
||||||
baker::calculateTangents(mesh,
|
baker::calculateTangents(mesh,
|
||||||
[&mesh, &normals, &tangentsOut](int firstIndex, int secondIndex, glm::vec3* outVertices, glm::vec2* outTexCoords, glm::vec3& outNormal) {
|
[&mesh, &normals, &tangentsOut](int firstIndex, int secondIndex, glm::vec3* outVertices, glm::vec2* outTexCoords, glm::vec3& outNormal) {
|
||||||
|
|
Loading…
Reference in a new issue