From 59377695bd21693b9a5a587890f6d70ee5d8b1ff Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 13 Apr 2012 09:08:43 +0000 Subject: Fix #30929: cycles rendering of object with scale 0 on some axis did not work correct with instancing. Actually such object will not work in many places, e.g. transforming vertices in edit mode doesn't work and textures will be misapplied in Blender Internal, so these should be avoided. --- intern/cycles/util/util_transform.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'intern/cycles/util') diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp index 8c5eac2cbb9..61bc36ae888 100644 --- a/intern/cycles/util/util_transform.cpp +++ b/intern/cycles/util/util_transform.cpp @@ -134,8 +134,16 @@ Transform transform_inverse(const Transform& tfm) R.T = transform_identity(); M.T = tfm; - if(!transform_matrix4_gj_inverse(R.M, M.M)) - return transform_identity(); + if(!transform_matrix4_gj_inverse(R.M, M.M)) { + /* matrix is degenerate (e.g. 0 scale on some axis), ideally we should + never be in this situation, but try to invert it anyway with tweak */ + M.M[0][0] += 1e-8f; + M.M[1][1] += 1e-8f; + M.M[2][2] += 1e-8f; + + if(!transform_matrix4_gj_inverse(R.M, M.M)) + return transform_identity(); + } return R.T; } -- cgit v1.2.3