From c10acd10727d659d475bac5a743f966f78ba0f37 Mon Sep 17 00:00:00 2001
From: vpenades <5433822+vpenades@users.noreply.github.com>
Date: Thu, 25 Jul 2024 22:15:11 +0200
Subject: [PATCH] Fixed normal renormalization being triggered unnecesarily,
 reported at #243

---
 .../Geometry/VertexTypes/VertexPreprocessorLambdas.cs         | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/SharpGLTF.Toolkit/Geometry/VertexTypes/VertexPreprocessorLambdas.cs b/src/SharpGLTF.Toolkit/Geometry/VertexTypes/VertexPreprocessorLambdas.cs
index f83bb3cf..09e526db 100644
--- a/src/SharpGLTF.Toolkit/Geometry/VertexTypes/VertexPreprocessorLambdas.cs
+++ b/src/SharpGLTF.Toolkit/Geometry/VertexTypes/VertexPreprocessorLambdas.cs
@@ -161,7 +161,7 @@ static class VertexPreprocessorLambdas
                 if (n == Vector3.Zero) return null;
 
                 var l = n.Length();
-                if (l < 0.99f || l > 0.01f) vertex.SetNormal(Vector3.Normalize(n));
+                if (Math.Abs(l-1) > 0.01f) vertex.SetNormal(Vector3.Normalize(n));
             }
 
             if (vertex.TryGetTangent(out Vector4 tw))
@@ -175,7 +175,7 @@ static class VertexPreprocessorLambdas
                 if (tw.W < 0) tw.W = -1;
 
                 var l = t.Length();
-                if (l < 0.99f || l > 0.01f) t = Vector3.Normalize(t);
+                if (Math.Abs(l - 1) > 0.01f) t = Vector3.Normalize(t);
 
                 vertex.SetTangent(new Vector4(t, tw.W));
             }