mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Simplification. If the normal is zero, then the cross product will also be
zero, so we can just have the one check and postpone normalization until afterwards.
This commit is contained in:
parent
6eac0ee2ae
commit
a1e208ae3d
1 changed files with 2 additions and 6 deletions
|
@ -895,16 +895,12 @@ FBXBlendshape extractBlendshape(const FBXNode& object) {
|
|||
|
||||
void setTangents(FBXMesh& mesh, int firstIndex, int secondIndex) {
|
||||
const glm::vec3& normal = mesh.normals.at(firstIndex);
|
||||
float normalLength = glm::length(normal);
|
||||
if (normalLength < EPSILON) {
|
||||
return;
|
||||
}
|
||||
glm::vec3 normalizedNormal = normal / normalLength;
|
||||
glm::vec3 bitangent = glm::cross(normalizedNormal, mesh.vertices.at(secondIndex) - mesh.vertices.at(firstIndex));
|
||||
glm::vec3 bitangent = glm::cross(normal, mesh.vertices.at(secondIndex) - mesh.vertices.at(firstIndex));
|
||||
if (glm::length(bitangent) < EPSILON) {
|
||||
return;
|
||||
}
|
||||
glm::vec2 texCoordDelta = mesh.texCoords.at(secondIndex) - mesh.texCoords.at(firstIndex);
|
||||
glm::vec3 normalizedNormal = glm::normalize(normal);
|
||||
mesh.tangents[firstIndex] += glm::cross(glm::angleAxis(-atan2f(-texCoordDelta.t, texCoordDelta.s), normalizedNormal) *
|
||||
glm::normalize(bitangent), normalizedNormal);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue