summaryrefslogtreecommitdiff
path: root/src/engine/Matrix.cpp
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2025-01-24 19:47:37 -0700
committerGitHub <noreply@github.com>2025-01-24 19:47:37 -0700
commit73ba320831997d38b4d6431df3805c62b76400e7 (patch)
tree49c3f3da3dacd71f3de8078ef0f50b64b35eccbc /src/engine/Matrix.cpp
parent23133b6fc058d87d999ddcebc4dd4388f29b96c8 (diff)
Fix matrix stack heap corruption (#166)
* Fix matrix stack heap corruption * Fix matrix overflow bug
Diffstat (limited to 'src/engine/Matrix.cpp')
-rw-r--r--src/engine/Matrix.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/engine/Matrix.cpp b/src/engine/Matrix.cpp
index 7b8c3b1fb..354389db9 100644
--- a/src/engine/Matrix.cpp
+++ b/src/engine/Matrix.cpp
@@ -34,29 +34,30 @@ void AddMatrixFixed(std::vector<Mtx>& stack, s32 flags) {
}
// Used in func_80095BD0
-void SetTextMatrix(f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
- Mat4 mtx;
- mtx[0][0] = arg3;
- mtx[0][1] = 0.0f;
- mtx[0][2] = 0.0f;
- mtx[0][3] = 0.0f;
- mtx[1][0] = 0.0f;
- mtx[1][1] = arg4;
- mtx[1][2] = 0.0f;
- mtx[1][3] = 0.0f;
- mtx[2][0] = 0.0f;
- mtx[2][1] = 0.0f;
- mtx[2][2] = 1.0f;
- mtx[2][3] = 0.0f;
- mtx[3][0] = arg1;
- mtx[3][1] = arg2;
- mtx[3][2] = 0.0f;
- mtx[3][3] = 1.0f;
-
- AddMatrix(gWorldInstance.Mtx.Effects, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+Mtx* SetTextMatrix(f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
+ Mat4 matrix;
+ matrix[0][0] = arg3;
+ matrix[0][1] = 0.0f;
+ matrix[0][2] = 0.0f;
+ matrix[0][3] = 0.0f;
+ matrix[1][0] = 0.0f;
+ matrix[1][1] = arg4;
+ matrix[1][2] = 0.0f;
+ matrix[1][3] = 0.0f;
+ matrix[2][0] = 0.0f;
+ matrix[2][1] = 0.0f;
+ matrix[2][2] = 1.0f;
+ matrix[2][3] = 0.0f;
+ matrix[3][0] = arg1;
+ matrix[3][1] = arg2;
+ matrix[3][2] = 0.0f;
+ matrix[3][3] = 1.0f;
+ Mtx* mtx = GetMatrix(gWorldInstance.Mtx.Effects);
+ guMtxF2L(matrix, mtx);
+
+ return mtx;
}
-
// API
extern "C" {