Implement a user preference for the default Auto Handle Smoothing mode.

The default was changed with an initial implementation of the feature.

With the feedback from animators, having a behavior which affects curves
outside of a changing range is not convenient for professional animators
working on high quality character animation. On the other hand, automatic
smoothing is better for casual animation of object motion.

This change adds an ability to change the default via User Preferences.

Differential Revision: https://developer.blender.org/D5875
This commit is contained in:
Alexander Gavrilov 2019-10-01 21:38:44 +03:00
parent d1a1302b01
commit aabd8701e9
13 changed files with 48 additions and 26 deletions

View File

@ -22,6 +22,7 @@
#include "DNA_userdef_types.h"
#include "DNA_curve_types.h"
#include "DNA_space_types.h"
#include "DNA_anim_types.h"
#include "BLI_math_rotation.h"
@ -138,6 +139,7 @@ const UserDef U_default = {
.glreslimit = 0,
.curssize = 0,
.color_picker_type = USER_CP_CIRCLE_HSV,
.auto_smoothing_new = FCURVE_SMOOTH_CONT_ACCEL,
.ipo_new = BEZT_IPO_BEZ,
.keyhandles_new = HD_AUTO_ANIM,
.view_frame_type = ZOOM_FRAME_MODE_KEEP_RANGE,

View File

@ -569,6 +569,7 @@ class USERPREF_PT_animation_fcurves(PreferencePanel, Panel):
flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
flow.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility")
flow.prop(edit, "fcurve_new_auto_smoothing", text="Default Smoothing Mode")
flow.prop(edit, "keyframe_new_interpolation_type", text="Default Interpolation")
flow.prop(edit, "keyframe_new_handle_type", text="Default Handles")
flow.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")

View File

@ -27,7 +27,7 @@
* \note Use #STRINGIFY() rather than defining with quotes.
*/
#define BLENDER_VERSION 281
#define BLENDER_SUBVERSION 12
#define BLENDER_SUBVERSION 13
/** Several breakages with 280, e.g. collections vs layers. */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0

View File

@ -1488,7 +1488,7 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
/* set default flags */
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
fcu->auto_smoothing = U.auto_smoothing_new;
/* store path - make copy, and store that */
fcu->rna_path = BLI_strdupn("influence", 9);
@ -1515,7 +1515,7 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
/* set default flags */
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
fcu->auto_smoothing = U.auto_smoothing_new;
/* store path - make copy, and store that */
fcu->rna_path = BLI_strdupn("strip_time", 10);

View File

@ -30,6 +30,7 @@
#include "DNA_windowmanager_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_anim_types.h"
#include "BKE_addon.h"
#include "BKE_colorband.h"
@ -624,15 +625,20 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
userdef->filebrowser_display_type = USER_TEMP_SPACE_DISPLAY_WINDOW;
}
if (!USER_VERSION_ATLEAST(281, 13)) {
userdef->auto_smoothing_new = FCURVE_SMOOTH_CONT_ACCEL;
if (userdef->file_space_data.display_type == FILE_DEFAULTDISPLAY) {
memcpy(
&userdef->file_space_data, &U_default.file_space_data, sizeof(userdef->file_space_data));
}
}
/**
* Include next version bump.
*/
{
/* pass */
if (userdef->file_space_data.display_type == FILE_DEFAULTDISPLAY) {
memcpy(
&userdef->file_space_data, &U_default.file_space_data, sizeof(userdef->file_space_data));
}
}
if (userdef->pixelsize == 0.0f) {

View File

@ -104,7 +104,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
fcu->flag = (FCURVE_VISIBLE | FCURVE_AUTO_HANDLES | FCURVE_SELECTED);
fcu->array_index = 0;
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
fcu->auto_smoothing = U.auto_smoothing_new;
for (unsigned int j = 0; j < curve->getKeyCount(); j++) {
BezTriple bez;

View File

@ -383,7 +383,7 @@ void BCAnimationCurve::adjust_range(const int frame_index)
void BCAnimationCurve::add_value(const float val, const int frame_index)
{
FCurve *fcu = get_edit_fcurve();
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
fcu->auto_smoothing = U.auto_smoothing_new;
insert_vert_fcurve(fcu, frame_index, val, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_NOFLAGS);
if (fcu->totvert == 1) {

View File

@ -111,7 +111,7 @@ struct FCurve *alloc_driver_fcurve(const char rna_path[],
FCurve *fcu = MEM_callocN(sizeof(FCurve), "FCurve");
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
fcu->auto_smoothing = U.auto_smoothing_new;
/* store path - make copy, and store that */
if (rna_path) {

View File

@ -202,7 +202,7 @@ FCurve *verify_fcurve(Main *bmain,
fcu = MEM_callocN(sizeof(FCurve), "FCurve");
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
fcu->auto_smoothing = U.auto_smoothing_new;
if (BLI_listbase_is_empty(&act->curves)) {
fcu->flag |= FCURVE_ACTIVE; /* first one added active */
}

View File

@ -728,11 +728,13 @@ typedef struct UserDef {
short curssize;
/** #eColorPicker_Types. */
short color_picker_type;
/** Curve smoothing type for newly added F-Curves. */
char auto_smoothing_new;
/** Interpolation mode for newly added F-Curves. */
char ipo_new;
/** Handle types for newly added keyframes. */
char keyhandles_new;
char _pad11[3];
char _pad11[2];
/** #eZoomFrame_Mode. */
char view_frame_type;

View File

@ -90,6 +90,7 @@ extern const EnumPropertyItem rna_enum_color_sets_items[];
extern const EnumPropertyItem rna_enum_beztriple_keyframe_type_items[];
extern const EnumPropertyItem rna_enum_beztriple_interpolation_mode_items[];
extern const EnumPropertyItem rna_enum_beztriple_interpolation_easing_items[];
extern const EnumPropertyItem rna_enum_fcurve_auto_smoothing_items[];
extern const EnumPropertyItem rna_enum_keyframe_handle_type_items[];
extern const EnumPropertyItem rna_enum_driver_target_rotation_mode_items[];

View File

@ -76,6 +76,22 @@ const EnumPropertyItem rna_enum_fmodifier_type_items[] = {
{0, NULL, 0, NULL, NULL},
};
const EnumPropertyItem rna_enum_fcurve_auto_smoothing_items[] = {
{FCURVE_SMOOTH_NONE,
"NONE",
0,
"None",
"Automatic handles only take immediately adjacent keys into account"},
{FCURVE_SMOOTH_CONT_ACCEL,
"CONT_ACCEL",
0,
"Continuous Acceleration",
"Automatic handles are adjusted to avoid jumps in acceleration, resulting "
"in smoother curves. However, key changes may affect interpolation over a "
"larger stretch of the curve"},
{0, NULL, 0, NULL, NULL},
};
const EnumPropertyItem rna_enum_beztriple_keyframe_type_items[] = {
{BEZT_KEYTYPE_KEYFRAME,
"KEYFRAME",
@ -2258,19 +2274,6 @@ static void rna_def_fcurve(BlenderRNA *brna)
"Use custom hand-picked color for F-Curve"},
{0, NULL, 0, NULL, NULL},
};
static EnumPropertyItem prop_mode_smoothing_items[] = {
{FCURVE_SMOOTH_NONE,
"NONE",
0,
"None",
"Auto handles only take adjacent keys into account (legacy mode)"},
{FCURVE_SMOOTH_CONT_ACCEL,
"CONT_ACCEL",
0,
"Continuous Acceleration",
"Auto handles are placed to avoid jumps in acceleration"},
{0, NULL, 0, NULL, NULL},
};
srna = RNA_def_struct(brna, "FCurve", NULL);
RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time");
@ -2350,7 +2353,7 @@ static void rna_def_fcurve(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
prop = RNA_def_property(srna, "auto_smoothing", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_mode_smoothing_items);
RNA_def_property_enum_items(prop, rna_enum_fcurve_auto_smoothing_items);
RNA_def_property_ui_text(
prop, "Auto Handle Smoothing", "Algorithm used to compute automatic handles");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FCurve_update_data");

View File

@ -4657,6 +4657,13 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
"Color for newly added transformation F-Curves (Location, Rotation, Scale) "
"and also Color is based on the transform axis");
prop = RNA_def_property(srna, "fcurve_new_auto_smoothing", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_fcurve_auto_smoothing_items);
RNA_def_property_enum_sdna(prop, NULL, "auto_smoothing_new");
RNA_def_property_ui_text(prop,
"New Curve Smoothing Mode",
"Auto Handle Smoothing mode used for newly added F-Curves");
prop = RNA_def_property(srna, "keyframe_new_interpolation_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_beztriple_interpolation_mode_items);
RNA_def_property_enum_sdna(prop, NULL, "ipo_new");