[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54462] trunk/blender/source/blender: fix [#34200] Metaball Tessellate error

Campbell Barton ideasman42 at gmail.com
Mon Feb 11 14:07:27 CET 2013


Revision: 54462
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54462
Author:   campbellbarton
Date:     2013-02-11 13:07:26 +0000 (Mon, 11 Feb 2013)
Log Message:
-----------
fix [#34200] Metaball Tessellate error

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/mball.c
    trunk/blender/source/blender/editors/metaball/mball_edit.c
    trunk/blender/source/blender/makesdna/DNA_meta_types.h

Modified: trunk/blender/source/blender/blenkernel/intern/mball.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mball.c	2013-02-11 12:41:57 UTC (rev 54461)
+++ trunk/blender/source/blender/blenkernel/intern/mball.c	2013-02-11 13:07:26 UTC (rev 54462)
@@ -1654,6 +1654,14 @@
 	}
 }
 
+/* could move to math api */
+BLI_INLINE void copy_v3_fl3(float v[3], float x, float y, float z)
+{
+	v[0] = x;
+	v[1] = y;
+	v[2] = z;
+}
+
 static float init_meta(Scene *scene, Object *ob)    /* return totsize */
 {
 	Scene *sce_iter = scene;
@@ -1730,6 +1738,7 @@
 						float temp1[4][4], temp2[4][4], temp3[4][4];
 						float (*mat)[4] = NULL, (*imat)[4] = NULL;
 						float max_x, max_y, max_z, min_x, min_y, min_z;
+						float expx, expy, expz;
 
 						max_x = max_y = max_z = -3.4e38;
 						min_x = min_y = min_z =  3.4e38;
@@ -1770,39 +1779,26 @@
 						G_mb.mainb[a]->mat = (float *) mat;
 						G_mb.mainb[a]->imat = (float *) imat;
 
+						if (!MB_TYPE_SIZE_SQUARED(ml->type)) {
+							expx = ml->expx;
+							expy = ml->expy;
+							expz = ml->expz;
+						}
+						else {
+							expx = ml->expx * ml->expx;
+							expy = ml->expy * ml->expy;
+							expz = ml->expz * ml->expz;
+						}
+
 						/* untransformed Bounding Box of MetaElem */
-						/* 0 */
-						G_mb.mainb[a]->bb->vec[0][0] = -ml->expx;
-						G_mb.mainb[a]->bb->vec[0][1] = -ml->expy;
-						G_mb.mainb[a]->bb->vec[0][2] = -ml->expz;
-						/* 1 */
-						G_mb.mainb[a]->bb->vec[1][0] =  ml->expx;
-						G_mb.mainb[a]->bb->vec[1][1] = -ml->expy;
-						G_mb.mainb[a]->bb->vec[1][2] = -ml->expz;
-						/* 2 */
-						G_mb.mainb[a]->bb->vec[2][0] =  ml->expx;
-						G_mb.mainb[a]->bb->vec[2][1] =  ml->expy;
-						G_mb.mainb[a]->bb->vec[2][2] = -ml->expz;
-						/* 3 */
-						G_mb.mainb[a]->bb->vec[3][0] = -ml->expx;
-						G_mb.mainb[a]->bb->vec[3][1] =  ml->expy;
-						G_mb.mainb[a]->bb->vec[3][2] = -ml->expz;
-						/* 4 */
-						G_mb.mainb[a]->bb->vec[4][0] = -ml->expx;
-						G_mb.mainb[a]->bb->vec[4][1] = -ml->expy;
-						G_mb.mainb[a]->bb->vec[4][2] =  ml->expz;
-						/* 5 */
-						G_mb.mainb[a]->bb->vec[5][0] =  ml->expx;
-						G_mb.mainb[a]->bb->vec[5][1] = -ml->expy;
-						G_mb.mainb[a]->bb->vec[5][2] =  ml->expz;
-						/* 6 */
-						G_mb.mainb[a]->bb->vec[6][0] =  ml->expx;
-						G_mb.mainb[a]->bb->vec[6][1] =  ml->expy;
-						G_mb.mainb[a]->bb->vec[6][2] =  ml->expz;
-						/* 7 */
-						G_mb.mainb[a]->bb->vec[7][0] = -ml->expx;
-						G_mb.mainb[a]->bb->vec[7][1] =  ml->expy;
-						G_mb.mainb[a]->bb->vec[7][2] =  ml->expz;
+						copy_v3_fl3(G_mb.mainb[a]->bb->vec[0], -expx, -expy, -expz);  /* 0 */
+						copy_v3_fl3(G_mb.mainb[a]->bb->vec[1], +expx, -expy, -expz);  /* 1 */
+						copy_v3_fl3(G_mb.mainb[a]->bb->vec[2], +expx, +expy, -expz);  /* 2 */
+						copy_v3_fl3(G_mb.mainb[a]->bb->vec[3], -expx, +expy, -expz);  /* 3 */
+						copy_v3_fl3(G_mb.mainb[a]->bb->vec[4], -expx, -expy, +expz);  /* 4 */
+						copy_v3_fl3(G_mb.mainb[a]->bb->vec[5], +expx, -expy, +expz);  /* 5 */
+						copy_v3_fl3(G_mb.mainb[a]->bb->vec[5], +expx, +expy, +expz);  /* 6 */
+						copy_v3_fl3(G_mb.mainb[a]->bb->vec[5], -expx, +expy, +expz);  /* 7 */
 
 						/* transformation of Metalem bb */
 						for (i = 0; i < 8; i++)

Modified: trunk/blender/source/blender/editors/metaball/mball_edit.c
===================================================================
--- trunk/blender/source/blender/editors/metaball/mball_edit.c	2013-02-11 12:41:57 UTC (rev 54461)
+++ trunk/blender/source/blender/editors/metaball/mball_edit.c	2013-02-11 13:07:26 UTC (rev 54462)
@@ -602,7 +602,7 @@
 		me->rad *= scale;
 		/* hrmf, probably elems shouldn't be
 		 * treating scale differently - campbell */
-		if (ELEM3(me->type, MB_CUBE, MB_PLANE, MB_TUBE)) {
+		if (!MB_TYPE_SIZE_SQUARED(me->type)) {
 			mul_v3_fl(&me->expx, scale);
 		}
 		else {

Modified: trunk/blender/source/blender/makesdna/DNA_meta_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_meta_types.h	2013-02-11 12:41:57 UTC (rev 54461)
+++ trunk/blender/source/blender/makesdna/DNA_meta_types.h	2013-02-11 13:07:26 UTC (rev 54462)
@@ -121,6 +121,8 @@
 #define MB_ELIPSOID	6
 #define MB_CUBE 	7
 
+#define MB_TYPE_SIZE_SQUARED(type)  (type == MB_ELIPSOID)
+
 /* ml->flag */
 #define MB_NEGATIVE	2
 #define MB_HIDE		8




More information about the Bf-blender-cvs mailing list