Skip to content

Commit

Permalink
utils: fix conversion of matrices from GL to GX
Browse files Browse the repository at this point in the history
GX matrices are 3x4, and the old code was overflowing: wee need to skip
the fourth row of the matrix.

Fixes one issue from devkitPro#87
  • Loading branch information
mardy committed Dec 8, 2024
1 parent 60afb21 commit 168e0ee
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,12 @@ static inline void gl_matrix_to_gx(const GLfloat *source, Mtx mv)
float w = source[15];
if (w != 1.0 && w != 0.0) {
for (int i = 0; i < 16; i++) {
if (i % 4 == 3) continue;
mv[i%4][i/4] = source[i] / w;
}
} else {
for (int i = 0; i < 16; i++) {
if (i % 4 == 3) continue;
mv[i%4][i/4] = source[i];
}
}
Expand Down

0 comments on commit 168e0ee

Please sign in to comment.