[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12244] trunk/blender/source/blender/src/ transform_constraints.c: IPO-Transform Bugfix:

Joshua Leung aligorith at gmail.com
Tue Oct 9 11:30:23 CEST 2007


Revision: 12244
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12244
Author:   aligorith
Date:     2007-10-09 11:30:22 +0200 (Tue, 09 Oct 2007)

Log Message:
-----------
IPO-Transform Bugfix:

Now MMB-constraint select should now work better than it did after the refactor. I've made some changes to setNearestAxis so that it is now an entrypoint from which spacetype (currently divided into 3D or 2D) specific methods can be used. The old code for this (IPO MMB-constraint) has effectively been restored.

Modified Paths:
--------------
    trunk/blender/source/blender/src/transform_constraints.c

Modified: trunk/blender/source/blender/src/transform_constraints.c
===================================================================
--- trunk/blender/source/blender/src/transform_constraints.c	2007-10-09 07:49:54 UTC (rev 12243)
+++ trunk/blender/source/blender/src/transform_constraints.c	2007-10-09 09:30:22 UTC (rev 12244)
@@ -840,24 +840,40 @@
 	t->redraw = 1;
 }
 
-void setNearestAxis(TransInfo *t)
+static void setNearestAxis2d(TransInfo *t)
 {
+	short mval[2];
+	short ival[2];
+	
+	getmouseco_areawin(mval);
+	ival[0]= t->imval[0];
+	ival[1]= t->imval[1];
+	
+	/* no correction needed... just use whichever one is lower */
+	if ( abs(mval[0]-ival[0]) > abs(mval[1]-ival[1]) ) {
+		t->con.mode |= CON_AXIS1;
+		sprintf(t->con.text, " along Y axis");
+	}
+	else {
+		t->con.mode |= CON_AXIS0;
+		sprintf(t->con.text, " along X axis");
+	}
+}
+
+static void setNearestAxis3d(TransInfo *t)
+{
 	float zfac;
 	float mvec[3], axis[3], proj[3];
 	float len[3];
 	int i, icoord[2];
 	short coord[2];
-
-	t->con.mode &= ~CON_AXIS0;
-	t->con.mode &= ~CON_AXIS1;
-	t->con.mode &= ~CON_AXIS2;
-
+	
+	/* calculate mouse movement */
 	getmouseco_areawin(coord);
 	mvec[0] = (float)(coord[0] - t->con.imval[0]);
 	mvec[1] = (float)(coord[1] - t->con.imval[1]);
 	mvec[2] = 0.0f;
-
-		
+	
 	/* we need to correct axis length for the current zoomlevel of view,
 	   this to prevent projected values to be clipped behind the camera
 	   and to overflow the short integers.
@@ -920,6 +936,25 @@
 			sprintf(t->con.text, " along %s Z axis", t->spacename);
 		}
 	}
+}
+
+void setNearestAxis(TransInfo *t)
+{
+	/* clear any prior constraint flags */
+	t->con.mode &= ~CON_AXIS0;
+	t->con.mode &= ~CON_AXIS1;
+	t->con.mode &= ~CON_AXIS2;
+
+	/* constraint setting - depends on spacetype */
+	if (t->spacetype == SPACE_VIEW3D) {
+		/* 3d-view */
+		setNearestAxis3d(t);	
+	}
+	else {
+		/* assume that this means a 2D-Editor */
+		setNearestAxis2d(t);
+	}
+	
 	getConstraintMatrix(t);
 }
 





More information about the Bf-blender-cvs mailing list