From 71b0af035029edeabf066f0bb47fb3e2cfed400b Mon Sep 17 00:00:00 2001 From: Thompson Lee Date: Sun, 31 Jul 2016 00:42:14 -0400 Subject: [PATCH] Decided to return int value to notify if inverse calculation is successful, or failed. --- include/c3d/maths.h | 2 ++ source/maths/mtx_inverse.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/c3d/maths.h b/include/c3d/maths.h index 6ab0f21..c461801 100644 --- a/include/c3d/maths.h +++ b/include/c3d/maths.h @@ -62,6 +62,8 @@ static inline void Mtx_Copy(C3D_Mtx* out, const C3D_Mtx* in) void Mtx_Identity(C3D_Mtx* out); 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_Scale(C3D_Mtx* mtx, float x, float y, float z); void Mtx_RotateX(C3D_Mtx* mtx, float angle, bool bRightSide); diff --git a/source/maths/mtx_inverse.c b/source/maths/mtx_inverse.c index 06179e7..938da3e 100644 --- a/source/maths/mtx_inverse.c +++ b/source/maths/mtx_inverse.c @@ -1,6 +1,6 @@ #include -void Mtx_Inverse(C3D_Mtx* out) +int Mtx_Inverse(C3D_Mtx* out) { float inv[16], det; int i; @@ -124,6 +124,10 @@ void Mtx_Inverse(C3D_Mtx* out) for (i = 0; i < 16; i++) out->m[i] = inv[i] * det; + + return 0; } - + + return -1; + }