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.
This commit is contained in:
Joshua Leung 2010-04-02 01:03:40 +00:00
parent 248f1380af
commit c6b77a06dd
5 changed files with 102 additions and 80 deletions

@ -371,7 +371,8 @@ class USERPREF_PT_edit(bpy.types.Panel):
col.separator() col.separator()
col.label(text="New F-Curve Defaults:") 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.prop(edit, "insertkey_xyz_to_rgb", text="XYZ to RGB")
col.separator() col.separator()
@ -707,14 +708,24 @@ class USERPREF_PT_theme(bpy.types.Panel):
col.prop(graph, "active_channels_group") col.prop(graph, "active_channels_group")
col.prop(graph, "dopesheet_channel") col.prop(graph, "dopesheet_channel")
col.prop(graph, "dopesheet_subchannel") col.prop(graph, "dopesheet_subchannel")
col.prop(graph, "vertex") col.prop(graph, "frame_current")
col = split.column() col = split.column()
col.prop(graph, "frame_current") col.prop(graph, "vertex")
col.prop(graph, "handle_vertex") col.prop(graph, "handle_vertex")
col.prop(graph, "handle_vertex_select") col.prop(graph, "handle_vertex_select")
col.separator() col.separator()
col.prop(graph, "handle_vertex_size") 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': elif theme.theme_area == 'FILE_BROWSER':
file_browse = theme.file_browser file_browse = theme.file_browser

@ -217,28 +217,16 @@ int insert_bezt_fcurve (FCurve *fcu, BezTriple *bezt, short flag)
if (replace) { if (replace) {
/* sanity check: 'i' may in rare cases exceed arraylen */ /* sanity check: 'i' may in rare cases exceed arraylen */
if ((i >= 0) && (i < fcu->totvert)) { if ((i >= 0) && (i < fcu->totvert)) {
/* take care with the handletypes and other info if the replacement flags are set */ /* just change the values when replacing, so as to not overwrite handles */
// NOTE: for now, always do non-destructive replace... if everybody likes this, just keep it as default BezTriple *dst= (fcu->bezt + i);
if (1/*flag & INSERTKEY_REPLACE*/) { float dy= bezt->vec[1][1] - dst->vec[1][1];
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;
/* just apply delta value change to the handle values */ dst->vec[1][1] += dy;
dst->vec[0][1] += dy; dst->vec[2][1] += dy;
dst->vec[1][1] += dy;
dst->vec[2][1] += dy; // TODO: perform some other operations?
// 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;
}
} }
} }
/* keyframing modes allow to not replace keyframe */ /* keyframing modes allow to not replace keyframe */
@ -246,14 +234,14 @@ int insert_bezt_fcurve (FCurve *fcu, BezTriple *bezt, short flag)
/* insert new - if we're not restricted to replacing keyframes only */ /* insert new - if we're not restricted to replacing keyframes only */
BezTriple *newb= MEM_callocN((fcu->totvert+1)*sizeof(BezTriple), "beztriple"); 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) if (i > 0)
memcpy(newb, fcu->bezt, i*sizeof(BezTriple)); memcpy(newb, fcu->bezt, i*sizeof(BezTriple));
/* add beztriple to paste at index i */ /* add beztriple to paste at index i */
*(newb + i)= *bezt; *(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) if (i < fcu->totvert)
memcpy(newb+i+1, fcu->bezt+i, (fcu->totvert-i)*sizeof(BezTriple)); memcpy(newb+i+1, fcu->bezt+i, (fcu->totvert-i)*sizeof(BezTriple));
@ -300,15 +288,15 @@ int insert_vert_fcurve (FCurve *fcu, float x, float y, short flag)
/* set all three points, for nicer start position */ /* set all three points, for nicer start position */
memset(&beztr, 0, sizeof(BezTriple)); memset(&beztr, 0, sizeof(BezTriple));
beztr.vec[0][0]= x; beztr.vec[0][0]= x-1.0f;
beztr.vec[0][1]= y; beztr.vec[0][1]= y;
beztr.vec[1][0]= x; beztr.vec[1][0]= x;
beztr.vec[1][1]= y; beztr.vec[1][1]= y;
beztr.vec[2][0]= x; beztr.vec[2][0]= x+1.0f;
beztr.vec[2][1]= y; beztr.vec[2][1]= y;
beztr.ipo= U.ipo_new; /* use default interpolation mode here... */ beztr.ipo= U.ipo_new; /* use default interpolation mode here... */
beztr.f1= beztr.f2= beztr.f3= SELECT; 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 */ //BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
/* add temp beztriple to keyframes */ /* add temp beztriple to keyframes */
@ -329,18 +317,9 @@ int insert_vert_fcurve (FCurve *fcu, float x, float y, short flag)
/* set handletype and interpolation */ /* set handletype and interpolation */
if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE)==0) { if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE)==0) {
BezTriple *bezt= (fcu->bezt + a); 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) */ /* 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; if (a > 0) bezt->ipo= (bezt-1)->ipo;
else if (a < fcu->totvert-1) bezt->ipo= (bezt+1)->ipo; else if (a < fcu->totvert-1) bezt->ipo= (bezt+1)->ipo;

@ -1412,6 +1412,35 @@ void init_userdef_do_versions(void)
if (U.flag & USER_LMOUSESELECT) if (U.flag & USER_LMOUSESELECT)
U.flag &= ~USER_TWOBUTTONMOUSE; 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!) */ /* GL Texture Garbage Collection (variable abused above!) */

@ -355,9 +355,10 @@ typedef struct UserDef {
short smooth_viewtx; /* miliseconds to spend spinning the view */ short smooth_viewtx; /* miliseconds to spend spinning the view */
short glreslimit; short glreslimit;
short ndof_pan, ndof_rotate; short ndof_pan, ndof_rotate;
short curssize, ipo_new; short curssize;
short color_picker_type; 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 scrcastfps; /* frame rate for screencast to be played back */
short scrcastwait; /* milliseconds between screencast snapshots */ short scrcastwait; /* milliseconds between screencast snapshots */

@ -25,6 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "RNA_define.h" #include "RNA_define.h"
#include "RNA_enum_types.h"
#include "rna_internal.h" #include "rna_internal.h"
@ -702,39 +703,41 @@ static void rna_def_userdef_theme_spaces_face(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_userdef_update"); 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; 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); prop= RNA_def_property(srna, "nurb_vline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "nurb_uline"); RNA_def_property_float_sdna(prop, NULL, "nurb_vline");
RNA_def_property_array(prop, 3); RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Nurb U-lines", ""); RNA_def_property_ui_text(prop, "Nurb V-lines", "");
RNA_def_property_update(prop, 0, "rna_userdef_update"); RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "nurb_vline", PROP_FLOAT, PROP_COLOR); prop= RNA_def_property(srna, "nurb_sel_uline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "nurb_vline"); RNA_def_property_float_sdna(prop, NULL, "nurb_sel_uline");
RNA_def_property_array(prop, 3); RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Nurb V-lines", ""); RNA_def_property_ui_text(prop, "Nurb active U-lines", "");
RNA_def_property_update(prop, 0, "rna_userdef_update"); RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "nurb_sel_uline", PROP_FLOAT, PROP_COLOR); prop= RNA_def_property(srna, "nurb_sel_vline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "nurb_sel_uline"); RNA_def_property_float_sdna(prop, NULL, "nurb_sel_vline");
RNA_def_property_array(prop, 3); RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Nurb active U-lines", ""); RNA_def_property_ui_text(prop, "Nurb active V-lines", "");
RNA_def_property_update(prop, 0, "rna_userdef_update"); RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "nurb_sel_vline", PROP_FLOAT, PROP_COLOR); prop= RNA_def_property(srna, "act_spline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "nurb_sel_vline"); RNA_def_property_float_sdna(prop, NULL, "act_spline");
RNA_def_property_array(prop, 3); RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Nurb active V-lines", ""); RNA_def_property_ui_text(prop, "Active spline", "");
RNA_def_property_update(prop, 0, "rna_userdef_update"); RNA_def_property_update(prop, 0, "rna_userdef_update");
}
prop= RNA_def_property(srna, "act_spline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "act_spline");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Active spline", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "handle_free", PROP_FLOAT, PROP_COLOR); prop= RNA_def_property(srna, "handle_free", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "handle_free"); RNA_def_property_float_sdna(prop, NULL, "handle_free");
@ -850,7 +853,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
rna_def_userdef_theme_spaces_vertex(srna); rna_def_userdef_theme_spaces_vertex(srna);
rna_def_userdef_theme_spaces_edge(srna); rna_def_userdef_theme_spaces_edge(srna);
rna_def_userdef_theme_spaces_face(srna); rna_def_userdef_theme_spaces_face(srna);
rna_def_userdef_theme_spaces_curves(srna); rna_def_userdef_theme_spaces_curves(srna, 1);
prop= RNA_def_property(srna, "editmesh_active", PROP_FLOAT, PROP_COLOR); prop= RNA_def_property(srna, "editmesh_active", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 4); RNA_def_property_array(prop, 4);
@ -920,6 +923,7 @@ static void rna_def_userdef_theme_space_graph(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_userdef_update"); RNA_def_property_update(prop, 0, "rna_userdef_update");
rna_def_userdef_theme_spaces_vertex(srna); rna_def_userdef_theme_spaces_vertex(srna);
rna_def_userdef_theme_spaces_curves(srna, 0);
prop= RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR); prop= RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "cframe"); RNA_def_property_float_sdna(prop, NULL, "cframe");
@ -2048,14 +2052,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
{AUTOKEY_MODE_NORMAL, "ADD_REPLACE_KEYS", 0, "Add/Replace", ""}, {AUTOKEY_MODE_NORMAL, "ADD_REPLACE_KEYS", 0, "Add/Replace", ""},
{AUTOKEY_MODE_EDITKEYS, "REPLACE_KEYS", 0, "Replace", ""}, {AUTOKEY_MODE_EDITKEYS, "REPLACE_KEYS", 0, "Replace", ""},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}};
// XXX: we could just use the one that is defined in rna_curve.h
static EnumPropertyItem new_interpolation_types[] = {
{BEZT_IPO_CONST, "CONSTANT", 0, "Constant", ""},
{BEZT_IPO_LIN, "LINEAR", 0, "Linear", ""},
{BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""},
{0, NULL, 0, NULL, NULL}};
static const EnumPropertyItem material_link_items[]= { static const EnumPropertyItem material_link_items[]= {
{0, "OBDATA", 0, "ObData", "Toggle whether the material is linked to object data or the object block"}, {0, "OBDATA", 0, "ObData", "Toggle whether the material is linked to object data or the object block"},
{USER_MAT_ON_OB, "OBJECT", 0, "Object", "Toggle whether the material is linked to object data or the object block"}, {USER_MAT_ON_OB, "OBJECT", 0, "Object", "Toggle whether the material is linked to object data or the object block"},
@ -2150,11 +2147,16 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_XYZ2RGB); RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_XYZ2RGB);
RNA_def_property_ui_text(prop, "New F-Curve Colors - XYZ to RGB", "Color for newly added transformation F-Curves (Location, Rotation, Scale) and also Color is based on the transform axis"); RNA_def_property_ui_text(prop, "New F-Curve Colors - XYZ to RGB", "Color for newly added transformation F-Curves (Location, Rotation, Scale) and also Color is based on the transform axis");
prop= RNA_def_property(srna, "new_interpolation_type", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "keyframe_new_interpolation_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, new_interpolation_types); RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items);
RNA_def_property_enum_sdna(prop, NULL, "ipo_new"); RNA_def_property_enum_sdna(prop, NULL, "ipo_new");
RNA_def_property_ui_text(prop, "New Interpolation Type", ""); RNA_def_property_ui_text(prop, "New Interpolation Type", "");
prop= RNA_def_property(srna, "keyframe_new_handle_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, beztriple_handle_type_items);
RNA_def_property_enum_sdna(prop, NULL, "keyhandles_new");
RNA_def_property_ui_text(prop, "New Handles Type", "");
/* frame numbers */ /* frame numbers */
prop= RNA_def_property(srna, "use_negative_frames", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "use_negative_frames", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_NONEGFRAMES); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_NONEGFRAMES);