Skip to content

Commit

Permalink
Update UtilityFunctions.cs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
winthos committed Oct 3, 2024
1 parent 5bf2d3e commit 1545ca2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions unity/Assets/Scripts/UtilityFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,11 @@ public static List<LightParameters> 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
Expand Down

0 comments on commit 1545ca2

Please sign in to comment.