Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2010-04-02 05:03:40 +0400
committerJoshua Leung <aligorith@gmail.com>2010-04-02 05:03:40 +0400
commitc6b77a06dd1baede633f18b094867603e0ef66f6 (patch)
tree8360c833c49c4b507347452ad5b5e774999b82b6
parent248f1380af7780d2e9bc0d1a06b407897a6cfde3 (diff)
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.
-rw-r--r--release/scripts/ui/space_userpref.py17
-rw-r--r--source/blender/editors/animation/keyframing.c53
-rw-r--r--source/blender/editors/interface/resources.c29
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c78
5 files changed, 102 insertions, 80 deletions
diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py
index 326a97825d9..0d9491473ad 100644
--- a/release/scripts/ui/space_userpref.py
+++ b/release/scripts/ui/space_userpref.py
@@ -371,7 +371,8 @@ class USERPREF_PT_edit(bpy.types.Panel):
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 @@ class USERPREF_PT_theme(bpy.types.Panel):
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
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 55001107715..800b0248728 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -217,28 +217,16 @@ int insert_bezt_fcurve (FCurve *fcu, BezTriple *bezt, short flag)
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 @@ int insert_bezt_fcurve (FCurve *fcu, BezTriple *bezt, short flag)
/* 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 @@ int insert_vert_fcurve (FCurve *fcu, float x, float y, short flag)
/* 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 @@ int insert_vert_fcurve (FCurve *fcu, float x, float y, short flag)
/* 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;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index b885d6cd355..2296da63800 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1412,6 +1412,35 @@ void init_userdef_do_versions(void)
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!) */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 4ebc2594c8f..e0a32d9ce6c 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -355,9 +355,10 @@ typedef struct UserDef {
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 */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index f5d6f1a6f79..68e6c20d8aa 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include "RNA_define.h"
+#include "RNA_enum_types.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");
}
-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");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Nurb active U-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");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Nurb active U-lines", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop= RNA_def_property(srna, "nurb_sel_vline", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "nurb_sel_vline");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Nurb active V-lines", "");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
+ prop= RNA_def_property(srna, "nurb_sel_vline", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_float_sdna(prop, NULL, "nurb_sel_vline");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Nurb active V-lines", "");
+ 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, "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);
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_edge(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);
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_userdef_theme_spaces_vertex(srna);
+ rna_def_userdef_theme_spaces_curves(srna, 0);
prop= RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR);
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_EDITKEYS, "REPLACE_KEYS", 0, "Replace", ""},
{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[]= {
{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"},
@@ -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_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);
- RNA_def_property_enum_items(prop, new_interpolation_types);
+ prop= RNA_def_property(srna, "keyframe_new_interpolation_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items);
RNA_def_property_enum_sdna(prop, NULL, "ipo_new");
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 */
prop= RNA_def_property(srna, "use_negative_frames", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_NONEGFRAMES);