From 7fd5da7d2c36c6a9d2383ab52815de020532b94e Mon Sep 17 00:00:00 2001 From: httpdigest Date: Sat, 20 Feb 2021 18:57:15 +0100 Subject: [PATCH] Add Matrix.set(int, Buffer) (#281) --- src/org/joml/Matrix2d.java | 38 ++++++++++++++++++ src/org/joml/Matrix2f.java | 38 ++++++++++++++++++ src/org/joml/Matrix3d.java | 74 +++++++++++++++++++++++++++++++++++ src/org/joml/Matrix3f.java | 38 ++++++++++++++++++ src/org/joml/Matrix3x2d.java | 38 ++++++++++++++++++ src/org/joml/Matrix3x2f.java | 44 +++++++++++++++++++-- src/org/joml/Matrix4d.java | 76 ++++++++++++++++++++++++++++++++++++ src/org/joml/Matrix4f.java | 38 ++++++++++++++++++ src/org/joml/Matrix4x3d.java | 76 ++++++++++++++++++++++++++++++++++++ src/org/joml/Matrix4x3f.java | 38 ++++++++++++++++++ 10 files changed, 494 insertions(+), 4 deletions(-) diff --git a/src/org/joml/Matrix2d.java b/src/org/joml/Matrix2d.java index 1fce804f..6a6fc327 100644 --- a/src/org/joml/Matrix2d.java +++ b/src/org/joml/Matrix2d.java @@ -742,6 +742,44 @@ public Matrix2d set(ByteBuffer buffer) { MemUtil.INSTANCE.get(this, buffer.position(), buffer); return this; } + + /** + * Set the values of this matrix by reading 4 double values from the given {@link DoubleBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The DoubleBuffer is expected to contain the values in column-major order. + *

+ * The position of the DoubleBuffer will not be changed by this method. + * + * @param index + * the absolute position into the DoubleBuffer + * @param buffer + * the DoubleBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix2d set(int index, DoubleBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } + + /** + * Set the values of this matrix by reading 4 double values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix2d set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } //#endif //#ifdef __HAS_UNSAFE__ /** diff --git a/src/org/joml/Matrix2f.java b/src/org/joml/Matrix2f.java index a26b6c27..1bc1d251 100644 --- a/src/org/joml/Matrix2f.java +++ b/src/org/joml/Matrix2f.java @@ -642,6 +642,44 @@ public Matrix2f set(ByteBuffer buffer) { MemUtil.INSTANCE.get(this, buffer.position(), buffer); return this; } + + /** + * Set the values of this matrix by reading 4 float values from the given {@link FloatBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The FloatBuffer is expected to contain the values in column-major order. + *

+ * The position of the FloatBuffer will not be changed by this method. + * + * @param index + * the absolute position into the FloatBuffer + * @param buffer + * the FloatBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix2f set(int index, FloatBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } + + /** + * Set the values of this matrix by reading 4 float values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix2f set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } //#endif //#ifdef __HAS_UNSAFE__ diff --git a/src/org/joml/Matrix3d.java b/src/org/joml/Matrix3d.java index 1de9c90a..b549fd2b 100644 --- a/src/org/joml/Matrix3d.java +++ b/src/org/joml/Matrix3d.java @@ -1201,6 +1201,80 @@ public Matrix3d setFloats(ByteBuffer buffer) { MemUtil.INSTANCE.getf(this, buffer.position(), buffer); return this; } + + /** + * Set the values of this matrix by reading 9 double values from the given {@link DoubleBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The DoubleBuffer is expected to contain the values in column-major order. + *

+ * The position of the DoubleBuffer will not be changed by this method. + * + * @param index + * the absolute position into the DoubleBuffer + * @param buffer + * the DoubleBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3d set(int index, DoubleBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } + + /** + * Set the values of this matrix by reading 9 float values from the given {@link FloatBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The FloatBuffer is expected to contain the values in column-major order. + *

+ * The position of the FloatBuffer will not be changed by this method. + * + * @param index + * the absolute position into the FloatBuffer + * @param buffer + * the FloatBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3d set(int index, FloatBuffer buffer) { + MemUtil.INSTANCE.getf(this, index, buffer); + return this; + } + + /** + * Set the values of this matrix by reading 9 double values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3d set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } + + /** + * Set the values of this matrix by reading 9 float values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3d setFloats(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.getf(this, index, buffer); + return this; + } //#endif //#ifdef __HAS_UNSAFE__ /** diff --git a/src/org/joml/Matrix3f.java b/src/org/joml/Matrix3f.java index a3b42e60..04481732 100644 --- a/src/org/joml/Matrix3f.java +++ b/src/org/joml/Matrix3f.java @@ -1049,6 +1049,44 @@ public Matrix3f set(ByteBuffer buffer) { MemUtil.INSTANCE.get(this, buffer.position(), buffer); return this; } + + /** + * Set the values of this matrix by reading 9 float values from the given {@link FloatBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The FloatBuffer is expected to contain the values in column-major order. + *

+ * The position of the FloatBuffer will not be changed by this method. + * + * @param index + * the absolute position into the FloatBuffer + * @param buffer + * the FloatBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3f set(int index, FloatBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } + + /** + * Set the values of this matrix by reading 9 float values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3f set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } //#endif //#ifdef __HAS_UNSAFE__ /** diff --git a/src/org/joml/Matrix3x2d.java b/src/org/joml/Matrix3x2d.java index 9103e2a3..30d5bfce 100644 --- a/src/org/joml/Matrix3x2d.java +++ b/src/org/joml/Matrix3x2d.java @@ -1197,6 +1197,44 @@ public Matrix3x2d set(ByteBuffer buffer) { MemUtil.INSTANCE.get(this, pos, buffer); return this; } + + /** + * Set the values of this matrix by reading 6 double values from the given {@link DoubleBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The DoubleBuffer is expected to contain the values in column-major order. + *

+ * The position of the DoubleBuffer will not be changed by this method. + * + * @param index + * the absolute position into the DoubleBuffer + * @param buffer + * the DoubleBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3x2d set(int index, DoubleBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } + + /** + * Set the values of this matrix by reading 6 double values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3x2d set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } //#endif //#ifdef __HAS_UNSAFE__ /** diff --git a/src/org/joml/Matrix3x2f.java b/src/org/joml/Matrix3x2f.java index 90756f8c..7ae72d6b 100644 --- a/src/org/joml/Matrix3x2f.java +++ b/src/org/joml/Matrix3x2f.java @@ -1145,8 +1145,7 @@ public float[] get4x4(float[] arr) { * @return this */ public Matrix3x2f set(FloatBuffer buffer) { - int pos = buffer.position(); - MemUtil.INSTANCE.get(this, pos, buffer); + MemUtil.INSTANCE.get(this, buffer.position(), buffer); return this; } @@ -1163,8 +1162,45 @@ public Matrix3x2f set(FloatBuffer buffer) { * @return this */ public Matrix3x2f set(ByteBuffer buffer) { - int pos = buffer.position(); - MemUtil.INSTANCE.get(this, pos, buffer); + MemUtil.INSTANCE.get(this, buffer.position(), buffer); + return this; + } + + /** + * Set the values of this matrix by reading 6 float values from the given {@link FloatBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The FloatBuffer is expected to contain the values in column-major order. + *

+ * The position of the FloatBuffer will not be changed by this method. + * + * @param index + * the absolute position into the FloatBuffer + * @param buffer + * the FloatBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3x2f set(int index, FloatBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return this; + } + + /** + * Set the values of this matrix by reading 6 float values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix3x2f set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); return this; } //#endif diff --git a/src/org/joml/Matrix4d.java b/src/org/joml/Matrix4d.java index c9f8aff3..fcb0a673 100644 --- a/src/org/joml/Matrix4d.java +++ b/src/org/joml/Matrix4d.java @@ -2640,6 +2640,63 @@ public Matrix4d set(ByteBuffer buffer) { return determineProperties(); } + /** + * Set the values of this matrix by reading 16 double values from the given {@link DoubleBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The DoubleBuffer is expected to contain the values in column-major order. + *

+ * The position of the DoubleBuffer will not be changed by this method. + * + * @param index + * the absolute position into the DoubleBuffer + * @param buffer + * the DoubleBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4d set(int index, DoubleBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return determineProperties(); + } + + /** + * Set the values of this matrix by reading 16 float values from the given {@link FloatBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The FloatBuffer is expected to contain the values in column-major order. + *

+ * The position of the FloatBuffer will not be changed by this method. + * + * @param index + * the absolute position into the FloatBuffer + * @param buffer + * the FloatBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4d set(int index, FloatBuffer buffer) { + MemUtil.INSTANCE.getf(this, index, buffer); + return determineProperties(); + } + + /** + * Set the values of this matrix by reading 16 double values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4d set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return determineProperties(); + } + /** * Set the values of this matrix by reading 16 float values from the given {@link ByteBuffer} in column-major order, * starting at its current position. @@ -2656,6 +2713,25 @@ public Matrix4d setFloats(ByteBuffer buffer) { MemUtil.INSTANCE.getf(this, buffer.position(), buffer); return determineProperties(); } + + /** + * Set the values of this matrix by reading 16 float values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4d setFloats(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.getf(this, index, buffer); + return determineProperties(); + } //#endif //#ifdef __HAS_UNSAFE__ diff --git a/src/org/joml/Matrix4f.java b/src/org/joml/Matrix4f.java index e50bd833..08c67bb6 100644 --- a/src/org/joml/Matrix4f.java +++ b/src/org/joml/Matrix4f.java @@ -2362,6 +2362,44 @@ public Matrix4f set(ByteBuffer buffer) { return determineProperties(); } + /** + * Set the values of this matrix by reading 16 float values from the given {@link FloatBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The FloatBuffer is expected to contain the values in column-major order. + *

+ * The position of the FloatBuffer will not be changed by this method. + * + * @param index + * the absolute position into the FloatBuffer + * @param buffer + * the FloatBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4f set(int index, FloatBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return determineProperties(); + } + + /** + * Set the values of this matrix by reading 16 float values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4f set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return determineProperties(); + } + /** * Set the values of this matrix by reading 16 float values from the given {@link FloatBuffer} in row-major order, * starting at its current position. diff --git a/src/org/joml/Matrix4x3d.java b/src/org/joml/Matrix4x3d.java index f1dd0429..f8447f8a 100644 --- a/src/org/joml/Matrix4x3d.java +++ b/src/org/joml/Matrix4x3d.java @@ -1487,6 +1487,63 @@ public Matrix4x3d set(ByteBuffer buffer) { return determineProperties(); } + /** + * Set the values of this matrix by reading 12 double values from the given {@link DoubleBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The DoubleBuffer is expected to contain the values in column-major order. + *

+ * The position of the DoubleBuffer will not be changed by this method. + * + * @param index + * the absolute position into the DoubleBuffer + * @param buffer + * the DoubleBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4x3d set(int index, DoubleBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return determineProperties(); + } + + /** + * Set the values of this matrix by reading 12 float values from the given {@link FloatBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The FloatBuffer is expected to contain the values in column-major order. + *

+ * The position of the FloatBuffer will not be changed by this method. + * + * @param index + * the absolute position into the FloatBuffer + * @param buffer + * the FloatBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4x3d set(int index, FloatBuffer buffer) { + MemUtil.INSTANCE.getf(this, index, buffer); + return determineProperties(); + } + + /** + * Set the values of this matrix by reading 12 double values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4x3d set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return determineProperties(); + } + /** * Set the values of this matrix by reading 12 float values from the given {@link ByteBuffer} in column-major order, * starting at its current position. @@ -1503,6 +1560,25 @@ public Matrix4x3d setFloats(ByteBuffer buffer) { MemUtil.INSTANCE.getf(this, buffer.position(), buffer); return determineProperties(); } + + /** + * Set the values of this matrix by reading 12 float values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4x3d setFloats(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.getf(this, buffer.position(), buffer); + return determineProperties(); + } //#endif //#ifdef __HAS_UNSAFE__ diff --git a/src/org/joml/Matrix4x3f.java b/src/org/joml/Matrix4x3f.java index 977fd239..c0c0605b 100644 --- a/src/org/joml/Matrix4x3f.java +++ b/src/org/joml/Matrix4x3f.java @@ -1213,6 +1213,44 @@ public Matrix4x3f set(ByteBuffer buffer) { MemUtil.INSTANCE.get(this, buffer.position(), buffer); return determineProperties(); } + + /** + * Set the values of this matrix by reading 12 float values from the given {@link FloatBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The FloatBuffer is expected to contain the values in column-major order. + *

+ * The position of the FloatBuffer will not be changed by this method. + * + * @param index + * the absolute position into the FloatBuffer + * @param buffer + * the FloatBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4x3f set(int index, FloatBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return determineProperties(); + } + + /** + * Set the values of this matrix by reading 12 float values from the given {@link ByteBuffer} in column-major order, + * starting at the specified absolute buffer position/index. + *

+ * The ByteBuffer is expected to contain the values in column-major order. + *

+ * The position of the ByteBuffer will not be changed by this method. + * + * @param index + * the absolute position into the ByteBuffer + * @param buffer + * the ByteBuffer to read the matrix values from in column-major order + * @return this + */ + public Matrix4x3f set(int index, ByteBuffer buffer) { + MemUtil.INSTANCE.get(this, index, buffer); + return determineProperties(); + } //#endif //#ifdef __HAS_UNSAFE__ /**