[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58147] trunk/blender/source/blender/ blenkernel/intern/mball.c: Fix #36076: Metaballs as particles with particle texture (size influence) crashes Blender

Sergey Sharybin sergey.vfx at gmail.com
Wed Jul 10 12:24:06 CEST 2013


Revision: 58147
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58147
Author:   nazgul
Date:     2013-07-10 10:24:06 +0000 (Wed, 10 Jul 2013)
Log Message:
-----------
Fix #36076: Metaballs as particles with particle texture (size influence) crashes Blender

Issue was caused by size influence affecting on object's matrix, which
is nice by it's own. But mball code was using ob->size to check whether
it's zero-sized object or not, but then was using ob->obmat to scale
the meta elements.

This lead to situation when zero-sized elements were trying to tessellate,
which is for sure a really bad idea.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/mball.c

Modified: trunk/blender/source/blender/blenkernel/intern/mball.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mball.c	2013-07-10 09:55:10 UTC (rev 58146)
+++ trunk/blender/source/blender/blenkernel/intern/mball.c	2013-07-10 10:24:06 UTC (rev 58147)
@@ -1646,6 +1646,14 @@
 	v[2] = z;
 }
 
+/* TODO(sergey): Perhaps it could be general utility function in mathutils. */
+static bool has_zero_axis_m4(float matrix[4][4])
+{
+	return len_squared_v3(matrix[0]) < FLT_EPSILON ||
+	       len_squared_v3(matrix[1]) < FLT_EPSILON ||
+	       len_squared_v3(matrix[2]) < FLT_EPSILON;
+}
+
 static float init_meta(PROCESS *process, Scene *scene, Object *ob)    /* return totsize */
 {
 	Scene *sce_iter = scene;
@@ -1694,13 +1702,13 @@
 
 			/* when metaball object has zero scale, then MetaElem to this MetaBall
 			 * will not be put to mainb array */
-			if (bob->size[0] == 0.0f || bob->size[1] == 0.0f || bob->size[2] == 0.0f) {
+			if (has_zero_axis_m4(bob->obmat)) {
 				zero_size = 1;
 			}
 			else if (bob->parent) {
 				struct Object *pob = bob->parent;
 				while (pob) {
-					if (pob->size[0] == 0.0f || pob->size[1] == 0.0f || pob->size[2] == 0.0f) {
+					if (has_zero_axis_m4(pob->obmat)) {
 						zero_size = 1;
 						break;
 					}




More information about the Bf-blender-cvs mailing list