summaryrefslogtreecommitdiff
path: root/source/math.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/math.h')
-rw-r--r--source/math.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/math.h b/source/math.h
index 77a650d..fda6bf8 100644
--- a/source/math.h
+++ b/source/math.h
@@ -6,6 +6,10 @@
#define To_Radian(x) ((x) * PI / 180.0f)
#define To_Degree(x) ((x) * 180.0f / PI)
+// @notes:
+// I dislike the mat4 discrepancy in the raw data. It's called buffer here while everywhere else it's called
+// data. It's weird and I hate it.
+
r32 clampf(r32 x, r32 bottom, r32 top)
{
if (x < bottom)
@@ -391,4 +395,19 @@ Mat4 lookat4m(Vec3 up, Vec3 forward, Vec3 right, Vec3 position)
return res;
}
+
+Mat4 to_col_major4m(Mat4 mat)
+{
+ Mat4 res = {0.0f};
+
+ res.data[0][0] = mat.data[0][0]; res.data[1][0] = mat.data[0][1]; res.data[2][0] = mat.data[0][2]; res.data[3][0] = mat.data[0][3];
+
+ res.data[0][1] = mat.data[1][0]; res.data[1][1] = mat.data[1][1]; res.data[2][1] = mat.data[1][2]; res.data[3][1] = mat.data[1][3];
+
+ res.data[0][2] = mat.data[2][0]; res.data[1][2] = mat.data[2][1]; res.data[2][2] = mat.data[2][2]; res.data[3][2] = mat.data[2][3];
+
+ res.data[0][3] = mat.data[3][0]; res.data[1][3] = mat.data[3][1]; res.data[2][3] = mat.data[3][2]; res.data[3][3] = mat.data[3][3];
+
+ return res;
+}
#endif