[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19212] branches/blender2.5/blender/source /blender: Transform fun

Martin Poirier theeth at yahoo.com
Fri Mar 6 16:50:15 CET 2009


Revision: 19212
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19212
Author:   theeth
Date:     2009-03-06 16:50:15 +0100 (Fri, 06 Mar 2009)

Log Message:
-----------
Transform fun

extracting params in split transform operators.

work in progress still, but lots of fun with operator replay (F6)

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
    branches/blender2.5/blender/source/blender/editors/include/BIF_transform.h
    branches/blender2.5/blender/source/blender/editors/transform/transform.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.h
    branches/blender2.5/blender/source/blender/editors/transform/transform_constraints.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_generics.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_ops.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_orientations.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-03-06 15:46:13 UTC (rev 19211)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-03-06 15:50:15 UTC (rev 19212)
@@ -287,6 +287,8 @@
 	sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
 	sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
 
+	sce->toolsettings->proportional_size = 1.0f;
+
 	pset= &sce->toolsettings->particle;
 	pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER;
 	pset->emitterdist= 0.25f;

Modified: branches/blender2.5/blender/source/blender/editors/include/BIF_transform.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/BIF_transform.h	2009-03-06 15:46:13 UTC (rev 19211)
+++ branches/blender2.5/blender/source/blender/editors/include/BIF_transform.h	2009-03-06 15:50:15 UTC (rev 19212)
@@ -56,7 +56,6 @@
 	TFM_WARP,
 	TFM_SHRINKFATTEN,
 	TFM_TILT,
-	TFM_LAMP_ENERGY,
 	TFM_TRACKBALL,
 	TFM_PUSHPULL,
 	TFM_CREASE,

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.c	2009-03-06 15:46:13 UTC (rev 19211)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.c	2009-03-06 15:50:15 UTC (rev 19212)
@@ -772,7 +772,7 @@
 			break;
 		case PADPLUSKEY:
 			if(event->keymodifier & KM_ALT && t->flag & T_PROP_EDIT) {
-				t->propsize*= 1.1f;
+				t->prop_size*= 1.1f;
 				calculatePropRatio(t);
 			}
 			t->redraw= 1;
@@ -783,7 +783,7 @@
 				transform_autoik_update(t, 1);
 			}
 			else if(t->flag & T_PROP_EDIT) {
-				t->propsize*= 1.1f;
+				t->prop_size*= 1.1f;
 				calculatePropRatio(t);
 			}
 			else view_editmove(event->type);
@@ -791,7 +791,7 @@
 			break;
 		case PADMINUS:
 			if(event->keymodifier & KM_ALT && t->flag & T_PROP_EDIT) {
-				t->propsize*= 0.90909090f;
+				t->prop_size*= 0.90909090f;
 				calculatePropRatio(t);
 			}
 			t->redraw= 1;
@@ -802,7 +802,7 @@
 				transform_autoik_update(t, -1);
 			}
 			else if (t->flag & T_PROP_EDIT) {
-				t->propsize*= 0.90909090f;
+				t->prop_size*= 0.90909090f;
 				calculatePropRatio(t);
 			}
 			else view_editmove(event->type);
@@ -903,7 +903,7 @@
 	
 	t->mode = TFM_DUMMY;
 
-	initTransInfo(C, t, event);					// internal data, mouse, vectors
+	initTransInfo(C, t, NULL, event);					// internal data, mouse, vectors
 
 	createTransData(C, t);			// make TransData structs from selection
 
@@ -942,21 +942,85 @@
 
 void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 {
-	short twmode= (t->spacetype==SPACE_VIEW3D)? ((View3D*)t->view)->twmode: V3D_MANIP_GLOBAL;
+	Scene *sce = CTX_data_scene(C);
+	int constraint_axis[3] = {0, 0, 0};
+	int proportional = 0;
 
 	RNA_int_set(op->ptr, "mode", t->mode);
 	RNA_int_set(op->ptr, "options", t->options);
-	RNA_float_set_array(op->ptr, "values", t->values);
 
+	if (t->flag & T_AUTOVALUES)
+	{
+		RNA_float_set_array(op->ptr, "value", t->auto_values);
+	}
+	else
+	{
+		RNA_float_set_array(op->ptr, "value", t->values);
+	}
+
+	/* XXX convert stupid flag to enum */
+	switch(t->flag & (T_PROP_EDIT|T_PROP_CONNECTED))
+	{
+	case (T_PROP_EDIT|T_PROP_CONNECTED):
+		proportional = 2;
+		break;
+	case T_PROP_EDIT:
+		proportional = 1;
+		break;
+	default:
+		proportional = 0;
+	}
+
+	if (RNA_struct_find_property(op->ptr, "proportional"))
+	{
+		RNA_enum_set(op->ptr, "proportional", proportional);
+		RNA_enum_set(op->ptr, "proportional_mode", t->prop_mode);
+		RNA_float_set(op->ptr, "proportional_size", t->prop_size);
+	}
+
+	if (RNA_struct_find_property(op->ptr, "mirror"))
+	{
+		RNA_boolean_set(op->ptr, "mirror", t->flag & T_MIRROR);
+	}
 	
-	RNA_int_set(op->ptr, "constraint_mode", t->con.mode);
-	RNA_int_set(op->ptr, "constraint_orientation", twmode);
-	RNA_float_set_array(op->ptr, "constraint_matrix", (float*)t->con.mtx);
+	if (RNA_struct_find_property(op->ptr, "constraint_mode"))
+	{
+		RNA_int_set(op->ptr, "constraint_mode", t->con.mode);
+		RNA_int_set(op->ptr, "constraint_orientation", t->current_orientation);
+
+		if (t->con.mode & CON_APPLY)
+		{
+			if (t->con.mode & CON_AXIS0) {
+				constraint_axis[0] = 1;
+			}
+			if (t->con.mode & CON_AXIS1) {
+				constraint_axis[1] = 1;
+			}
+			if (t->con.mode & CON_AXIS2) {
+				constraint_axis[2] = 1;
+			}
+		}
+
+		RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
+	}
+
+	// XXX If modal, save settings back in scene
+	if (t->flag & T_MODAL)
+	{
+		sce->prop_mode = t->prop_mode;
+		sce->proportional = proportional;
+
+		if(t->spacetype == SPACE_VIEW3D)
+		{
+			View3D *v3d = t->view;
+			
+			v3d->twmode = t->current_orientation;
+		}
+	}
 }
 
-void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
+void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int mode)
 {
-	int mode    = RNA_int_get(op->ptr, "mode");
 	int options = RNA_int_get(op->ptr, "options");
 
 	/* added initialize, for external calls to set stuff in TransInfo, like undo string */
@@ -967,8 +1031,8 @@
 	
 	t->mode = mode;
 
-	initTransInfo(C, t, event);					// internal data, mouse, vectors
-	
+	initTransInfo(C, t, op, event);					// internal data, mouse, vectors
+
 	initTransformOrientation(C, t);
 
 	if(t->spacetype == SPACE_VIEW3D)
@@ -1094,26 +1158,40 @@
 		initAlign(t);
 		break;
 	}
-	
+
 	/* overwrite initial values if operator supplied a non-null vector */
-	if (RNA_property_is_set(op->ptr, "values"))
+	if (RNA_property_is_set(op->ptr, "value"))
 	{
 		float values[4];
-		RNA_float_get_array(op->ptr, "values", values);
+		RNA_float_get_array(op->ptr, "value", values);
 		QUATCOPY(t->values, values);
+		QUATCOPY(t->auto_values, values);
+		t->flag |= T_AUTOVALUES;
 	}
 
 	/* Constraint init from operator */
+	if (RNA_property_is_set(op->ptr, "constraint_axis"))
 	{
-		t->con.mode = RNA_int_get(op->ptr, "constraint_mode");
-		
-		if (t->con.mode & CON_APPLY)
+		int constraint_axis[3];
+
+		RNA_boolean_get_array(op->ptr, "constraint_axis", constraint_axis);
+
+		if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2])
 		{
-			RNA_float_get_array(op->ptr, "constraint_matrix", (float*)t->spacemtx);
-			
+			t->con.mode |= CON_APPLY;
+
+			if (constraint_axis[0]) {
+				t->con.mode |= CON_AXIS0;
+			}
+			if (constraint_axis[1]) {
+				t->con.mode |= CON_AXIS1;
+			}
+			if (constraint_axis[2]) {
+				t->con.mode |= CON_AXIS2;
+			}
+				
 			setUserConstraint(t, t->con.mode, "%s");		
 		}
-
 	}
 }
 
@@ -2227,6 +2305,13 @@
 
 	applySnapping(t, size);
 
+	if (t->flag & T_AUTOVALUES)
+	{
+		VECCOPY(size, t->auto_values);
+	}
+
+	VECCOPY(t->values, size);
+
 	SizeToMat3(size, mat);
 
 	if (t->con.applySize) {

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.h	2009-03-06 15:46:13 UTC (rev 19211)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.h	2009-03-06 15:50:15 UTC (rev 19212)
@@ -214,7 +214,7 @@
     NDofInput   ndof;           /* ndof input                           */
     MouseInput	mouse;			/* mouse input                          */
     char        redraw;         /* redraw flag                          */
-	float		propsize;		/* proportional circle radius           */
+	float		prop_size;		/* proportional circle radius           */
 	char		proptext[20];	/* proportional falloff text			*/
     float       center[3];      /* center of transformation             */
     int         center2d[2];    /* center in screen coordinates         */
@@ -245,7 +245,12 @@
 
 	/*************** NEW STUFF *********************/
 
+	short		current_orientation;
+
+	short		prop_mode;
+
 	float		values[4];
+	float		auto_values[4];
 	void		*view;
 	struct ScrArea	*sa;
 	struct ARegion	*ar;
@@ -303,6 +308,13 @@
 	/* auto-ik is on */
 #define T_AUTOIK			(1 << 18)
 
+#define T_MIRROR			(1 << 19)
+
+#define T_AUTOVALUES		(1 << 20)
+
+	/* to specificy if we save back settings at the end */
+#define	T_MODAL				(1 << 21)
+
 /* TransInfo->modifiers */
 #define	MOD_CONSTRAINT_SELECT	0x01
 #define	MOD_PRECISION			0x02
@@ -354,7 +366,7 @@
 
 void TFM_OT_transform(struct wmOperatorType *ot);
 
-void initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, struct wmEvent *event);
+void initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, struct wmEvent *event, int mode);
 void saveTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op);
 void transformEvent(TransInfo *t, struct wmEvent *event);
 void transformApply(struct bContext *C, TransInfo *t);
@@ -539,7 +551,7 @@
 
 /*********************** Generics ********************************/
 
-void initTransInfo(struct bContext *C, TransInfo *t, struct wmEvent *event);
+void initTransInfo(struct bContext *C, TransInfo *t, struct wmOperator *op, struct wmEvent *event);
 void postTrans (TransInfo *t);
 void resetTransRestrictions(TransInfo *t);
 

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform_constraints.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform_constraints.c	2009-03-06 15:46:13 UTC (rev 19211)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform_constraints.c	2009-03-06 15:50:15 UTC (rev 19212)
@@ -90,6 +90,28 @@
 static void drawObjectConstraint(TransInfo *t);
 
 /* ************************** CONSTRAINTS ************************* */
+void constraintAutoValues(TransInfo *t, float vec[3])
+{
+	int mode = t->con.mode;
+	if (mode & CON_APPLY)
+	{
+		float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f;
+
+		if ((mode & CON_AXIS0) == 0)
+		{
+			vec[0] = nval;
+		}
+		if ((mode & CON_AXIS1) == 0)
+		{
+			vec[1] = nval;
+		}
+		if ((mode & CON_AXIS2) == 0)
+		{
+			vec[2] = nval;
+		}
+	}
+}
+
 void constraintNumInput(TransInfo *t, float vec[3])
 {
 	int mode = t->con.mode;
@@ -99,6 +121,8 @@
 		if (getConstraintSpaceDimension(t) == 2) {
 			int axis = mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
 			if (axis == (CON_AXIS0|CON_AXIS1)) {
+				vec[0] = vec[0];
+				vec[1] = vec[1];
 				vec[2] = nval;
 			}

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list