[Bf-blender-cvs] [d2ed556] master: Metaball transform, support active-only option

Campbell Barton noreply at git.blender.org
Fri May 9 12:25:49 CEST 2014


Commit: d2ed5563d7127a44571e3518f535d71d0bdaf1ae
Author: Campbell Barton
Date:   Fri May 9 20:23:04 2014 +1000
https://developer.blender.org/rBd2ed5563d7127a44571e3518f535d71d0bdaf1ae

Metaball transform, support active-only option

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

M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/transform/transform_orientations.c

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

diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index f94fec3..125975e 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -450,16 +450,19 @@ int calc_manipulator_stats(const bContext *C)
 		}
 		else if (obedit->type == OB_MBALL) {
 			MetaBall *mb = (MetaBall *)obedit->data;
-			MetaElem *ml /* , *ml_sel = NULL */ /* UNUSED */;
+			MetaElem *ml;
 
-			ml = mb->editelems->first;
-			while (ml) {
-				if (ml->flag & SELECT) {
-					calc_tw_center(scene, &ml->x);
-					/* ml_sel = ml; */ /* UNUSED */
-					totsel++;
+			if ((v3d->around == V3D_ACTIVE) && (ml = mb->lastelem)) {
+				calc_tw_center(scene, &ml->x);
+				totsel++;
+			}
+			else {
+				for (ml = mb->editelems->first; ml; ml = ml->next) {
+					if (ml->flag & SELECT) {
+						calc_tw_center(scene, &ml->x);
+						totsel++;
+					}
 				}
-				ml = ml->next;
 			}
 		}
 		else if (obedit->type == OB_LATTICE) {
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index f8c06e3..ba90926 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -795,18 +795,31 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
 		}
 		else if (obedit->type == OB_MBALL) {
 			MetaBall *mb = obedit->data;
+			MetaElem *ml;
+			bool ok = false;
+			float tmat[3][3];
 			
-			if (mb->lastelem) {
-				float qmat[3][3];
-
-				/* Rotation of MetaElem is stored in quat */
-				quat_to_mat3(qmat, mb->lastelem->quat);
-
-				copy_v3_v3(normal, qmat[2]);
+			if (activeOnly && (ml = mb->lastelem)) {
+				quat_to_mat3(tmat, ml->quat);
+				add_v3_v3(normal, tmat[2]);
+				add_v3_v3(plane, tmat[1]);
+				ok = true;
+			}
+			else {
+				for (ml = mb->editelems->first; ml; ml = ml->next) {
+					if (ml->flag & SELECT) {
+						quat_to_mat3(tmat, ml->quat);
+						add_v3_v3(normal, tmat[2]);
+						add_v3_v3(plane, tmat[1]);
+						ok = true;
+					}
+				}
+			}
 
-				copy_v3_v3(plane, qmat[1]);
-				
-				result = ORIENTATION_FACE;
+			if (ok) {
+				if (!is_zero_v3(plane)) {
+					result = ORIENTATION_FACE;
+				}
 			}
 		}
 		else if (obedit->type == OB_ARMATURE) {




More information about the Bf-blender-cvs mailing list