Skip to content

Commit

Permalink
Add Matrix.set(int, Buffer) (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
httpdigest committed Feb 20, 2021
1 parent b527ac5 commit 7fd5da7
Show file tree
Hide file tree
Showing 10 changed files with 494 additions and 4 deletions.
38 changes: 38 additions & 0 deletions src/org/joml/Matrix2d.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* The DoubleBuffer is expected to contain the values in column-major order.
* <p>
* 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.
* <p>
* The ByteBuffer is expected to contain the values in column-major order.
* <p>
* 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__
/**
Expand Down
38 changes: 38 additions & 0 deletions src/org/joml/Matrix2f.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* The FloatBuffer is expected to contain the values in column-major order.
* <p>
* 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.
* <p>
* The ByteBuffer is expected to contain the values in column-major order.
* <p>
* 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__
Expand Down
74 changes: 74 additions & 0 deletions src/org/joml/Matrix3d.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* The DoubleBuffer is expected to contain the values in column-major order.
* <p>
* 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.
* <p>
* The FloatBuffer is expected to contain the values in column-major order.
* <p>
* 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.
* <p>
* The ByteBuffer is expected to contain the values in column-major order.
* <p>
* 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.
* <p>
* The ByteBuffer is expected to contain the values in column-major order.
* <p>
* 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__
/**
Expand Down
38 changes: 38 additions & 0 deletions src/org/joml/Matrix3f.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* The FloatBuffer is expected to contain the values in column-major order.
* <p>
* 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.
* <p>
* The ByteBuffer is expected to contain the values in column-major order.
* <p>
* 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__
/**
Expand Down
38 changes: 38 additions & 0 deletions src/org/joml/Matrix3x2d.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* The DoubleBuffer is expected to contain the values in column-major order.
* <p>
* 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.
* <p>
* The ByteBuffer is expected to contain the values in column-major order.
* <p>
* 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__
/**
Expand Down
44 changes: 40 additions & 4 deletions src/org/joml/Matrix3x2f.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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.
* <p>
* The FloatBuffer is expected to contain the values in column-major order.
* <p>
* 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.
* <p>
* The ByteBuffer is expected to contain the values in column-major order.
* <p>
* 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
Expand Down
Loading

0 comments on commit 7fd5da7

Please sign in to comment.