[Bf-blender-cvs] [fcff5f80f94] temp-object-multi-mode: Temp

Campbell Barton noreply at git.blender.org
Tue Apr 10 19:11:50 CEST 2018


Commit: fcff5f80f940d80b59cc32d919233caae37d3a5a
Author: Campbell Barton
Date:   Mon Apr 9 15:59:33 2018 +0200
Branches: temp-object-multi-mode
https://developer.blender.org/rBfcff5f80f940d80b59cc32d919233caae37d3a5a

Temp

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

M	source/blender/blenkernel/BKE_layer.h
M	source/blender/blenkernel/intern/layer_utils.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_constraints.c
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_generics.c

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

diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 4e663b6a48f..4ab9d74dfa6 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -383,6 +383,7 @@ struct Object **BKE_view_layer_array_from_objects_in_mode_params(
 
 
 bool BKE_view_layer_filter_edit_mesh_has_uvs(struct Object *ob, void *user_data);
+bool BKE_view_layer_filter_edit_mesh_has_edges(struct Object *ob, void *user_data);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/intern/layer_utils.c b/source/blender/blenkernel/intern/layer_utils.c
index c556443cbed..5c2e9bce623 100644
--- a/source/blender/blenkernel/intern/layer_utils.c
+++ b/source/blender/blenkernel/intern/layer_utils.c
@@ -102,7 +102,23 @@ bool BKE_view_layer_filter_edit_mesh_has_uvs(Object *ob, void *UNUSED(user_data)
 		Mesh *me = ob->data;
 		BMEditMesh *em = me->edit_btmesh;
 		if (em != NULL) {
-			return CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV) != -1;
+			if (CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV) != -1) {
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+bool BKE_view_layer_filter_edit_mesh_has_edges(Object *ob, void *UNUSED(user_data))
+{
+	if (ob->type == OB_MESH) {
+		Mesh *me = ob->data;
+		BMEditMesh *em = me->edit_btmesh;
+		if (em != NULL) {
+			if (em->bm->totedge != 0) {
+				return true;
+			}
 		}
 	}
 	return false;
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 5ba10759cec..5d0db753977 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -110,7 +110,7 @@ static void drawEdgeSlide(TransInfo *t);
 static void drawVertSlide(TransInfo *t);
 static void postInputRotation(TransInfo *t, float values[3]);
 
-static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], const short around);
+static void ElementRotation(TransInfo *t, TransHandle *th, TransData *td, float mat[3][3], const short around);
 static void initSnapSpatial(TransInfo *t, float r_snap[3]);
 
 
@@ -211,7 +211,7 @@ static bool transdata_check_local_center(TransInfo *t, short around)
 {
 	return ((around == V3D_AROUND_LOCAL_ORIGINS) && (
 	            (t->flag & (T_OBJECT | T_POSE)) ||
-	            (t->obedit && ELEM(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)) ||
+	            ((t->flag & T_EDIT) && ELEM(t->obedit_type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)) ||
 	            (t->spacetype == SPACE_IPO) ||
 	            (t->options & (CTX_MOVIECLIP | CTX_MASK | CTX_PAINT_CURVE)))
 	        );
@@ -220,7 +220,7 @@ static bool transdata_check_local_center(TransInfo *t, short around)
 bool transdata_check_local_islands(TransInfo *t, short around)
 {
 	return ((around == V3D_AROUND_LOCAL_ORIGINS) && (
-	        (t->obedit && ELEM(t->obedit->type, OB_MESH))));
+	        ((t->flag & T_EDIT) && ELEM(t->obedit_type, OB_MESH))));
 }
 
 /* ************************** SPACE DEPENDANT CODE **************************** */
@@ -619,8 +619,14 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
 		else {
 			// XXX how to deal with lock?
 			SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
-			if (sima->lock) WM_event_add_notifier(C, NC_GEOM | ND_DATA, t->obedit->data);
-			else ED_area_tag_redraw(t->sa);
+			if (sima->lock) {
+				FOREACH_THAND (t, th) {
+					WM_event_add_notifier(C, NC_GEOM | ND_DATA, th->obedit->data);
+				}
+			}
+			else {
+				ED_area_tag_redraw(t->sa);
+			}
 		}
 	}
 	else if (t->spacetype == SPACE_CLIP) {
@@ -1024,7 +1030,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 					handled = true;
 				}
 				else {
-					if (t->obedit && t->obedit->type == OB_MESH) {
+					if ((t->flag & T_EDIT) && (t->obedit_type == OB_MESH)) {
 						if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) {
 							restoreTransObjects(t);
 							resetTransModal(t);
@@ -1570,7 +1576,7 @@ bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], floa
 
 	t->around = centerMode;             // override userdefined mode
 
-	if (t->total == 0) {
+	if (t->total_all_handle == 0) {
 		success = false;
 	}
 	else {
@@ -1971,7 +1977,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 					ts->proportional_fcurve = proportional;
 				else if (t->spacetype == SPACE_ACTION)
 					ts->proportional_action = proportional;
-				else if (t->obedit)
+				else if (t->flag & T_EDIT)
 					ts->proportional = proportional;
 				else if (t->options & CTX_MASK)
 					ts->proportional_mask = (proportional != PROP_EDIT_OFF);
@@ -2161,7 +2167,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 
 	createTransData(C, t);          // make TransData structs from selection
 
-	if (t->total == 0) {
+	if (t->total_all_handle == 0) {
 		postTrans(C, t);
 		return 0;
 	}
@@ -2265,7 +2271,9 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 			break;
 		case TFM_BONESIZE:
 		{   /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
-			bArmature *arm = t->poseobj->data;
+			/* Note: we have to pick one, use the active object. */
+			TransHandle *th = &t->thand[0];
+			bArmature *arm = th->poseobj->data;
 			if (arm->drawtype == ARM_ENVELOPE) {
 				initBoneEnvelope(t);
 				t->mode = TFM_BONE_ENVELOPE_DIST;
@@ -2923,10 +2931,6 @@ static void initBend(TransInfo *t)
 	ED_view3d_win_to_3d(t->sa->spacedata.first, t->ar, curs, mval_fl, data->warp_end);
 
 	copy_v3_v3(data->warp_nor, t->viewinv[2]);
-	if (t->flag & T_EDIT) {
-		sub_v3_v3(data->warp_sta, t->obedit->obmat[3]);
-		sub_v3_v3(data->warp_end, t->obedit->obmat[3]);
-	}
 	normalize_v3(data->warp_nor);
 
 	/* tangent */
@@ -3023,7 +3027,8 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
 		madd_v3_v3fl(pivot, data->warp_tan, +values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle));
 	}
 
-	for (TransHandle *th = t->thand, *th_end = t->thand + t->thand_len; th != th_end; th++) {
+	/* TODO(campbell): xform, compensate object center. */
+	FOREACH_THAND (t, th) {
 	TransData *td = th->data;
 	for (i = 0; i < th->total; i++, td++) {
 		float mat[3][3];
@@ -3065,7 +3070,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
 
 		/* rotation */
 		if ((t->flag & T_POINTS) == 0) {
-			ElementRotation(t, td, mat, V3D_AROUND_LOCAL_ORIGINS);
+			ElementRotation(t, th, td, mat, V3D_AROUND_LOCAL_ORIGINS);
 		}
 
 		/* location */
@@ -3143,7 +3148,6 @@ static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event)
 
 static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
 {
-	TransData *td = t->data;
 	float vec[3];
 	float smat[3][3], tmat[3][3], totmat[3][3], persmat[3][3], persinv[3][3];
 	float value;
@@ -3186,7 +3190,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
 	mul_m3_m3m3(tmat, smat, persmat);
 	mul_m3_m3m3(totmat, persinv, tmat);
 
-	for (TransHandle *th = t->thand, *th_end = t->thand + t->thand_len; th != th_end; th++) {
+	FOREACH_THAND (t, th) {
 	TransData *td = th->data;
 	for (i = 0; i < th->total; i++, td++) {
 		const float *center, *co;
@@ -3197,7 +3201,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
 		if (td->flag & TD_SKIP)
 			continue;
 		
-		if (t->obedit) {
+		if (t->flag & T_EDIT) {
 			float mat3[3][3];
 			mul_m3_m3m3(mat3, totmat, td->mtx);
 			mul_m3_m3m3(tmat, td->smtx, mat3);
@@ -3253,7 +3257,7 @@ static void initResize(TransInfo *t)
 	t->num.val_flag[1] |= NUM_NULL_ONE;
 	t->num.val_flag[2] |= NUM_NULL_ONE;
 	t->num.flag |= NUM_AFFECT_ALL;
-	if (!t->obedit) {
+	if (t->flag & T_EDIT) {
 		t->flag |= T_NO_ZERO;
 #ifdef USE_NUM_NO_ZERO
 		t->num.val_flag[0] |= NUM_NO_ZERO;
@@ -3337,7 +3341,7 @@ static void TransMat3ToSize(float mat[3][3], float smat[3][3], float size[3])
 	if (dot_v3v3(rmat[2], smat[2]) < 0.0f) size[2] = -size[2];
 }
 
-static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
+static void ElementResize(TransInfo *t, TransHandle *th, TransData *td, float mat[3][3])
 {
 	float tmat[3][3], smat[3][3], center[3];
 	float vec[3];
@@ -3351,7 +3355,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
 	}
 	
 	if (t->con.applySize) {
-		t->con.applySize(t, td, tmat);
+		t->con.applySize(t, th, td, tmat);
 	}
 	
 	/* local constraint shouldn't alter center */
@@ -3440,7 +3444,6 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
 
 static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
 {
-	TransData *td;
 	float mat[3][3];
 	int i;
 	char str[UI_MAX_DRAW_STR];
@@ -3465,32 +3468,38 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
 	size_to_mat3(mat, t->values);
 	
 	if (t->con.applySize) {
-		t->con.applySize(t, NULL, mat);
+		t->con.applySize(t, NULL, NULL, mat);
 	}
 	
 	copy_m3_m3(t->mat, mat);    // used in manipulator
 	
 	headerResize(t, t->values, str);
-	
-	for (i = 0, td = t->data; i < t->total; i++, td++) {
+
+	FOREACH_THAND (t, th) {
+	TransData *td = th->data;
+	for (i = 0; i < th->total; i++, td++) {
 		if (td->flag & TD_NOACTION)
 			break;
 		
 		if (td->flag & TD_SKIP)
 			continue;
 		
-		ElementResize(t, td, mat);
+		ElementResize(t, th, td, mat);
 	}
-	
+	} // FIXME(indent)
+
 	/* evil hack - redo resize if cliping needed */
 	if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 1)) {
 		size_to_mat3(mat, t->values);
 		
 		if (t->con.applySize)
-			t->con.applySize(t, NULL, mat);
+			t->con.applySize(t, NULL, NULL, mat);
+
 		
-		for (i = 0, td = t->data; i < t->total; i++, td++)
-			ElementResize(t, td, mat);
+		FOREACH_THAND (t, th) {
+		TransData *td = th->data;
+		for (i = 0; i < th->total; i++, td++)
+			ElementResize(t, th, td, mat);
 
 		/* In proportional edit it can happen that */
 		/* vertices in the radius of the brush end */
@@ -3499,6 +3508,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
 		if (t->flag & T_PROP_EDIT_ALL) {
 			clipUVData(t);
 		}
+		} // FIXME(indent)
 	}
 	
 	recalcData(t);
@@ -3526,7 +3536,7 @@ static void initSkinResize(TransInfo *t)
 	t->num.val_flag[1] |= NUM_NULL_ONE;
 	t->num.val_flag[2] |= NUM_NULL_ONE;
 	t->nu

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list