[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25280] trunk/blender: Durian Request: Default F-Curve Auto-Colour Modes

Joshua Leung aligorith at gmail.com
Thu Dec 10 11:40:28 CET 2009


Revision: 25280
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25280
Author:   aligorith
Date:     2009-12-10 11:40:28 +0100 (Thu, 10 Dec 2009)

Log Message:
-----------
Durian Request: Default F-Curve Auto-Colour Modes

Added option to KeyingSets+Keyframing Functions which makes newly added F-Curves for Transforms + Colours to use the colour mode which uses the array index to determine the colour of the F-Curve. 

The main implication of this is that when this option is enabled for a KeyingSet, all sets of XYZ F-Curves (i.e. location, rotation, scale) for transforms will be shown in Red/Green/Blue instead of some automatically determined "rainbow" colour. Useful for animators far too used to Maya's Graph Editor :P

This setting is named, "XYZ to RGB", though that doesn't make its purpose entirely clear.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_scene.py
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/editors/include/ED_keyframing.h
    trunk/blender/source/blender/makesdna/DNA_anim_types.h
    trunk/blender/source/blender/makesrna/intern/rna_animation.c

Modified: trunk/blender/release/scripts/ui/properties_scene.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_scene.py	2009-12-10 10:36:32 UTC (rev 25279)
+++ trunk/blender/release/scripts/ui/properties_scene.py	2009-12-10 10:40:28 UTC (rev 25280)
@@ -100,7 +100,8 @@
                 col = row.column()
             col.label(text="Keyframing Settings:")
             col.prop(ks, "insertkey_needed", text="Needed")
-            col.prop(ks, "insertkey_visual", text="Visual")
+            col.prop(ks, "insertkey_visual", text="Visual")	
+            col.prop(ks, "insertkey_xyz_to_rgb", text="XYZ to RGB")
 
 
 class SCENE_PT_keying_set_paths(SceneButtonsPanel):

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c	2009-12-10 10:36:32 UTC (rev 25279)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2009-12-10 10:40:28 UTC (rev 25280)
@@ -274,6 +274,7 @@
 	beztr.ipo= U.ipo_new; /* use default interpolation mode here... */
 	beztr.f1= beztr.f2= beztr.f3= SELECT;
 	beztr.h1= beztr.h2= HD_AUTO; // XXX what about when we replace an old one?
+	//BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
 	
 	/* add temp beztriple to keyframes */
 	a= insert_bezt_fcurve(fcu, &beztr, flag);
@@ -809,7 +810,7 @@
 		return 0;
 	}
 	
-	/* get F-Curve - if no action is provided, keyframe to the default one attached to this ID-block */
+	/* if no action is provided, keyframe to the default one attached to this ID-block */
 	if (act == NULL) {
 		AnimData *adt= BKE_animdata_from_id(id);
 		
@@ -842,8 +843,19 @@
 	
 	/* will only loop once unless the array index was -1 */
 	for (; array_index < array_index_max; array_index++) {
+		/* make sure the F-Curve exists */
 		fcu= verify_fcurve(act, group, rna_path, array_index, 1);
 		
+		/* set color mode if the F-Curve is new (i.e. without any keyframes) */
+		if ((fcu->totvert == 0) && (flag & INSERTKEY_XYZ2RGB)) {
+			/* for Loc/Rot/Scale and also Color F-Curves, the color of the F-Curve in the Graph Editor,
+			 * is determined by the array index for the F-Curve
+			 */
+			if (ELEM4(RNA_property_subtype(prop), PROP_TRANSLATION, PROP_XYZ, PROP_EULER, PROP_COLOR)) {
+				fcu->color_mode= FCURVE_COLOR_AUTO_RGB;
+			}
+		}
+		
 		/* insert keyframe */
 		ret += insert_keyframe_direct(ptr, prop, fcu, cfra, flag);
 	}

Modified: trunk/blender/source/blender/editors/include/ED_keyframing.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_keyframing.h	2009-12-10 10:36:32 UTC (rev 25279)
+++ trunk/blender/source/blender/editors/include/ED_keyframing.h	2009-12-10 10:40:28 UTC (rev 25280)
@@ -149,7 +149,7 @@
 /* Main Driver Management API calls:
  * 	Add a new driver for the specified property on the given ID block
  */
-short ANIM_add_driver (struct ID *id, const char rna_path[], int array_index, short flag, int type);
+short ANIM_add_driver(struct ID *id, const char rna_path[], int array_index, short flag, int type);
 
 /* Main Driver Management API calls:
  * 	Remove the driver for the specified property on the given ID block (if available)

Modified: trunk/blender/source/blender/makesdna/DNA_anim_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_anim_types.h	2009-12-10 10:36:32 UTC (rev 25279)
+++ trunk/blender/source/blender/makesdna/DNA_anim_types.h	2009-12-10 10:40:28 UTC (rev 25280)
@@ -291,8 +291,8 @@
 	/* python expression to execute (may call functions defined in an accessory file) 
 	 * which relates the target 'variables' in some way to yield a single usable value
 	 */
-	char expression[256];
-	void *expr_comp; /* PyObject - compiled expression, dont save this */
+	char expression[256];	/* expression to compile for evaluation */
+	void *expr_comp; 		/* PyObject - compiled expression, dont save this */
 	
 	float curval;		/* result of previous evaluation, for subtraction from result under certain circumstances */
 	float influence;	/* influence of driver on result */ // XXX to be implemented... this is like the constraint influence setting
@@ -323,8 +323,8 @@
 		/* driver does replace value, but overrides (for layering of animation over driver) */
 		// TODO: this needs to be implemented at some stage or left out...
 	DRIVER_FLAG_LAYERING	= (1<<2),
-
-	DRIVER_FLAG_RECOMPILE	= (1<<3), /* use when the expression needs to be recompiled */
+		/* use when the expression needs to be recompiled */
+	DRIVER_FLAG_RECOMPILE	= (1<<3), 
 } eDriver_Flags;
 
 /* F-Curves -------------------------------------- */
@@ -367,7 +367,7 @@
 	char *rna_path;			/* RNA-path to resolve data-access */
 	
 		/* curve coloring (for editor) */
-	int color_mode;			/* coloring method to use */
+	int color_mode;			/* coloring method to use (eFCurve_Coloring) */
 	float color[3];			/* the last-color this curve took */
 } FCurve;
 
@@ -703,6 +703,7 @@
 	INSERTKEY_FAST 		= (1<<2),	/* don't recalculate handles,etc. after adding key */
 	INSERTKEY_FASTR		= (1<<3),	/* don't realloc mem (or increase count, as array has already been set out) */
 	INSERTKEY_REPLACE 	= (1<<4),	/* only replace an existing keyframe (this overrides INSERTKEY_NEEDED) */
+	INSERTKEY_XYZ2RGB	= (1<<5),	/* transform F-Curves should have XYZ->RGB color mode */
 } eInsertKeyFlags;
 
 /* ************************************************ */

Modified: trunk/blender/source/blender/makesrna/intern/rna_animation.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_animation.c	2009-12-10 10:36:32 UTC (rev 25279)
+++ trunk/blender/source/blender/makesrna/intern/rna_animation.c	2009-12-10 10:40:28 UTC (rev 25280)
@@ -267,6 +267,10 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "keyingflag", INSERTKEY_MATRIX);
 	RNA_def_property_ui_text(prop, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'.");
 	
+	prop= RNA_def_property(srna, "insertkey_xyz_to_rgb", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "keyingflag", INSERTKEY_XYZ2RGB);
+	RNA_def_property_ui_text(prop, "XYZ Transforms to RGB", "Color for newly added transformation F-Curves (Location, Rotation, Scale) and also Color is based on the transform axis.");
+	
 	/* Keying Set API */
 	RNA_api_keyingset(srna);
 }





More information about the Bf-blender-cvs mailing list