[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25716] trunk/blender/source/blender/ editors/transform: transform:

Martin Poirier theeth at yahoo.com
Mon Jan 4 21:49:42 CET 2010


Revision: 25716
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25716
Author:   theeth
Date:     2010-01-04 21:49:42 +0100 (Mon, 04 Jan 2010)

Log Message:
-----------
transform:

Rotation operator now saves axis of rotation (when not using a constraint). Better for operator redo and tweak (would use a Z axis because of matrix init)

Also fix crash in Translation operator redo and tweak (rv3d is not always available).

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

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2010-01-04 20:18:13 UTC (rev 25715)
+++ trunk/blender/source/blender/editors/transform/transform.c	2010-01-04 20:49:42 UTC (rev 25716)
@@ -1384,6 +1384,11 @@
 		RNA_float_set(op->ptr, "proportional_size", t->prop_size);
 	}
 
+	if (RNA_struct_find_property(op->ptr, "axis"))
+	{
+		RNA_float_set_array(op->ptr, "axis", t->axis);
+	}
+
 	if (RNA_struct_find_property(op->ptr, "mirror"))
 	{
 		RNA_boolean_set(op->ptr, "mirror", t->flag & T_MIRROR);
@@ -1577,6 +1582,13 @@
 		t->flag |= T_AUTOVALUES;
 	}
 
+	/* Transformation axis from operator */
+	if (RNA_struct_find_property(op->ptr, "axis") && RNA_property_is_set(op->ptr, "axis"))
+	{
+		RNA_float_get_array(op->ptr, "axis", t->axis);
+		normalize_v3(t->axis);
+	}
+
 	/* Constraint init from operator */
 	if (RNA_struct_find_property(op->ptr, "constraint_axis") && RNA_property_is_set(op->ptr, "constraint_axis"))
 	{
@@ -2662,6 +2674,10 @@
 	
 	if (t->flag & T_2D_EDIT)
 		t->flag |= T_NO_CONSTRAINT;
+
+	VECCOPY(t->axis, t->viewinv[2]);
+	mul_v3_fl(t->axis, -1.0f);
+	normalize_v3(t->axis);
 }
 
 static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short around) {
@@ -2906,13 +2922,8 @@
 	
 	float final;
 	
-	float axis[3];
 	float mat[3][3];
 	
-	VECCOPY(axis, t->viewinv[2]);
-	mul_v3_fl(axis, -1.0f);
-	normalize_v3(axis);
-	
 	final = t->values[0];
 	
 	applyNDofInput(&t->ndof, &final);
@@ -2920,7 +2931,7 @@
 	snapGrid(t, &final);
 	
 	if (t->con.applyRot) {
-		t->con.applyRot(t, NULL, axis, &final);
+		t->con.applyRot(t, NULL, t->axis, &final);
 	}
 	
 	applySnapping(t, &final);
@@ -2947,13 +2958,13 @@
 		sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext);
 	}
 	
-	vec_rot_to_mat3( mat,axis, final);
+	vec_rot_to_mat3( mat, t->axis, final);
 	
 	// TRANSFORM_FIX_ME
 //	t->values[0] = final;		// used in manipulator
 //	copy_m3_m3(t->mat, mat);	// used in manipulator
 	
-	applyRotation(t, final, axis);
+	applyRotation(t, final, t->axis);
 	
 	recalcData(t);
 	
@@ -3085,9 +3096,11 @@
 	if(t->spacetype == SPACE_VIEW3D) {
 		RegionView3D *rv3d = t->ar->regiondata;
 
-		t->snap[0] = 0.0f;
-		t->snap[1] = rv3d->gridview * 1.0f;
-		t->snap[2] = t->snap[1] * 0.1f;
+		if (rv3d) {
+			t->snap[0] = 0.0f;
+			t->snap[1] = rv3d->gridview * 1.0f;
+			t->snap[2] = t->snap[1] * 0.1f;
+		}
 	}
 	else if(t->spacetype == SPACE_IMAGE) {
 		t->snap[0] = 0.0f;

Modified: trunk/blender/source/blender/editors/transform/transform.h
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.h	2010-01-04 20:18:13 UTC (rev 25715)
+++ trunk/blender/source/blender/editors/transform/transform.h	2010-01-04 20:49:42 UTC (rev 25716)
@@ -315,6 +315,8 @@
 
 	float		values[4];
 	float		auto_values[4];
+	float		axis[3];
+
 	void		*view;
 	struct ScrArea	*sa;
 	struct ARegion	*ar;

Modified: trunk/blender/source/blender/editors/transform/transform_ops.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_ops.c	2010-01-04 20:18:13 UTC (rev 25715)
+++ trunk/blender/source/blender/editors/transform/transform_ops.c	2010-01-04 20:49:42 UTC (rev 25716)
@@ -385,6 +385,15 @@
 	RNA_def_float(ot->srna, "proportional_size", 1, 0, FLT_MAX, "Proportional Size", "", 0, 100);
 }
 
+void Properties_Axis(struct wmOperatorType *ot)
+{
+	PropertyRNA *prop;
+
+	prop= RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION);
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_ui_text(prop, "Axis", "The axis around which the transformation occurs.");
+}
+
 void Properties_Snapping(struct wmOperatorType *ot, short fullsnap, short align)
 {
 	RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", "");
@@ -504,6 +513,8 @@
 
 	RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2);
 
+	Properties_Axis(ot);
+
 	Properties_Proportional(ot);
 
 	RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
@@ -757,6 +768,8 @@
 
 	RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
 
+	Properties_Axis(ot);
+
 	Properties_Proportional(ot);
 	RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
 





More information about the Bf-blender-cvs mailing list