From cbc7dac0d524489345f4311d8e7a6ac467718379 Mon Sep 17 00:00:00 2001 From: Joyless <65855333+Joy-less@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:53:38 +0100 Subject: [PATCH] Improve `IsNormalized()` --- modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs | 2 +- modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs | 2 +- modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs | 2 +- modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs index 334e35a4645..aaf8d9acaeb 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs @@ -338,7 +338,7 @@ namespace Godot /// A for whether the quaternion is normalized or not. public readonly bool IsNormalized() { - return Mathf.Abs(LengthSquared() - 1) <= Mathf.Epsilon; + return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon); } public readonly Quaternion Log() diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index f5b64ff81b8..6b32efbe091 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -370,7 +370,7 @@ namespace Godot /// A indicating whether or not the vector is normalized. public readonly bool IsNormalized() { - return Mathf.Abs(LengthSquared() - 1.0f) < Mathf.Epsilon; + return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon); } /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index eb5105ea6c1..033b225a0c0 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -368,7 +368,7 @@ namespace Godot /// A indicating whether or not the vector is normalized. public readonly bool IsNormalized() { - return Mathf.Abs(LengthSquared() - 1.0f) < Mathf.Epsilon; + return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon); } /// diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs index ec59197fa33..5985ea05591 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs @@ -318,7 +318,7 @@ namespace Godot /// A indicating whether or not the vector is normalized. public readonly bool IsNormalized() { - return Mathf.Abs(LengthSquared() - 1.0f) < Mathf.Epsilon; + return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon); } ///