[Bf-blender-cvs] [ae42dd53274] temp-object-multi-mode: Center now works for multiple objects

Campbell Barton noreply at git.blender.org
Tue Apr 10 19:12:08 CEST 2018


Commit: ae42dd53274db1b0c55d17dc793cf2757ad6f1db
Author: Campbell Barton
Date:   Tue Apr 10 19:03:19 2018 +0200
Branches: temp-object-multi-mode
https://developer.blender.org/rBae42dd53274db1b0c55d17dc793cf2757ad6f1db

Center now works for multiple objects

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

M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_generics.c

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

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index d1d5d2953b0..defbe626e92 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -244,8 +244,8 @@ void setTransformViewMatrices(TransInfo *t)
 		t->persp = RV3D_ORTHO;
 	}
 
-	calculateCenterGlobal(t, t->center, t->center_global);
 	calculateCenter2D(t);
+	calculateCenterLocal(t, t->center_global);
 }
 
 void setTransformViewAspect(TransInfo *t, float r_aspect[3])
@@ -650,7 +650,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
 static void viewRedrawPost(bContext *C, TransInfo *t)
 {
 	ED_area_headerprint(t->sa, NULL);
-
+	
 	if (t->spacetype == SPACE_VIEW3D) {
 		/* if autokeying is enabled, send notifiers that keyframes were added */
 		if (IS_AUTOKEY_ON(t->scene))
@@ -662,12 +662,12 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
 		{
 			WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
 		}
-
+		
 		/* XXX temp, first hack to get auto-render in compositor work (ton) */
 		WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM_DONE, CTX_data_scene(C));
 
 	}
-
+	
 #if 0 // TRANSFORM_FIX_ME
 	if (t->spacetype == SPACE_VIEW3D) {
 		allqueue(REDRAWBUTSOBJECT, 0);
@@ -843,14 +843,14 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
 		{TFM_MODAL_INSERTOFS_TOGGLE_DIR, "INSERTOFS_TOGGLE_DIR", 0, "Toggle Direction for Node Auto-offset", ""},
 		{0, NULL, 0, NULL, NULL}
 	};
-
+	
 	wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Transform Modal Map");
-
+	
 	/* this function is called for each spacetype, only needs to add map once */
 	if (keymap && keymap->modal_items) return NULL;
-
+	
 	keymap = WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items);
-
+	
 	/* items for modal map */
 	WM_modalkeymap_add_item(keymap, ESCKEY,    KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL);
 	WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
@@ -860,7 +860,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
 	WM_modalkeymap_add_item(keymap, GKEY, KM_PRESS, 0, 0, TFM_MODAL_TRANSLATE);
 	WM_modalkeymap_add_item(keymap, RKEY, KM_PRESS, 0, 0, TFM_MODAL_ROTATE);
 	WM_modalkeymap_add_item(keymap, SKEY, KM_PRESS, 0, 0, TFM_MODAL_RESIZE);
-
+	
 	WM_modalkeymap_add_item(keymap, TABKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_SNAP_TOGGLE);
 
 	WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_SNAP_INV_ON);
@@ -868,7 +868,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
 
 	WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_SNAP_INV_ON);
 	WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, TFM_MODAL_SNAP_INV_OFF);
-
+	
 	WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, 0, 0, TFM_MODAL_ADD_SNAP);
 	WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, KM_ALT, 0, TFM_MODAL_REMOVE_SNAP);
 
@@ -884,7 +884,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
 
 	WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_ALT, 0, TFM_MODAL_EDGESLIDE_UP);
 	WM_modalkeymap_add_item(keymap, WHEELUPMOUSE, KM_PRESS, KM_ALT, 0, TFM_MODAL_EDGESLIDE_DOWN);
-
+	
 	WM_modalkeymap_add_item(keymap, PAGEUPKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOIK_LEN_INC);
 	WM_modalkeymap_add_item(keymap, PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOIK_LEN_DEC);
 	WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOIK_LEN_INC);
@@ -903,7 +903,7 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
 		const bool edit_2d = (t->flag & T_2D_EDIT) != 0;
 		const char *msg1 = "", *msg2 = "", *msg3 = "";
 		char axis;
-
+	
 		/* Initialize */
 		switch (key_type) {
 			case XKEY:
@@ -1029,7 +1029,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 					handled = true;
 				}
 				else {
-					if ((t->flag & T_EDIT) && (t->obedit_type == OB_MESH)) {
+					if (t->obedit_type == OB_MESH) {
 						if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) {
 							restoreTransObjects(t);
 							resetTransModal(t);
@@ -1074,7 +1074,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 						restoreTransObjects(t);
 						resetTransModal(t);
 						resetTransRestrictions(t);
-
+						
 						if (t->mode == TFM_ROTATION) {
 							initTrackball(t);
 						}
@@ -1119,7 +1119,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 					}
 				}
 				break;
-
+				
 			case TFM_MODAL_SNAP_INV_ON:
 				t->modifiers |= MOD_SNAP_INVERT;
 				t->redraw |= TREDRAW_HARD;
@@ -1701,7 +1701,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
 static int helpline_poll(bContext *C)
 {
 	ARegion *ar = CTX_wm_region(C);
-
+	
 	if (ar && ar->regiontype == RGN_TYPE_WINDOW)
 		return 1;
 	return 0;
@@ -1844,7 +1844,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
 static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), void *arg)
 {
 	TransInfo *t = arg;
-
+	
 	glLineWidth(1.0f);
 
 	drawConstraint(t);
@@ -1868,10 +1868,10 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
 
 	const int font_id = BLF_default();
 	BLF_width_and_height(font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
-
+	
 	xco = (rect.xmax - U.widget_unit) - (int)printable_size[0];
 	yco = (rect.ymax - U.widget_unit);
-
+	
 	/* warning text (to clarify meaning of overlays)
 	 * - original color was red to match the icon, but that clashes badly with a less nasty border
 	 */
@@ -1883,28 +1883,28 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
 #else
 	BLF_draw_default_ascii(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
 #endif
-
+	
 	/* autokey recording icon... */
 	glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 	glEnable(GL_BLEND);
-
+	
 	xco -= U.widget_unit;
 	yco -= (int)printable_size[1] / 2;
 
 	UI_icon_draw(xco, yco, ICON_REC);
-
+	
 	glDisable(GL_BLEND);
 }
 
 static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg)
-{
+{	
 	TransInfo *t = arg;
 	Scene *scene = t->scene;
 	ViewLayer *view_layer = t->view_layer;
 	Object *ob = OBACT(view_layer);
-
-	/* draw autokeyframing hint in the corner
-	 * - only draw if enabled (advanced users may be distracted/annoyed),
+	
+	/* draw autokeyframing hint in the corner 
+	 * - only draw if enabled (advanced users may be distracted/annoyed), 
 	 *   for objects that will be autokeyframed (no point ohterwise),
 	 *   AND only for the active region (as showing all is too overwhelming)
 	 */
@@ -1995,7 +1995,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 				ts->prop_mode = t->prop_mode;
 			}
 		}
-
+		
 		/* do we check for parameter? */
 		if (t->modifiers & MOD_SNAP) {
 			ts->snap_flag |= SCE_SNAP;
@@ -2018,7 +2018,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 			}
 		}
 	}
-
+	
 	if ((prop = RNA_struct_find_property(op->ptr, "proportional"))) {
 		RNA_property_enum_set(op->ptr, prop, proportional);
 		RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
@@ -2102,7 +2102,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 			options |= CTX_TEXTURE;
 		}
 	}
-
+	
 	if ((prop = RNA_struct_find_property(op->ptr, "gpencil_strokes")) && RNA_property_is_set(op->ptr, prop)) {
 		if (RNA_property_boolean_get(op->ptr, prop)) {
 			options |= CTX_GPENCIL_STROKES;
@@ -2271,7 +2271,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 		case TFM_BONESIZE:
 		{   /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
 			/* Note: we have to pick one, use the active object. */
-			TransHandle *th = &t->thand[0];
+			TransHandle *th = THAND_FIRST_OK(t);
 			bArmature *arm = th->poseobj->data;
 			if (arm->drawtype == ARM_ENVELOPE) {
 				initBoneEnvelope(t);
@@ -2463,7 +2463,7 @@ int transformEnd(bContext *C, TransInfo *t)
 			else if (t->mode == TFM_VERT_SLIDE) {
 				doVertSlide(t, 0.0f);
 			}
-
+			
 			exit_code = OPERATOR_CANCELLED;
 			restoreTransObjects(t); // calls recalcData()
 		}
@@ -2528,7 +2528,7 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
 	/* check that protection flags are set */
 	if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
 		return;
-
+	
 	if (protectflag & OB_LOCK_ROT4D) {
 		/* axis-angle getting limited as 4D entities that they are... */
 		if (protectflag & OB_LOCK_ROTW)
@@ -2543,19 +2543,19 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
 	else {
 		/* axis-angle get limited with euler... */
 		float eul[3], oldeul[3];
-
+		
 		axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, axis, *angle);
 		axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, oldAxis, oldAngle);
-
+		
 		if (protectflag & OB_LOCK_ROTX)
 			eul[0] = oldeul[0];
 		if (protectflag & OB_LOCK_ROTY)
 			eul[1] = oldeul[1];
 		if (protectflag & OB_LOCK_ROTZ)
 			eul[2] = oldeul[2];
-
+		
 		eulO_to_axis_angle(axis, angle, eul, EULER_ORDER_DEFAULT);
-
+		
 		/* when converting to axis-angle, we need a special exception for the case when there is no axis */
 		if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) {
 			/* for now, rotate around y-axis then (so that it simply becomes the roll) */
@@ -2570,7 +2570,7 @@ static void protectedQuaternionBits(short protectflag, float quat[4], const floa
 	/* check that protection flags are set */
 	if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
 		return;
-
+	
 	if (protectflag & OB_LOCK_ROT4D) {
 		/* quaternions getting limited as 4D entities that they are... */
 		if (protectflag & OB_LOCK_ROTW)
@@ -2604,7 +2604,7 @@ static void protectedQuaternionBits(short protectflag, float quat[4], const floa
 
 		/* restore original quat size */
 		mul_qt_fl(quat, qlen);
-
+		
 		/* quaternions flip w sign to accumulate rotations correctly */
 		if ((nquat[0] < 0.0f && quat[0] > 0.0f) ||
 		    (nquat[0] > 0.0f && quat[0] < 0.0f))
@@ -2621,43 +2621,43 @@ static void constraintTrans

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list