[Bf-blender-cvs] [99b8c0fe5d7] temp-object-multi-mode: Work in progress transform code

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


Commit: 99b8c0fe5d783bef9f441dcba7c317b0bb2b3ffb
Author: Campbell Barton
Date:   Mon Apr 9 08:59:28 2018 +0200
Branches: temp-object-multi-mode
https://developer.blender.org/rB99b8c0fe5d783bef9f441dcba7c317b0bb2b3ffb

Work in progress transform code

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

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_generics.c
M	source/blender/editors/transform/transform_snap.c

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

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index a4bce5b0f1d..587b1670810 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2963,7 +2963,6 @@ static eRedrawFlag handleEventBend(TransInfo *UNUSED(t), const wmEvent *event)
 
 static void Bend(TransInfo *t, const int UNUSED(mval[2]))
 {
-	TransData *td = t->data;
 	float vec[3];
 	float pivot[3];
 	float warp_end_radius[3];
@@ -3034,7 +3033,9 @@ 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 (i = 0; i < t->total; i++, td++) {
+	for (TransHandle *th = t->thand, *th_end = t->thand + t->thand_len; th != th_end; th++) {
+	TransData *td = th->data;
+	for (i = 0; i < th->total; i++, td++) {
 		float mat[3][3];
 		float delta[3];
 		float fac, fac_scaled;
@@ -3080,6 +3081,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
 		/* location */
 		copy_v3_v3(td->loc, vec);
 	}
+	} // FIXME(indent)
 	
 	recalcData(t);
 	
@@ -3194,7 +3196,9 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
 	mul_m3_m3m3(tmat, smat, persmat);
 	mul_m3_m3m3(totmat, persinv, tmat);
 
-	for (i = 0; i < t->total; i++, td++) {
+	for (TransHandle *th = t->thand, *th_end = t->thand + t->thand_len; th != th_end; th++) {
+	TransData *td = th->data;
+	for (i = 0; i < th->total; i++, td++) {
 		const float *center, *co;
 
 		if (td->flag & TD_NOACTION)
@@ -3232,6 +3236,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
 		
 		add_v3_v3v3(td->loc, td->iloc, vec);
 	}
+	} // FIXME(indent)
 	
 	recalcData(t);
 	
@@ -3719,7 +3724,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
 static void postInputRotation(TransInfo *t, float values[3])
 {
 	if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
-		t->con.applyRot(t, NULL, t->axis, values);
+		t->con.applyRot(t, NULL, NULL, t->axis, values);
 	}
 }
 
@@ -4032,7 +4037,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
 	snapGridIncrement(t, &final);
 
 	if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
-		t->con.applyRot(t, NULL, t->axis, NULL);
+		t->con.applyRot(t, NULL, NULL, t->axis, NULL);
 	}
 	else {
 		/* reset axis if constraint is not set */
@@ -5004,7 +5009,7 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
 	}
 
 	if (t->con.applyRot && t->con.mode & CON_APPLY) {
-		t->con.applyRot(t, NULL, axis_global, NULL);
+		t->con.applyRot(t, NULL, NULL, axis_global, NULL);
 	}
 
 	for (i = 0; i < t->total; i++, td++) {
@@ -5018,7 +5023,7 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
 		if (t->con.applyRot && t->con.mode & CON_APPLY) {
 			float axis[3];
 			copy_v3_v3(axis, axis_global);
-			t->con.applyRot(t, td, axis, NULL);
+			t->con.applyRot(t, th, td, axis, NULL);
 
 			mul_m3_v3(td->smtx, axis);
 			if (isLockConstraint(t)) {
@@ -8280,8 +8285,6 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR])
 
 static void applyTimeTranslateValue(TransInfo *t)
 {
-	TransData *td = t->data;
-	TransData2D *td2d = t->data2d;
 	Scene *scene = t->scene;
 	int i;
 	
@@ -8290,6 +8293,9 @@ static void applyTimeTranslateValue(TransInfo *t)
 
 	float deltax, val /* , valprev */;
 
+	for (TransHandle *th = t->thand, *th_end = t->thand + t->thand_len; th != th_end; th++) {
+	TransData *td = th->data;
+	TransData2D *td2d = th->data2d;
 	/* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
 	for (i = 0; i < t->total; i++, td++, td2d++) {
 		/* it is assumed that td->extra is a pointer to the AnimData,
@@ -8331,6 +8337,7 @@ static void applyTimeTranslateValue(TransInfo *t)
 		/* apply nearest snapping */
 		doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap);
 	}
+	} // FIXME(indent)
 }
 
 static void applyTimeTranslate(TransInfo *t, const int mval[2])
@@ -8622,7 +8629,8 @@ static void applyTimeScaleValue(TransInfo *t)
 	const short autosnap = getAnimEdit_SnapMode(t);
 	const double secf = FPS;
 
-
+	for (TransHandle *th = t->thand, *th_end = t->thand + t->thand_len; th != th_end; th++) {
+	TransData *td = th->data;
 	for (i = 0; i < t->total; i++, td++, td2d++) {
 		/* it is assumed that td->extra is a pointer to the AnimData,
 		 * whose active action is where this keyframe comes from
@@ -8649,6 +8657,7 @@ static void applyTimeScaleValue(TransInfo *t)
 		/* apply nearest snapping */
 		doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap);
 	}
+	} // FIXME(indent)
 }
 
 static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index fe05207e645..e5ea6940551 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -47,6 +47,7 @@
 
 struct Depsgraph;
 struct TransInfo;
+struct TransHandle;
 struct TransData;
 struct TransformOrientation;
 struct TransSnap;
@@ -109,7 +110,7 @@ typedef struct TransSnap {
 	 * \note Return value can be anything,
 	 * where the smallest absolute value defines whats closest.
 	 */
-	float  (*distance)(struct TransInfo *, const float p1[3], const float p2[3]);
+	float  (*distance)(struct TransInfo *t, const float p1[3], const float p2[3]);
 
 	/**
 	 * Re-usable snap context data.
@@ -127,14 +128,16 @@ typedef struct TransCon {
 	                     /* the one in TransInfo is not garanty to stay the same (Rotates change it)  */
 	int   mode;          /* Mode flags of the Constraint                                              */
 	void  (*drawExtra)(struct TransInfo *t);
+
+	                     /* Note: if 'th' is NULL, 'td' must also be NULL. */
 	                     /* For constraints that needs to draw differently from the other
 	                      * uses this instead of the generic draw function                            */
-	void  (*applyVec)(struct TransInfo *t, struct TransData *td, const float in[3], float out[3], float pvec[3]);
+	void  (*applyVec)(struct TransInfo *t, struct TransHandle *th, struct TransData *td, const float in[3], float out[3], float pvec[3]);
 	                     /* Apply function pointer for linear vectorial transformation                */
 	                     /* The last three parameters are pointers to the in/out/printable vectors    */
-	void  (*applySize)(struct TransInfo *t, struct TransData *td, float smat[3][3]);
+	void  (*applySize)(struct TransInfo *t, struct TransHandle *th, struct TransData *td, float smat[3][3]);
 	                     /* Apply function pointer for size transformation */
-	void  (*applyRot)(struct TransInfo *t, struct TransData *td, float vec[3], float *angle);
+	void  (*applyRot)(struct TransInfo *t, struct TransHandle *th, struct TransData *td, float vec[3], float *angle);
 	                     /* Apply function pointer for rotation transformation */
 } TransCon;
 
@@ -382,7 +385,23 @@ typedef struct TransCenterData {
 	unsigned int is_set : 1;
 } TransCenterData;
 
+typedef struct TransHandle {
+	TransData  *data;           /* transformed data (array)             */
+	TransDataExtension *ext;	/* transformed data extension (array)   */
+	TransData2D *data2d;		/* transformed data for 2d (array)      */
+	int         total;          /* total number of transformed data     */
+
+	struct Object *obedit;
+	float          obedit_mat[3][3]; /* normalized editmode matrix (T_EDIT only) */
+
+	struct Object *poseobj;		/* if t->flag & T_POSE, this denotes pose object */
+} TransHandle;
+
 typedef struct TransInfo {
+	TransHandle *thand;
+	int          thand_len;
+	int          total_all_handle;
+
 	int         mode;           /* current mode                         */
 	int	        flag;           /* generic flags for special behaviors  */
 	int			modifiers;		/* special modifiers, by function, not key */
@@ -393,10 +412,6 @@ typedef struct TransInfo {
 								/* transform function pointer           */
 	eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *);
 								/* event handler function pointer  RETURN 1 if redraw is needed */
-	int         total;          /* total number of transformed data     */
-	TransData  *data;           /* transformed data (array)             */
-	TransDataExtension *ext;	/* transformed data extension (array)   */
-	TransData2D *data2d;		/* transformed data for 2d (array)      */
 	TransCon    con;            /* transformed constraint               */
 	TransSnap	tsnap;
 	NumInput    num;            /* numerical input                      */
@@ -425,6 +440,7 @@ typedef struct TransInfo {
 	short		around;
 	char		spacetype;		/* spacetype where transforming is      */
 	char		helpline;		/* helpline modes (not to be confused with hotline) */
+	short		obedit_type;	/* Avoid looking inside TransHandle obedit. */
 
 	float		vec[3];			/* translation, to show for widget   	*/
 	float		mat[3][3];		/* rot/rescale, to show for widget   	*/
@@ -432,8 +448,6 @@ typedef struct TransInfo {
 	float		spacemtx[3][3];	/* orientation matrix of the current space	*/
 	char		spacename[64];	/* name of the current space, MAX_NAME		*/
 
-	struct Object *poseobj;		/* if t->flag & T_POSE, this denotes pose object */
-
 	/**
 	 * Rule of thumb for choosing between mode/type:
 	 * - If transform mode uses the data, assign to `mode`
@@ -484,8 +498,6 @@ typedef struct TransInfo {
 	struct ReportList *reports;  /* assign from the operator, or can be NULL */
 	int         mval[2];        /* current mouse position               */
 	float       zfac;           /* use for 3d view */
-	struct Object *obedit;
-	float          obedit_mat[3][3]; /* normalized editmode matrix (T_EDIT only) */
 	void		*draw_handle_apply;
 	void		*draw_handle_view;
 	void		*draw_handle_pixel;
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 4e409e7f77f..81a0d45063e 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -333,7 +333,8 @@ static void planeProject

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list