[Bf-blender-cvs] [aabd8701e98] master: Implement a user preference for the default Auto Handle Smoothing mode.

Alexander Gavrilov noreply at git.blender.org
Wed Oct 2 19:44:40 CEST 2019


Commit: aabd8701e98595bae57d59344ed5d127b8b0f7db
Author: Alexander Gavrilov
Date:   Tue Oct 1 21:38:44 2019 +0300
Branches: master
https://developer.blender.org/rBaabd8701e98595bae57d59344ed5d127b8b0f7db

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

===================================================================

M	release/datafiles/userdef/userdef_default.c
M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/intern/nla.c
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/collada/AnimationImporter.cpp
M	source/blender/collada/BCAnimationCurve.cpp
M	source/blender/editors/animation/drivers.c
M	source/blender/editors/animation/keyframing.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/rna_fcurve.c
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c
index 7785c9d2962..dc35187ab7e 100644
--- a/release/datafiles/userdef/userdef_default.c
+++ b/release/datafiles/userdef/userdef_default.c
@@ -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,
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 8ccd8b57357..4c90f987c50 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -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")
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 21ef70b7bcd..7b879cc1a15 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -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
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 2cc1083aba3..09581debd99 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -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);
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index e769e72d8e1..3eaf45954f3 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -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) {
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 79593f07383..47325c4dece 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -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;
diff --git a/source/blender/collada/BCAnimationCurve.cpp b/source/blender/collada/BCAnimationCurve.cpp
index bf32ec9148c..f944a77196c 100644
--- a/source/blender/collada/BCAnimationCurve.cpp
+++ b/source/blender/collada/BCAnimationCurve.cpp
@@ -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) {
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 61c8da08954..64f7fe034dc 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -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) {
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 0f8b8742659..8203a9131fa 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -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 */
     }
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 75f29695eb3..b9f43c0e579 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -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;
 
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index e72a55b5a9e..458f031ceae 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -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[];
 
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 254f3bc3710..424bb4a492f 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -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_pro

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list