From e8bc38cec5afb897369abd1c305cbf30011151de Mon Sep 17 00:00:00 2001 From: Dmytro Ivanov Date: Sun, 18 Dec 2016 14:49:34 +0100 Subject: [PATCH] fixing mat4 inverse again --- README.md | 2 +- gb_math.h | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2fa9e58..b27f93c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ gb single-file public domain libraries for C & C++ library | latest version | category | description ----------------|----------------|----------|------------- **gb.h** | 0.26d | misc | Helper library (Standard library _improvement_) -**gb_math.h** | 0.07c | math | Vector math library geared towards game development +**gb_math.h** | 0.07d | math | Vector math library geared towards game development **gb_gl.h** | 0.05 | graphics | OpenGL Helper Library **gb_string.h** | 0.95a | strings | A better string library (this is built into gb.h too with custom allocator support!) **gb_ini.h** | 0.93 | misc | Simple ini file loader library diff --git a/gb_math.h b/gb_math.h index 11eb9a2..4b17453 100644 --- a/gb_math.h +++ b/gb_math.h @@ -3,6 +3,7 @@ use '#define GB_MATH_IMPLEMENTATION' before including to create the implementation in _ONE_ file Version History: + 0.07d - Fix mat4_inverse 0.07c - Add gb_random01 0.07b - Fix mat4_inverse 0.07a - Fix Mat2 @@ -1565,9 +1566,9 @@ void gb_mat4_inverse(gbMat4 *out, gbMat4 *in) { o[3][3] = +(m[0][0] * sf15 - m[0][1] * sf17 + m[0][2] * sf18); ood = 1.0f / (m[0][0] * o[0][0] + - m[1][0] * o[1][0] + - m[2][0] * o[2][0] + - m[3][0] * o[3][0]); + m[0][1] * o[1][0] + + m[0][2] * o[2][0] + + m[0][3] * o[3][0]); o[0][0] *= ood; o[0][1] *= ood; @@ -1585,14 +1586,6 @@ void gb_mat4_inverse(gbMat4 *out, gbMat4 *in) { o[3][1] *= ood; o[3][2] *= ood; o[3][3] *= ood; - - /* Transpose */ - tmp = o[1][0]; o[1][0] = o[0][1]; o[0][1] = tmp; - tmp = o[2][0]; o[2][0] = o[0][2]; o[0][2] = tmp; - tmp = o[3][0]; o[3][0] = o[0][3]; o[0][3] = tmp; - tmp = o[2][1]; o[2][1] = o[1][2]; o[1][2] = tmp; - tmp = o[3][1]; o[3][1] = o[1][3]; o[1][3] = tmp; - tmp = o[3][2]; o[3][2] = o[2][3]; o[2][3] = tmp; }