From 1545ca219d349cd24bafc57c6989cf5a72433042 Mon Sep 17 00:00:00 2001 From: Winson Han Date: Thu, 3 Oct 2024 16:23:54 -0700 Subject: [PATCH] Update UtilityFunctions.cs allowing epsilon to be parameterized, default to Unity's Vector3.kEpsilon, which apparently is built into the Vector3 class specifically because Unity's representation of floats is the 32-bit variety and that epsilon value is tuned for that??? So seems like a good default still --- unity/Assets/Scripts/UtilityFunctions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unity/Assets/Scripts/UtilityFunctions.cs b/unity/Assets/Scripts/UtilityFunctions.cs index c05a2cba83..10d14ea27d 100644 --- a/unity/Assets/Scripts/UtilityFunctions.cs +++ b/unity/Assets/Scripts/UtilityFunctions.cs @@ -484,11 +484,11 @@ public static List GetLightPropertiesOfScene() { return allOfTheLights; } - public static bool ArePositionsApproximatelyEqual(Vector3 position1, Vector3 position2) { + public static bool ArePositionsApproximatelyEqual(Vector3 position1, Vector3 position2, float epsilon = Vector3.kEpsilon) { // Compare each component (x, y, z) of the two positions to see if they are approximately equal via the epsilon value - return Mathf.Abs(position1.x - position2.x) < Vector3.kEpsilon - && Mathf.Abs(position1.y - position2.y) < Vector3.kEpsilon - && Mathf.Abs(position1.z - position2.z) < Vector3.kEpsilon; + return Mathf.Abs(position1.x - position2.x) < epsilon + && Mathf.Abs(position1.y - position2.y) < epsilon + && Mathf.Abs(position1.z - position2.z) < epsilon; } #if UNITY_EDITOR