[Bf-blender-cvs] [81ea815dcb6] blender2.8: Gizmo: use general active center calculation

Campbell Barton noreply at git.blender.org
Thu Dec 13 00:59:35 CET 2018


Commit: 81ea815dcb6125288d25447fcab4b4390e14297a
Author: Campbell Barton
Date:   Thu Dec 13 10:51:37 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB81ea815dcb6125288d25447fcab4b4390e14297a

Gizmo: use general active center calculation

There are some minor differences in center calculation but I don't think
they're important, if so we can update the code.

- Edit-bone uses head (instead of the middle when both are selected).
- Edit-bone flag for restricting components uses the selection instead
  of the active bone.

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

M	source/blender/editors/transform/transform_gizmo_3d.c

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

diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index b1d2fd329bb..8b877c7ec23 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -862,21 +862,6 @@ int ED_transform_calc_gizmo_stats(
 					}
 				}
 			} FOREACH_EDIT_OBJECT_END();
-
-			/* Around active, only if there is a selection. The active
-			 * element itself does not have to be selected. */
-			if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
-				BMEditMesh *em = BKE_editmesh_from_object(obedit);
-				BMEditSelection ese;
-
-				if (BM_select_history_active_get(em->bm, &ese)) {
-					float vec[3] = {0, 0, 0};
-					BM_editselection_center(&ese, vec);
-					reset_tw_center(tbounds);
-					calc_tw_center(tbounds, vec);
-					totsel = 1;
-				}
-			}
 		} /* end editmesh */
 		else if (obedit->type == OB_ARMATURE) {
 			FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) {
@@ -908,31 +893,6 @@ int ED_transform_calc_gizmo_stats(
 					}
 				}
 			} FOREACH_EDIT_OBJECT_END();
-
-			/* Around active, only if there is a selection. The active
-			 * element itself does not have to be selected. */
-			if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
-				bArmature *arm = obedit->data;
-				EditBone *ebo = arm->act_edbone;
-
-				if (ebo) {
-					reset_tw_center(tbounds);
-					rv3d->twdrawflag = 0xFFFF;
-					totsel = 0;
-
-					if (ebo->flag & BONE_TIPSEL) {
-						calc_tw_center(tbounds, ebo->tail);
-						totsel++;
-					}
-					if ((ebo->flag & BONE_ROOTSEL) ||
-						((ebo->flag & BONE_TIPSEL) == false))  /* ensure we get at least one point */
-					{
-						calc_tw_center(tbounds, ebo->head);
-						totsel++;
-					}
-					protectflag_to_drawflags_ebone(rv3d, ebo);
-				}
-			}
 		}
 		else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
 			FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) {
@@ -996,19 +956,6 @@ int ED_transform_calc_gizmo_stats(
 					nu = nu->next;
 				}
 			} FOREACH_EDIT_OBJECT_END();
-
-			/* Around active, only if there is a selection. The active
-			 * element itself does not have to be selected. */
-			if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
-				Curve *cu = obedit->data;
-				float center[3];
-
-				if (ED_curve_active_center(cu, center)) {
-					reset_tw_center(tbounds);
-					calc_tw_center(tbounds, center);
-					totsel = 1;
-				}
-			}
 		}
 		else if (obedit->type == OB_MBALL) {
 			FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) {
@@ -1026,19 +973,6 @@ int ED_transform_calc_gizmo_stats(
 					}
 				}
 			} FOREACH_EDIT_OBJECT_END();
-
-			/* Around active, only if there is a selection. The active
-			 * element itself does not have to be selected. */
-			if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
-				MetaBall *mb = (MetaBall *)obedit->data;
-				MetaElem *ml = mb->lastelem;
-
-				if (ml) {
-					reset_tw_center(tbounds);
-					calc_tw_center(tbounds, &ml->x);
-					totsel = 1;
-				}
-			}
 		}
 		else if (obedit->type == OB_LATTICE) {
 			FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) {
@@ -1059,19 +993,6 @@ int ED_transform_calc_gizmo_stats(
 					bp++;
 				}
 			} FOREACH_EDIT_OBJECT_END();
-
-			/* Around active, only if there is a selection. The active
-			 * element itself does not have to be selected. */
-			if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
-				Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
-				BPoint *bp = BKE_lattice_active_point_get(lt);
-
-				if (bp) {
-					reset_tw_center(tbounds);
-					calc_tw_center(tbounds, bp->vec);
-					totsel = 1;
-				}
-			}
 		}
 
 #undef FOREACH_EDIT_OBJECT_BEGIN
@@ -1092,22 +1013,12 @@ int ED_transform_calc_gizmo_stats(
 		totsel = count_set_pose_transflags(ob, mode, V3D_AROUND_CENTER_BOUNDS, NULL);
 
 		if (totsel) {
-			if ((pivot_point == V3D_AROUND_ACTIVE) &&
-			    (pchan = BKE_pose_channel_active(ob)))
-			{
-				/* Doesn't check selection or visibility of the active bone intentionally. */
-				calc_tw_center(tbounds, pchan->pose_head);
-				protectflag_to_drawflags_pchan(rv3d, pchan);
-				totsel = 1;
-			}
-			else {
-				/* use channels to get stats */
-				for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-					Bone *bone = pchan->bone;
-					if (bone && (bone->flag & BONE_TRANSFORM)) {
-						calc_tw_center(tbounds, pchan->pose_head);
-						protectflag_to_drawflags_pchan(rv3d, pchan);
-					}
+			/* use channels to get stats */
+			for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+				Bone *bone = pchan->bone;
+				if (bone && (bone->flag & BONE_TRANSFORM)) {
+					calc_tw_center(tbounds, pchan->pose_head);
+					protectflag_to_drawflags_pchan(rv3d, pchan);
 				}
 			}
 
@@ -1217,18 +1128,17 @@ static void gizmo_prepare_mat(
 		case V3D_AROUND_CENTER_BOUNDS:
 		case V3D_AROUND_ACTIVE:
 		{
-			bGPdata *gpd = CTX_data_gpencil_data(C);
-			Object *ob = OBACT(view_layer);
+			mid_v3_v3v3(rv3d->twmat[3], tbounds->min, tbounds->max);
 
-			if (((scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) &&
-			     (OBEDIT_FROM_OBACT(ob) == NULL)) &&
-			    ((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) &&
-			    (!(ob->mode & OB_MODE_POSE)))
-			{
-				copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
-			}
-			else {
-				mid_v3_v3v3(rv3d->twmat[3], tbounds->min, tbounds->max);
+			if (scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) {
+				bGPdata *gpd = CTX_data_gpencil_data(C);
+				Object *ob = OBACT(view_layer);
+				if (gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)) {
+					/* pass */
+				}
+				else if (ob != NULL) {
+					ED_object_calc_active_center(ob, false, rv3d->twmat[3]);
+				}
 			}
 			break;
 		}



More information about the Bf-blender-cvs mailing list