diff --git a/src/main/java/org/joml/Matrix2d.java b/src/main/java/org/joml/Matrix2d.java index 34dd137e..b5ec150d 100644 --- a/src/main/java/org/joml/Matrix2d.java +++ b/src/main/java/org/joml/Matrix2d.java @@ -277,7 +277,9 @@ Matrix2d _m11(double m11) { * @return this */ public Matrix2d set(Matrix2dc m) { - if (m instanceof Matrix2d) { + if (m == this) + return this; + else if (m instanceof Matrix2d) { MemUtil.INSTANCE.copy((Matrix2d) m, this); } else { setMatrix2dc(m); diff --git a/src/main/java/org/joml/Matrix2f.java b/src/main/java/org/joml/Matrix2f.java index d300cec4..b5749aa5 100644 --- a/src/main/java/org/joml/Matrix2f.java +++ b/src/main/java/org/joml/Matrix2f.java @@ -250,7 +250,9 @@ Matrix2f _m11(float m11) { * @return this */ public Matrix2f set(Matrix2fc m) { - if (m instanceof Matrix2f) { + if (m == this) + return this; + else if (m instanceof Matrix2f) { MemUtil.INSTANCE.copy((Matrix2f) m, this); } else { setMatrix2fc(m); diff --git a/src/main/java/org/joml/Matrix3d.java b/src/main/java/org/joml/Matrix3d.java index 9372b4b8..7a753ce0 100644 --- a/src/main/java/org/joml/Matrix3d.java +++ b/src/main/java/org/joml/Matrix3d.java @@ -428,6 +428,8 @@ Matrix3d _m22(double m22) { * @return this */ public Matrix3d set(Matrix3dc m) { + if (m == this) + return this; m00 = m.m00(); m01 = m.m01(); m02 = m.m02(); diff --git a/src/main/java/org/joml/Matrix3f.java b/src/main/java/org/joml/Matrix3f.java index d8923eb9..32319d5d 100644 --- a/src/main/java/org/joml/Matrix3f.java +++ b/src/main/java/org/joml/Matrix3f.java @@ -397,6 +397,8 @@ Matrix3f _m22(float m22) { * @return this */ public Matrix3f set(Matrix3fc m) { + if (m == this) + return this; return _m00(m.m00()). _m01(m.m01()). diff --git a/src/main/java/org/joml/Matrix3x2d.java b/src/main/java/org/joml/Matrix3x2d.java index 90a7f947..3a5b1cf9 100644 --- a/src/main/java/org/joml/Matrix3x2d.java +++ b/src/main/java/org/joml/Matrix3x2d.java @@ -242,7 +242,9 @@ Matrix3x2d _m21(double m21) { * @return this */ public Matrix3x2d set(Matrix3x2dc m) { - if (m instanceof Matrix3x2d) { + if (m == this) + return this; + else if (m instanceof Matrix3x2d) { MemUtil.INSTANCE.copy((Matrix3x2d) m, this); } else { setMatrix3x2dc(m); diff --git a/src/main/java/org/joml/Matrix3x2f.java b/src/main/java/org/joml/Matrix3x2f.java index 0e0f8059..2d3c6719 100644 --- a/src/main/java/org/joml/Matrix3x2f.java +++ b/src/main/java/org/joml/Matrix3x2f.java @@ -227,7 +227,9 @@ Matrix3x2f _m21(float m21) { * @return this */ public Matrix3x2f set(Matrix3x2fc m) { - if (m instanceof Matrix3x2f) { + if (m == this) + return this; + else if (m instanceof Matrix3x2f) { MemUtil.INSTANCE.copy((Matrix3x2f) m, this); } else { setMatrix3x2fc(m); diff --git a/src/main/java/org/joml/Matrix4d.java b/src/main/java/org/joml/Matrix4d.java index d7d4b488..8fc1a282 100644 --- a/src/main/java/org/joml/Matrix4d.java +++ b/src/main/java/org/joml/Matrix4d.java @@ -788,6 +788,8 @@ private void _identity() { * @return this */ public Matrix4d set(Matrix4dc m) { + if (m == this) + return this; return _m00(m.m00()). _m01(m.m01()). @@ -8984,8 +8986,7 @@ else if ((properties & PROPERTY_ORTHONORMAL) != 0) return normalGeneric(dest); } private Matrix4d normalOrthonormal(Matrix4d dest) { - if (dest != this) - dest.set(this); + dest.set(this); return dest._properties(PROPERTY_AFFINE | PROPERTY_ORTHONORMAL); } private Matrix4d normalGeneric(Matrix4d dest) { diff --git a/src/main/java/org/joml/Matrix4f.java b/src/main/java/org/joml/Matrix4f.java index 6e43d0b7..2068637e 100644 --- a/src/main/java/org/joml/Matrix4f.java +++ b/src/main/java/org/joml/Matrix4f.java @@ -777,6 +777,8 @@ public Matrix4f identity() { * @return this */ public Matrix4f set(Matrix4fc m) { + if (m == this) + return this; //#ifdef __HAS_JVMCI__ if (JvmciCode.canUseJvmci && m instanceof Matrix4f) { JvmciCode.__Matrix4f_set((Matrix4f) m, this); @@ -12766,8 +12768,7 @@ else if ((properties & PROPERTY_ORTHONORMAL) != 0) return normalGeneric(dest); } private Matrix4f normalOrthonormal(Matrix4f dest) { - if (dest != this) - dest.set(this); + dest.set(this); return dest._properties(PROPERTY_AFFINE | PROPERTY_ORTHONORMAL); } private Matrix4f normalGeneric(Matrix4f dest) { diff --git a/src/main/java/org/joml/Matrix4x3d.java b/src/main/java/org/joml/Matrix4x3d.java index ba53d0f7..3c690108 100644 --- a/src/main/java/org/joml/Matrix4x3d.java +++ b/src/main/java/org/joml/Matrix4x3d.java @@ -609,6 +609,8 @@ public Matrix4x3d identity() { * @return this */ public Matrix4x3d set(Matrix4x3dc m) { + if (m == this) + return this; m00 = m.m00(); m01 = m.m01(); m02 = m.m02(); diff --git a/src/main/java/org/joml/Matrix4x3f.java b/src/main/java/org/joml/Matrix4x3f.java index 6af56b44..4d77db92 100644 --- a/src/main/java/org/joml/Matrix4x3f.java +++ b/src/main/java/org/joml/Matrix4x3f.java @@ -596,6 +596,8 @@ public Matrix4x3f identity() { * @return this */ public Matrix4x3f set(Matrix4x3fc m) { + if (m == this) + return this; m00 = m.m00(); m01 = m.m01(); m02 = m.m02(); @@ -7741,8 +7743,7 @@ else if ((properties & PROPERTY_ORTHONORMAL) != 0) return normalGeneric(dest); } private Matrix4x3f normalOrthonormal(Matrix4x3f dest) { - if (dest != this) - dest.set(this); + dest.set(this); return dest._properties(PROPERTY_ORTHONORMAL); } private Matrix4x3f normalGeneric(Matrix4x3f dest) { diff --git a/src/main/java/org/joml/Vector3d.java b/src/main/java/org/joml/Vector3d.java index 1480171e..7f1a5a97 100644 --- a/src/main/java/org/joml/Vector3d.java +++ b/src/main/java/org/joml/Vector3d.java @@ -350,6 +350,8 @@ public Vector3d set(Vector4ic v) { * @return this */ public Vector3d set(Vector3dc v) { + if (v == this) + return this; this.x = v.x(); this.y = v.y(); this.z = v.z(); diff --git a/src/main/java/org/joml/Vector3f.java b/src/main/java/org/joml/Vector3f.java index 4bd52db1..fd610b2e 100644 --- a/src/main/java/org/joml/Vector3f.java +++ b/src/main/java/org/joml/Vector3f.java @@ -326,6 +326,8 @@ public Vector3f set(Vector4ic v) { * @return this */ public Vector3f set(Vector3fc v) { + if (v == this) + return this; this.x = v.x(); this.y = v.y(); this.z = v.z(); diff --git a/src/main/java/org/joml/Vector4d.java b/src/main/java/org/joml/Vector4d.java index 1730d234..50833e13 100644 --- a/src/main/java/org/joml/Vector4d.java +++ b/src/main/java/org/joml/Vector4d.java @@ -383,6 +383,8 @@ public double w() { * @return this */ public Vector4d set(Vector4dc v) { + if (v == this) + return this; this.x = v.x(); this.y = v.y(); this.z = v.z(); diff --git a/src/main/java/org/joml/Vector4f.java b/src/main/java/org/joml/Vector4f.java index 943f434b..3ba6c361 100644 --- a/src/main/java/org/joml/Vector4f.java +++ b/src/main/java/org/joml/Vector4f.java @@ -342,6 +342,8 @@ public float w() { * @return this */ public Vector4f set(Vector4fc v) { + if (v == this) + return this; this.x = v.x(); this.y = v.y(); this.z = v.z();