Math: Set matrix to zero when inversion fails
Avoids usage of uninitialized memory when inversion fails. That uninitialized memory can cause object to become visible when it is supposed not to or other artifacts like that. Longer term solution would be to check every instance of invert_m# function and to explicit fallback when needed (possibly, using extra utility functions).
This commit is contained in:
parent
f3501a00e2
commit
9921e10583
|
@ -48,6 +48,9 @@ bool EIG_invert_m4_m4(float inverse[4][4], const float matrix[4][4])
|
|||
Matrix4f R;
|
||||
bool invertible = true;
|
||||
M.computeInverseWithCheck(R, invertible, 0.0f);
|
||||
if (!invertible) {
|
||||
R = R.Zero();
|
||||
}
|
||||
memcpy(inverse, R.data(), sizeof(float)*4*4);
|
||||
return invertible;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue