[Bf-blender-cvs] [3364a5bea6c] master: Cleanup: move code in graph_slider_ops

Christoph Lendenfeld noreply at git.blender.org
Thu Nov 4 22:35:37 CET 2021


Commit: 3364a5bea6c977069210c3325111dc28051ee1cb
Author: Christoph Lendenfeld
Date:   Thu Nov 4 21:35:28 2021 +0000
Branches: master
https://developer.blender.org/rB3364a5bea6c977069210c3325111dc28051ee1cb

Cleanup: move code in graph_slider_ops

Future operators can use the same code,
so it is moved up to disassociate it from decimate

No functional changes

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D12489
Ref: D12489

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

M	source/blender/editors/space_graph/graph_slider_ops.c

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

diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c
index f669a7e193d..14a8f73a3a4 100644
--- a/source/blender/editors/space_graph/graph_slider_ops.c
+++ b/source/blender/editors/space_graph/graph_slider_ops.c
@@ -53,7 +53,10 @@
   (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | \
    ANIMFILTER_NODUPLIS)
 
-/* ------------------- */
+/* ******************** GRAPH SLIDER OPERATORS ************************* */
+/* This file contains a collection of operators to modify keyframes in the graph editor. All
+ * operators are modal and use a slider that allows the user to define a percentage to modify the
+ * operator. */
 
 /* This data type is only used for modal operation. */
 typedef struct tGraphSliderOp {
@@ -78,16 +81,6 @@ typedef struct tBeztCopyData {
   BezTriple *bezt;
 } tBeztCopyData;
 
-typedef enum tDecimModes {
-  DECIM_RATIO = 1,
-  DECIM_ERROR,
-} tDecimModes;
-
-/* ******************** GRAPH SLIDER OPERATORS ************************* */
-/* This file contains a collection of operators to modify keyframes in the graph editor. All
- * operators are modal and use a slider that allows the user to define a percentage to modify the
- * operator. */
-
 /* ******************** Utility Functions ************************* */
 
 /* Construct a list with the original bezt arrays so we can restore them during modal operation.
@@ -130,30 +123,6 @@ static void store_original_bezt_arrays(tGraphSliderOp *gso)
   ANIM_animdata_freelist(&anim_data);
 }
 
-/* ******************** Decimate Keyframes Operator ************************* */
-
-static void decimate_graph_keys(bAnimContext *ac, float remove_ratio, float error_sq_max)
-{
-  ListBase anim_data = {NULL, NULL};
-  bAnimListElem *ale;
-
-  /* Filter data. */
-  ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
-
-  /* Loop through filtered data and clean curves. */
-  for (ale = anim_data.first; ale; ale = ale->next) {
-    if (!decimate_fcurve(ale, remove_ratio, error_sq_max)) {
-      /* The selection contains unsupported keyframe types! */
-      WM_report(RPT_WARNING, "Decimate: Skipping non linear/bezier keyframes!");
-    }
-
-    ale->update |= ANIM_UPDATE_DEFAULT;
-  }
-
-  ANIM_animdata_update(ac, &anim_data);
-  ANIM_animdata_freelist(&anim_data);
-}
-
 /* Overwrite the current bezts arrays with the original data. */
 static void reset_bezts(tGraphSliderOp *gso)
 {
@@ -192,6 +161,35 @@ static void reset_bezts(tGraphSliderOp *gso)
   ANIM_animdata_freelist(&anim_data);
 }
 
+/* ******************** Decimate Keyframes Operator ************************* */
+
+typedef enum tDecimModes {
+  DECIM_RATIO = 1,
+  DECIM_ERROR,
+} tDecimModes;
+
+static void decimate_graph_keys(bAnimContext *ac, float remove_ratio, float error_sq_max)
+{
+  ListBase anim_data = {NULL, NULL};
+  bAnimListElem *ale;
+
+  /* Filter data. */
+  ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
+
+  /* Loop through filtered data and clean curves. */
+  for (ale = anim_data.first; ale; ale = ale->next) {
+    if (!decimate_fcurve(ale, remove_ratio, error_sq_max)) {
+      /* The selection contains unsupported keyframe types! */
+      WM_report(RPT_WARNING, "Decimate: Skipping non linear/bezier keyframes!");
+    }
+
+    ale->update |= ANIM_UPDATE_DEFAULT;
+  }
+
+  ANIM_animdata_update(ac, &anim_data);
+  ANIM_animdata_freelist(&anim_data);
+}
+
 static void decimate_exit(bContext *C, wmOperator *op)
 {
   tGraphSliderOp *gso = op->customdata;



More information about the Bf-blender-cvs mailing list