[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27942] trunk/blender: Keyframe Defaults and Cleanups:

Joshua Leung aligorith at gmail.com
Fri Apr 2 03:03:40 CEST 2010


Revision: 27942
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27942
Author:   aligorith
Date:     2010-04-02 03:03:40 +0200 (Fri, 02 Apr 2010)

Log Message:
-----------
Keyframe Defaults and Cleanups: 

This commit fixes reports #21638 and #21818, which were both also Durian feature requests.

Cbanges:
* Added new default setting for the type of handles created when creating keyframes. This can be found in the user-preferences, and is used whenever existing keyframes aren't being overwritten (instead of the value being always taken from the keyframes either side, #21638).

* When keyframing over existing keyframes, only the values will be changed. The handles will be offset by the same amount that the value of the keyframe changed, though how well this works in practice still needs to be tested more thoroughly (#21818, already fixed earlier, but this commit is the full fix).

* When 'free' handles are added by default, they are offset to be +/- 1 frame on either side of the keyframe so that it is obvious that they can be moved. However, they just take the same value of the keyframe since this is easiest.

* Properly initialising handle colour defaults for 3D-View and Graph Editor. Graph Editor's theme userprefs also show these settings now, though the layout is really quick hack-style.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_userpref.py
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/editors/interface/resources.c
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2010-04-02 00:27:30 UTC (rev 27941)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2010-04-02 01:03:40 UTC (rev 27942)
@@ -371,7 +371,8 @@
         col.separator()
 
         col.label(text="New F-Curve Defaults:")
-        col.prop(edit, "new_interpolation_type", text="Interpolation")
+        col.prop(edit, "keyframe_new_interpolation_type", text="Interpolation")
+        col.prop(edit, "keyframe_new_handle_type", text="Handles")
         col.prop(edit, "insertkey_xyz_to_rgb", text="XYZ to RGB")
 
         col.separator()
@@ -707,14 +708,24 @@
             col.prop(graph, "active_channels_group")
             col.prop(graph, "dopesheet_channel")
             col.prop(graph, "dopesheet_subchannel")
-            col.prop(graph, "vertex")
+            col.prop(graph, "frame_current")
 
             col = split.column()
-            col.prop(graph, "frame_current")
+            col.prop(graph, "vertex")
             col.prop(graph, "handle_vertex")
             col.prop(graph, "handle_vertex_select")
             col.separator()
             col.prop(graph, "handle_vertex_size")
+            col.separator()
+            col.separator()
+            col.prop(graph, "handle_free")
+            col.prop(graph, "handle_auto")
+            col.prop(graph, "handle_vect")
+            col.prop(graph, "handle_align")
+            col.prop(graph, "handle_sel_free")
+            col.prop(graph, "handle_sel_auto")
+            col.prop(graph, "handle_sel_vect")
+            col.prop(graph, "handle_sel_align")
 
         elif theme.theme_area == 'FILE_BROWSER':
             file_browse = theme.file_browser

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c	2010-04-02 00:27:30 UTC (rev 27941)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2010-04-02 01:03:40 UTC (rev 27942)
@@ -217,28 +217,16 @@
 		if (replace) {			
 			/* sanity check: 'i' may in rare cases exceed arraylen */
 			if ((i >= 0) && (i < fcu->totvert)) {
-				/* take care with the handletypes and other info if the replacement flags are set */
-				// NOTE: for now, always do non-destructive replace... if everybody likes this, just keep it as default
-				if (1/*flag & INSERTKEY_REPLACE*/) {
-					BezTriple *dst= (fcu->bezt + i);
-					float dy= bezt->vec[1][1] - dst->vec[1][1];
-					
-					/* just apply delta value change to the handle values */
-					dst->vec[0][1] += dy;
-					dst->vec[1][1] += dy;
-					dst->vec[2][1] += dy;
-					
-					// TODO: perform some other operations?
-				}
-				else {
-					char oldKeyType= BEZKEYTYPE(fcu->bezt + i);
-					
-					/* just brutally replace the values */
-					*(fcu->bezt + i) = *bezt;
-					
-					/* special exception for keyframe type - copy value back so that this info isn't lost */
-					BEZKEYTYPE(fcu->bezt + i)= oldKeyType;
-				}
+				/* just change the values when replacing, so as to not overwrite handles */
+				BezTriple *dst= (fcu->bezt + i);
+				float dy= bezt->vec[1][1] - dst->vec[1][1];
+				
+				/* just apply delta value change to the handle values */
+				dst->vec[0][1] += dy;
+				dst->vec[1][1] += dy;
+				dst->vec[2][1] += dy;
+				
+				// TODO: perform some other operations?
 			}
 		}
 		/* keyframing modes allow to not replace keyframe */
@@ -246,14 +234,14 @@
 			/* insert new - if we're not restricted to replacing keyframes only */
 			BezTriple *newb= MEM_callocN((fcu->totvert+1)*sizeof(BezTriple), "beztriple");
 			
-			/* add the beztriples that should occur before the beztriple to be pasted (originally in ei->icu) */
+			/* add the beztriples that should occur before the beztriple to be pasted (originally in fcu) */
 			if (i > 0)
 				memcpy(newb, fcu->bezt, i*sizeof(BezTriple));
 			
 			/* add beztriple to paste at index i */
 			*(newb + i)= *bezt;
 			
-			/* add the beztriples that occur after the beztriple to be pasted (originally in icu) */
+			/* add the beztriples that occur after the beztriple to be pasted (originally in fcu) */
 			if (i < fcu->totvert) 
 				memcpy(newb+i+1, fcu->bezt+i, (fcu->totvert-i)*sizeof(BezTriple));
 			
@@ -300,15 +288,15 @@
 	
 	/* set all three points, for nicer start position */
 	memset(&beztr, 0, sizeof(BezTriple));
-	beztr.vec[0][0]= x; 
+	beztr.vec[0][0]= x-1.0f; 
 	beztr.vec[0][1]= y;
 	beztr.vec[1][0]= x;
 	beztr.vec[1][1]= y;
-	beztr.vec[2][0]= x;
+	beztr.vec[2][0]= x+1.0f;
 	beztr.vec[2][1]= y;
 	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?
+	beztr.h1= beztr.h2= U.keyhandles_new; /* use default handle type here */
 	//BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
 	
 	/* add temp beztriple to keyframes */
@@ -329,18 +317,9 @@
 	/* set handletype and interpolation */
 	if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE)==0) {
 		BezTriple *bezt= (fcu->bezt + a);
-		char h1, h2;
 		
-		/* set handles (autohandles by default) */
-		h1= h2= HD_AUTO;
-		
-		if (a > 0) h1= (bezt-1)->h2;
-		if (a < fcu->totvert-1) h2= (bezt+1)->h1;
-		
-		bezt->h1= h1;
-		bezt->h2= h2;
-		
 		/* set interpolation from previous (if available) */
+		// FIXME: this doesn't work if user tweaked the interpolation specifically, and they were just overwriting some existing key in the process...
 		if (a > 0) bezt->ipo= (bezt-1)->ipo;
 		else if (a < fcu->totvert-1) bezt->ipo= (bezt+1)->ipo;
 			

Modified: trunk/blender/source/blender/editors/interface/resources.c
===================================================================
--- trunk/blender/source/blender/editors/interface/resources.c	2010-04-02 00:27:30 UTC (rev 27941)
+++ trunk/blender/source/blender/editors/interface/resources.c	2010-04-02 01:03:40 UTC (rev 27942)
@@ -1412,6 +1412,35 @@
 		if (U.flag & USER_LMOUSESELECT) 
 			U.flag &= ~USER_TWOBUTTONMOUSE;
 	}
+	if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 4)) {
+		bTheme *btheme;
+		
+		/* default new handle type is auto handles */
+		U.keyhandles_new = HD_AUTO;
+		
+		/* init new curve colors */
+		for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+			/* init colors used for handles in 3D-View  */
+			SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
+			SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
+			SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
+			SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
+			SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
+			SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
+			SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
+			SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
+			
+			/* same colors again for Graph Editor... */
+			SETCOL(btheme->tipo.handle_free, 0, 0, 0, 255);
+			SETCOL(btheme->tipo.handle_auto, 0x90, 0x90, 0x00, 255);
+			SETCOL(btheme->tipo.handle_vect, 0x40, 0x90, 0x30, 255);
+			SETCOL(btheme->tipo.handle_align, 0x80, 0x30, 0x60, 255);
+			SETCOL(btheme->tipo.handle_sel_free, 0, 0, 0, 255);
+			SETCOL(btheme->tipo.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
+			SETCOL(btheme->tipo.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
+			SETCOL(btheme->tipo.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
+		}
+	}
 
 	
 	/* GL Texture Garbage Collection (variable abused above!) */

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2010-04-02 00:27:30 UTC (rev 27941)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2010-04-02 01:03:40 UTC (rev 27942)
@@ -355,9 +355,10 @@
 	short smooth_viewtx;	/* miliseconds to spend spinning the view */
 	short glreslimit;
 	short ndof_pan, ndof_rotate;
-	short curssize, ipo_new;
+	short curssize;
 	short color_picker_type;
-	short pad2;
+	short ipo_new;			/* interpolation mode for newly added F-Curves */
+	short keyhandles_new;	/* handle types for newly added keyframes */
 
 	short scrcastfps;		/* frame rate for screencast to be played back */
 	short scrcastwait;		/* milliseconds between screencast snapshots */

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2010-04-02 00:27:30 UTC (rev 27941)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2010-04-02 01:03:40 UTC (rev 27942)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "rna_internal.h"
 
@@ -702,40 +703,42 @@
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
 }
 
-static void rna_def_userdef_theme_spaces_curves(StructRNA *srna)
+static void rna_def_userdef_theme_spaces_curves(StructRNA *srna, short incl_nurbs)
 {
 	PropertyRNA *prop;
+	
+	if (incl_nurbs) {
+		prop= RNA_def_property(srna, "nurb_uline", PROP_FLOAT, PROP_COLOR);
+		RNA_def_property_float_sdna(prop, NULL, "nurb_uline");
+		RNA_def_property_array(prop, 3);
+		RNA_def_property_ui_text(prop, "Nurb U-lines", "");
+		RNA_def_property_update(prop, 0, "rna_userdef_update");
 
-	prop= RNA_def_property(srna, "nurb_uline", PROP_FLOAT, PROP_COLOR);
-	RNA_def_property_float_sdna(prop, NULL, "nurb_uline");
-	RNA_def_property_array(prop, 3);
-	RNA_def_property_ui_text(prop, "Nurb U-lines", "");
-	RNA_def_property_update(prop, 0, "rna_userdef_update");
+		prop= RNA_def_property(srna, "nurb_vline", PROP_FLOAT, PROP_COLOR);
+		RNA_def_property_float_sdna(prop, NULL, "nurb_vline");
+		RNA_def_property_array(prop, 3);
+		RNA_def_property_ui_text(prop, "Nurb V-lines", "");
+		RNA_def_property_update(prop, 0, "rna_userdef_update");
 
-	prop= RNA_def_property(srna, "nurb_vline", PROP_FLOAT, PROP_COLOR);
-	RNA_def_property_float_sdna(prop, NULL, "nurb_vline");
-	RNA_def_property_array(prop, 3);
-	RNA_def_property_ui_text(prop, "Nurb V-lines", "");
-	RNA_def_property_update(prop, 0, "rna_userdef_update");
+		prop= RNA_def_property(srna, "nurb_sel_uline", PROP_FLOAT, PROP_COLOR);
+		RNA_def_property_float_sdna(prop, NULL, "nurb_sel_uline");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list