Decided to return int value to notify if inverse calculation is successful, or failed.

This commit is contained in:
Thompson Lee 2016-07-31 00:42:14 -04:00
parent e999c4c6f7
commit 71b0af0350
2 changed files with 8 additions and 2 deletions

View File

@ -62,6 +62,8 @@ static inline void Mtx_Copy(C3D_Mtx* out, const C3D_Mtx* in)
void Mtx_Identity(C3D_Mtx* out); void Mtx_Identity(C3D_Mtx* out);
void Mtx_Multiply(C3D_Mtx* out, const C3D_Mtx* a, const C3D_Mtx* b); void Mtx_Multiply(C3D_Mtx* out, const C3D_Mtx* a, const C3D_Mtx* b);
int Mtx_Inverse(C3D_Mtx* out);
void Mtx_Translate(C3D_Mtx* mtx, float x, float y, float z); void Mtx_Translate(C3D_Mtx* mtx, float x, float y, float z);
void Mtx_Scale(C3D_Mtx* mtx, float x, float y, float z); void Mtx_Scale(C3D_Mtx* mtx, float x, float y, float z);
void Mtx_RotateX(C3D_Mtx* mtx, float angle, bool bRightSide); void Mtx_RotateX(C3D_Mtx* mtx, float angle, bool bRightSide);

View File

@ -1,6 +1,6 @@
#include <c3d/maths.h> #include <c3d/maths.h>
void Mtx_Inverse(C3D_Mtx* out) int Mtx_Inverse(C3D_Mtx* out)
{ {
float inv[16], det; float inv[16], det;
int i; int i;
@ -124,6 +124,10 @@ void Mtx_Inverse(C3D_Mtx* out)
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
out->m[i] = inv[i] * det; out->m[i] = inv[i] * det;
return 0;
} }
return -1;
} }