aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2021-02-05 01:38:37 +0100
committerJulien Gouesse <[email protected]>2021-02-05 01:38:37 +0100
commit46335e7a94404af90d62669e77380d9d23ef324e (patch)
tree8daf3efd896cf0dbae4ff7d8cb8a8c4cdaf077d0
parent0180645067ad49604b9ce7055f428a1d1a53a921 (diff)
Fixes Vector*.equals() inconsistent with hashCode()
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java2
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java3
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java3
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;
}
// /////////////////