Skip to content

Commit

Permalink
Restore transformNormal function in API
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Dec 5, 2023
1 parent 2b9910e commit 58d1c95
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/api/java/net/caffeinemc/mods/sodium/api/math/MatrixHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,36 @@
* the same as those produced by JOML, otherwise Z-fighting will occur.
*/
public class MatrixHelper {
/**
* @param mat The transformation matrix to apply to the normal
* @param x The X-coordinate of the normal vector
* @param y The Y-coordinate of the normal vector
* @param z The Z-coordinate of the normal vector
* @return The transformed normal vector (in packed format)
*/
public static int transformNormal(Matrix3f mat, float x, float y, float z) {
// The transformed normal vector
float nxt = transformNormalX(mat, x, y, z);
float nyt = transformNormalY(mat, x, y, z);
float nzt = transformNormalZ(mat, x, y, z);

return NormI8.pack(nxt, nyt, nzt);
}

/**
* @param mat The transformation matrix to apply to the normal
* @param norm The normal vector to transform (in packed format)
* @return The transformed normal vector (in packed format)
*/
public static int transformNormal(Matrix3f mat, int norm) {
// The unpacked normal vector
float x = NormI8.unpackX(norm);
float y = NormI8.unpackY(norm);
float z = NormI8.unpackZ(norm);

return transformNormal(mat, x, y, z);
}

/**
* @param mat The transformation matrix to apply to the normal vector
* @param x The X-coordinate of the normal vector
Expand Down

0 comments on commit 58d1c95

Please sign in to comment.