[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55979] trunk/blender/source/blender/ editors/transform: fix for own recent addition of transform indervidual-axis in editmode, not working if the object was rotated.

Campbell Barton ideasman42 at gmail.com
Fri Apr 12 04:16:48 CEST 2013


Revision: 55979
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55979
Author:   campbellbarton
Date:     2013-04-12 02:16:44 +0000 (Fri, 12 Apr 2013)
Log Message:
-----------
fix for own recent addition of transform indervidual-axis in editmode, not working if the object was rotated.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/transform/transform.h
    trunk/blender/source/blender/editors/transform/transform_constraints.c
    trunk/blender/source/blender/editors/transform/transform_generics.c

Modified: trunk/blender/source/blender/editors/transform/transform.h
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.h	2013-04-12 01:52:30 UTC (rev 55978)
+++ trunk/blender/source/blender/editors/transform/transform.h	2013-04-12 02:16:44 UTC (rev 55979)
@@ -355,7 +355,8 @@
 	struct wmKeyMap *keymap;  /* so we can do lookups for header text */
 	int         mval[2];        /* current mouse position               */
 	float       zfac;           /* use for 3d view */
-	struct Object   *obedit;
+	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;

Modified: trunk/blender/source/blender/editors/transform/transform_constraints.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_constraints.c	2013-04-12 01:52:30 UTC (rev 55978)
+++ trunk/blender/source/blender/editors/transform/transform_constraints.c	2013-04-12 02:16:44 UTC (rev 55979)
@@ -393,7 +393,11 @@
 			if (t->con.mode & CON_AXIS2) {
 				out[2] = in[i++];
 			}
+
 			mul_m3_v3(td->axismtx, out);
+			if (t->flag & T_EDIT) {
+				mul_m3_v3(t->obedit_mat, out);
+			}
 		}
 	}
 }
@@ -446,6 +450,9 @@
 
 		mul_m3_m3m3(tmat, smat, imat);
 		mul_m3_m3m3(smat, td->axismtx, tmat);
+		if (t->flag & T_EDIT) {
+			mul_m3_m3m3(smat, smat, t->obedit_mat);
+		}
 	}
 }
 
@@ -509,24 +516,34 @@
 {
 	if (t->con.mode & CON_APPLY) {
 		int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
+		float tmp_axismtx[3][3];
+		float (*axismtx)[3];
 
 		/* on setup call, use first object */
 		if (td == NULL) {
 			td = t->data;
 		}
 
+		if (t->flag & T_EDIT) {
+			mul_m3_m3m3(tmp_axismtx, t->obedit_mat, td->axismtx);
+			axismtx = tmp_axismtx;
+		}
+		else {
+			axismtx = td->axismtx;
+		}
+
 		switch (mode) {
 			case CON_AXIS0:
 			case (CON_AXIS1 | CON_AXIS2):
-				copy_v3_v3(vec, td->axismtx[0]);
+				copy_v3_v3(vec, axismtx[0]);
 				break;
 			case CON_AXIS1:
 			case (CON_AXIS0 | CON_AXIS2):
-				copy_v3_v3(vec, td->axismtx[1]);
+				copy_v3_v3(vec, axismtx[1]);
 				break;
 			case CON_AXIS2:
 			case (CON_AXIS0 | CON_AXIS1):
-				copy_v3_v3(vec, td->axismtx[2]);
+				copy_v3_v3(vec, axismtx[2]);
 				break;
 		}
 		if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) {
@@ -563,10 +580,7 @@
 	    /* not all editmode supports axis-matrix */
 	    ((t->around != V3D_LOCAL) || (!ELEM3(t->obedit->type, OB_MESH, OB_MBALL, OB_ARMATURE))))
 	{
-		float obmat[3][3];
-		copy_m3_m4(obmat, t->scene->obedit->obmat);
-		normalize_m3(obmat);
-		setConstraint(t, obmat, mode, text);
+		setConstraint(t, t->obedit_mat, mode, text);
 	}
 	else
 #endif
@@ -759,31 +773,39 @@
 	short options = DRAWLIGHT;
 	TransData *td = t->data;
 	int i;
+	float tmp_axismtx[3][3];
 
 	for (i = 0; i < t->total; i++, td++) {
 		float co[3];
+		float (*axismtx)[3];
 
 		if (t->flag & T_OBJECT) {
 			copy_v3_v3(co, td->ob->obmat[3]);
+			axismtx = td->axismtx;
 		}
 		else if (t->flag & T_EDIT) {
 			mul_v3_m4v3(co, t->obedit->obmat, td->center);
+
+			mul_m3_m3m3(tmp_axismtx, t->obedit_mat, td->axismtx);
+			axismtx = tmp_axismtx;
 		}
 		else if (t->flag & T_POSE) {
 			mul_v3_m4v3(co, t->poseobj->obmat, td->center);
+			axismtx = td->axismtx;
 		}
 		else {
 			copy_v3_v3(co, td->center);
+			axismtx = td->axismtx;
 		}
 
 		if (t->con.mode & CON_AXIS0) {
-			drawLine(t, td->center, td->axismtx[0], 'X', options);
+			drawLine(t, co, axismtx[0], 'X', options);
 		}
 		if (t->con.mode & CON_AXIS1) {
-			drawLine(t, td->center, td->axismtx[1], 'Y', options);
+			drawLine(t, co, axismtx[1], 'Y', options);
 		}
 		if (t->con.mode & CON_AXIS2) {
-			drawLine(t, td->center, td->axismtx[2], 'Z', options);
+			drawLine(t, co, axismtx[2], 'Z', options);
 		}
 		options &= ~DRAWLIGHT;
 	}

Modified: trunk/blender/source/blender/editors/transform/transform_generics.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_generics.c	2013-04-12 01:52:30 UTC (rev 55978)
+++ trunk/blender/source/blender/editors/transform/transform_generics.c	2013-04-12 02:16:44 UTC (rev 55979)
@@ -1027,7 +1027,12 @@
 	t->ar = ar;
 	t->obedit = obedit;
 	t->settings = ts;
-	
+
+	if (obedit) {
+		copy_m3_m4(t->obedit_mat, obedit->obmat);
+		normalize_m3(t->obedit_mat);
+	}
+
 	t->data = NULL;
 	t->ext = NULL;
 	




More information about the Bf-blender-cvs mailing list