[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34646] trunk/blender/source/blender: Logic UI: multiple fixes on Constraint Actuator

Dalai Felinto dfelinto at gmail.com
Fri Feb 4 22:25:58 CET 2011


Revision: 34646
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34646
Author:   dfelinto
Date:     2011-02-04 21:25:57 +0000 (Fri, 04 Feb 2011)
Log Message:
-----------
Logic UI: multiple fixes on Constraint Actuator
1) damping factor is not percentage (it's in frames, who would know that)
2) angles as degrees (cleaning the tooltips for those too)
3) setting Direction to None when changing from Loc and Fh Consts to Ori - negative axis is not supported in Ori Const. Buggy since ever (2.49).

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_logic/logic_window.c
    trunk/blender/source/blender/makesrna/intern/rna_actuator.c

Modified: trunk/blender/source/blender/editors/space_logic/logic_window.c
===================================================================
--- trunk/blender/source/blender/editors/space_logic/logic_window.c	2011-02-04 21:10:27 UTC (rev 34645)
+++ trunk/blender/source/blender/editors/space_logic/logic_window.c	2011-02-04 21:25:57 UTC (rev 34646)
@@ -3814,7 +3814,7 @@
 			break;
 
 		case ACT_CONST_TYPE_ORI:
-			uiItemR(layout, ptr, "direction_axis", 0, NULL, ICON_NULL);
+			uiItemR(layout, ptr, "direction_axis_pos", 0, NULL, ICON_NULL);
 
 			row=uiLayoutRow(layout, 1);
 			uiItemR(row, ptr, "damping", UI_ITEM_R_SLIDER , NULL, ICON_NULL);

Modified: trunk/blender/source/blender/makesrna/intern/rna_actuator.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_actuator.c	2011-02-04 21:10:27 UTC (rev 34645)
+++ trunk/blender/source/blender/makesrna/intern/rna_actuator.c	2011-02-04 21:25:57 UTC (rev 34646)
@@ -35,6 +35,8 @@
 
 #include "WM_types.h"
 
+#include "BLI_utildefines.h"
+
 /* Always keep in alphabetical order */
 EnumPropertyItem actuator_type_items[] ={
 	{ACT_ACTION, "ACTION", 0, "Action", ""},
@@ -117,6 +119,29 @@
 	}
 }
 
+static void rna_ConstraintActuator_type_set(struct PointerRNA *ptr, int value)
+{
+	bActuator *act= (bActuator *)ptr->data;
+	bConstraintActuator *ca= act->data;
+	if (value != ca->type)
+	{
+		ca->type = value;
+		switch (ca->type) {
+		case ACT_CONST_TYPE_ORI:
+			/* negative axis not supported in the orientation mode */
+			if (ELEM3(ca->mode, ACT_CONST_DIRNX,ACT_CONST_DIRNY, ACT_CONST_DIRNZ))
+				ca->mode = ACT_CONST_NONE;
+			break;
+
+		case ACT_CONST_TYPE_LOC:
+		case ACT_CONST_TYPE_DIST:
+		case ACT_CONST_TYPE_FH:
+		default:
+			break;
+		}
+	}
+}
+
 static float rna_ConstraintActuator_limitmin_get(struct PointerRNA *ptr)
 {
 	bActuator *act = (bActuator*)ptr->data;
@@ -1076,6 +1101,14 @@
 		{0, NULL, 0, NULL, NULL}
 	};
 
+	static EnumPropertyItem prop_direction_pos_items[] ={
+		{ACT_CONST_NONE, "NONE", 0, "None", ""},
+		{ACT_CONST_DIRPX, "DIRPX", 0, "X axis", ""},
+		{ACT_CONST_DIRPY, "DIRPY", 0, "Y axis", ""},
+		{ACT_CONST_DIRPZ, "DIRPZ", 0, "Z axis", ""},
+		{0, NULL, 0, NULL, NULL}
+	};
+
 	srna= RNA_def_struct(brna, "ConstraintActuator", "Actuator");
 	RNA_def_struct_ui_text(srna, "Constraint Actuator", "Actuator to handle Constraints");
 	RNA_def_struct_sdna_from(srna, "bConstraintActuator", "data");
@@ -1083,6 +1116,7 @@
 	prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "type");
 	RNA_def_property_enum_items(prop, prop_type_items);
+	RNA_def_property_enum_funcs(prop, NULL, "rna_ConstraintActuator_type_set", NULL);
 	RNA_def_property_ui_text(prop, "Constraints Mode", "The type of the constraint");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
@@ -1117,7 +1151,7 @@
 	RNA_def_property_ui_text(prop, "Max", "");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
-	prop= RNA_def_property(srna, "damping", PROP_INT, PROP_PERCENTAGE);
+	prop= RNA_def_property(srna, "damping", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "damp");
 	RNA_def_property_ui_range(prop, 0, 100, 1, 1);
 	RNA_def_property_ui_text(prop, "Damping", "Damping factor: time constant (in frame) of low pass filter");
@@ -1154,13 +1188,19 @@
 	RNA_def_property_ui_text(prop, "Time", "Maximum activation time in frame, 0 for unlimited");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
-	prop= RNA_def_property(srna, "damping_rotation", PROP_INT, PROP_PERCENTAGE);
+	prop= RNA_def_property(srna, "damping_rotation", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "rotdamp");
 	RNA_def_property_ui_range(prop, 0, 100, 1, 1);
 	RNA_def_property_ui_text(prop, "rotDamp", "Use a different damping for orientation");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
 	/* ACT_CONST_TYPE_ORI */
+	prop= RNA_def_property(srna, "direction_axis_pos", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "mode");
+	RNA_def_property_enum_items(prop, prop_direction_pos_items);
+	RNA_def_property_ui_text(prop, "Direction", "Select the axis to be aligned along the reference direction");
+	RNA_def_property_update(prop, NC_LOGIC, NULL);
+
 	prop= RNA_def_property(srna, "rotation_max", PROP_FLOAT, PROP_XYZ);
 	RNA_def_property_float_sdna(prop, NULL, "maxrot");
 	RNA_def_property_array(prop, 3);
@@ -1168,16 +1208,16 @@
 	RNA_def_property_ui_text(prop, "Reference Direction", "Reference Direction");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
-	prop= RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_ANGLE);
 	RNA_def_property_float_sdna(prop, NULL, "minloc[0]");
-	RNA_def_property_ui_range(prop, 0.0, 180.0, 10, 2);
-	RNA_def_property_ui_text(prop, "Min Angle", "Minimum angle (in degree) to maintain with target direction. No correction is done if angle with target direction is between min and max");
+	RNA_def_property_range(prop, 0.0, 180.0);
+	RNA_def_property_ui_text(prop, "Min Angle", "Minimum angle to maintain with target direction. No correction is done if angle with target direction is between min and max");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
-	prop= RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_ANGLE);
 	RNA_def_property_float_sdna(prop, NULL, "maxloc[0]");
-	RNA_def_property_ui_range(prop, 0.0, 180.0, 10, 2);
-	RNA_def_property_ui_text(prop, "Max Angle", "Maximum angle (in degree) allowed with target direction. No correction is done if angle with target direction is between min and max");
+	RNA_def_property_range(prop, 0.0, 180.0);
+	RNA_def_property_ui_text(prop, "Max Angle", "Maximum angle allowed with target direction. No correction is done if angle with target direction is between min and max");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
 	/* ACT_CONST_TYPE_FH */
@@ -1187,7 +1227,7 @@
 	RNA_def_property_ui_text(prop, "Distance", "Height of the Fh area");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
-	prop= RNA_def_property(srna, "spring", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "spring", PROP_FLOAT, PROP_PERCENTAGE);
 	RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_spring_get", "rna_ConstraintActuator_spring_set", NULL);
 	RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2);
 	RNA_def_property_ui_text(prop, "Fh", "Spring force within the Fh area");




More information about the Bf-blender-cvs mailing list