diff options
author | Julien Gouesse <[email protected]> | 2021-02-05 01:38:37 +0100 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2021-02-05 01:38:37 +0100 |
commit | 46335e7a94404af90d62669e77380d9d23ef324e (patch) | |
tree | 8daf3efd896cf0dbae4ff7d8cb8a8c4cdaf077d0 | |
parent | 0180645067ad49604b9ce7055f428a1d1a53a921 (diff) |
Fixes Vector*.equals() inconsistent with hashCode()
3 files changed, 5 insertions, 3 deletions
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java b/ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java index c881f64..e73939f 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java @@ -975,7 +975,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect return false; } final ReadOnlyVector2 comp = (ReadOnlyVector2) o; - return getX() == comp.getX() && getY() == comp.getY(); + return Double.compare(getX(), comp.getX()) == 0 && Double.compare(getY(), comp.getY()) == 0; } // ///////////////// diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java b/ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java index 8c67591..7fe00c2 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java @@ -1090,7 +1090,8 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect return false; } final ReadOnlyVector3 comp = (ReadOnlyVector3) o; - return getX() == comp.getX() && getY() == comp.getY() && getZ() == comp.getZ(); + return Double.compare(getX(), comp.getX()) == 0 && Double.compare(getY(), comp.getY()) == 0 + && Double.compare(getZ(), comp.getZ()) == 0; } // ///////////////// diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java b/ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java index 2c64746..58a0541 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java @@ -1057,7 +1057,8 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect return false; } final ReadOnlyVector4 comp = (ReadOnlyVector4) o; - return getX() == comp.getX() && getY() == comp.getY() && getZ() == comp.getZ() && getW() == comp.getW(); + return Double.compare(getX(), comp.getX()) == 0 && Double.compare(getY(), comp.getY()) == 0 + && Double.compare(getZ(), comp.getZ()) == 0 && Double.compare(getW(), comp.getW()) == 0; } // ///////////////// |