[Bf-blender-cvs] [9921e10583d] blender2.8: Math: Set matrix to zero when inversion fails

Sergey Sharybin noreply at git.blender.org
Fri Jun 22 12:08:26 CEST 2018


Commit: 9921e10583d7a6ef735ecc069b2b78f97ca9c226
Author: Sergey Sharybin
Date:   Fri Jun 22 11:22:50 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB9921e10583d7a6ef735ecc069b2b78f97ca9c226

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).

===================================================================

M	intern/eigen/intern/matrix.cc

===================================================================

diff --git a/intern/eigen/intern/matrix.cc b/intern/eigen/intern/matrix.cc
index 5e00540f27c..bcd5273fd74 100644
--- a/intern/eigen/intern/matrix.cc
+++ b/intern/eigen/intern/matrix.cc
@@ -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;
 }



More information about the Bf-blender-cvs mailing list