common: precision increase while matrix inversion

A numerically motivated limit on the matrix determinant
set at 1e-6 was not sufficient. The limit has been increased
by checkoing whether 1/det is still a number.
This commit is contained in:
Mira Grudzinska 2024-09-03 17:32:22 +02:00 committed by Hermet Park
parent 9dbe141058
commit e01cc2723f
2 changed files with 3 additions and 4 deletions

View file

@ -43,9 +43,8 @@ bool mathInverse(const Matrix* m, Matrix* out)
m->e12 * (m->e21 * m->e33 - m->e23 * m->e31) +
m->e13 * (m->e21 * m->e32 - m->e22 * m->e31);
if (mathZero(det)) return false;
auto invDet = 1 / det;
auto invDet = 1.0f / det;
if (!std::isfinite(invDet)) return false;
out->e11 = (m->e22 * m->e33 - m->e32 * m->e23) * invDet;
out->e12 = (m->e13 * m->e32 - m->e12 * m->e33) * invDet;

View file

@ -26,7 +26,7 @@
#define _USE_MATH_DEFINES
#include <float.h>
#include <math.h>
#include <cmath>
#include "tvgCommon.h"
#define MATH_PI 3.14159265358979323846f