fix for div by zero reported by address sanitizer
parent
812397d681
commit
f69bf5f7ed
|
@ -212,7 +212,7 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
|
||||||
// project tangent and bitangent into the plane formed by the vertex' normal
|
// project tangent and bitangent into the plane formed by the vertex' normal
|
||||||
aiVector3D localTangent = tangent - meshNorm[p] * (tangent * meshNorm[p]);
|
aiVector3D localTangent = tangent - meshNorm[p] * (tangent * meshNorm[p]);
|
||||||
aiVector3D localBitangent = bitangent - meshNorm[p] * (bitangent * meshNorm[p]);
|
aiVector3D localBitangent = bitangent - meshNorm[p] * (bitangent * meshNorm[p]);
|
||||||
localTangent.Normalize(); localBitangent.Normalize();
|
localTangent.NormalizeSafe(); localBitangent.NormalizeSafe();
|
||||||
|
|
||||||
// reconstruct tangent/bitangent according to normal and bitangent/tangent when it's infinite or NaN.
|
// reconstruct tangent/bitangent according to normal and bitangent/tangent when it's infinite or NaN.
|
||||||
bool invalid_tangent = is_special_float(localTangent.x) || is_special_float(localTangent.y) || is_special_float(localTangent.z);
|
bool invalid_tangent = is_special_float(localTangent.x) || is_special_float(localTangent.y) || is_special_float(localTangent.z);
|
||||||
|
@ -220,10 +220,10 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
|
||||||
if (invalid_tangent != invalid_bitangent) {
|
if (invalid_tangent != invalid_bitangent) {
|
||||||
if (invalid_tangent) {
|
if (invalid_tangent) {
|
||||||
localTangent = meshNorm[p] ^ localBitangent;
|
localTangent = meshNorm[p] ^ localBitangent;
|
||||||
localTangent.Normalize();
|
localTangent.NormalizeSafe();
|
||||||
} else {
|
} else {
|
||||||
localBitangent = localTangent ^ meshNorm[p];
|
localBitangent = localTangent ^ meshNorm[p];
|
||||||
localBitangent.Normalize();
|
localBitangent.NormalizeSafe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue