[Bf-blender-cvs] [9299746b15f] temp-graph-select-changes: Cleanup: Comments, use enum types or aliases in parameter lists

Julian Eisel noreply at git.blender.org
Fri Nov 15 17:07:27 CET 2019


Commit: 9299746b15f3aea758c72a994c5cab0f8b1c3405
Author: Julian Eisel
Date:   Thu Nov 14 17:10:52 2019 +0100
Branches: temp-graph-select-changes
https://developer.blender.org/rB9299746b15f3aea758c72a994c5cab0f8b1c3405

Cleanup: Comments, use enum types or aliases in parameter lists

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

M	source/blender/blenkernel/BKE_curve.h
M	source/blender/blenkernel/BKE_fcurve.h
M	source/blender/blenkernel/intern/curve.c
M	source/blender/blenkernel/intern/fcurve.c
M	source/blender/editors/space_graph/graph_select.c
M	source/blender/editors/transform/transform_convert.c
M	source/blender/editors/transform/transform_convert_graph.c

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

diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 1c0c8143e31..e03780cc027 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -35,6 +35,8 @@ struct Path;
 struct TextBox;
 struct rctf;
 
+typedef int eBezTriple_Flag__Alias;
+
 typedef struct CurveCache {
   ListBase disp;
   ListBase bev;
@@ -245,7 +247,7 @@ void BKE_nurb_handle_calc(struct BezTriple *bezt,
 void BKE_nurb_handle_calc_ex(struct BezTriple *bezt,
                              struct BezTriple *prev,
                              struct BezTriple *next,
-                             const int handle_sel_flag,
+                             const eBezTriple_Flag__Alias handle_sel_flag,
                              const bool is_fcurve,
                              const char smoothing);
 void BKE_nurb_handle_calc_simple(struct Nurb *nu, struct BezTriple *bezt);
@@ -255,7 +257,9 @@ void BKE_nurb_handle_smooth_fcurve(struct BezTriple *bezt, int total, bool cycli
 
 void BKE_nurb_handles_calc(struct Nurb *nu);
 void BKE_nurb_handles_autocalc(struct Nurb *nu, int flag);
-void BKE_nurb_bezt_handle_test(struct BezTriple *bezt, const int sel_flag, const bool use_handle);
+void BKE_nurb_bezt_handle_test(struct BezTriple *bezt,
+                               const eBezTriple_Flag__Alias sel_flag,
+                               const bool use_handle);
 void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles);
 
 /* **** Depsgraph evaluation **** */
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 80e13d66107..426e0ed4b0e 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -328,8 +328,8 @@ eFCU_Cycle_Type BKE_fcurve_get_cycle_type(struct FCurve *fcu);
 /* -------- Curve Sanity --------  */
 
 void calchandles_fcurve(struct FCurve *fcu);
-void calchandles_fcurve_ex(struct FCurve *fcu, int handle_sel_flag);
-void testhandles_fcurve(struct FCurve *fcu, const int sel_flag, const bool use_handle);
+void calchandles_fcurve_ex(struct FCurve *fcu, eBezTriple_Flag handle_sel_flag);
+void testhandles_fcurve(struct FCurve *fcu, eBezTriple_Flag sel_flag, const bool use_handle);
 void sort_time_fcurve(struct FCurve *fcu);
 short test_time_fcurve(struct FCurve *fcu);
 
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 39c7cf9b44e..12bb7b573bd 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -3201,7 +3201,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
 static void calchandleNurb_intern(BezTriple *bezt,
                                   const BezTriple *prev,
                                   const BezTriple *next,
-                                  int handle_sel_flag,
+                                  eBezTriple_Flag handle_sel_flag,
                                   bool is_fcurve,
                                   bool skip_align,
                                   char fcurve_smoothing)
@@ -3444,7 +3444,7 @@ static void calchandleNurb_intern(BezTriple *bezt,
 #undef p2_h2
 }
 
-static void calchandlesNurb_intern(Nurb *nu, int handle_sel_flag, bool skip_align)
+static void calchandlesNurb_intern(Nurb *nu, eBezTriple_Flag handle_sel_flag, bool skip_align)
 {
   BezTriple *bezt, *prev, *next;
   int a;
@@ -3602,8 +3602,7 @@ static bool tridiagonal_solve_with_limits(
 
         float target = h[i] > hmax[i] ? hmax[i] : hmin[i];
 
-        /* heuristically only lock handles that go in the right direction if there are such ones
-         */
+        /* heuristically only lock handles that go in the right direction if there are such ones */
         if (target != 0.0f || all) {
           /* mark item locked */
           is_locked[i] = 1;
@@ -4040,16 +4039,27 @@ void BKE_nurb_handle_smooth_fcurve(BezTriple *bezt, int total, bool cycle)
   }
 }
 
+/**
+ * Recalculate the handles of a nurb bezier-triple. Acts based on handle selection with `SELECT`
+ * flag. To use a different flag, use #BKE_nurb_handle_calc_ex().
+ */
 void BKE_nurb_handle_calc(
     BezTriple *bezt, BezTriple *prev, BezTriple *next, const bool is_fcurve, const char smoothing)
 {
   calchandleNurb_intern(bezt, prev, next, SELECT, is_fcurve, false, smoothing);
 }
 
+/**
+ * Variant of #BKE_nurb_handle_calc() that allows calculating based on a different select flag.
+ *
+ * \param sel_flag: The flag (bezt.f1/2/3) value to use to determine selection. Usually `SELECT`,
+ *                  but may want to use a different one at times (if caller does not operate on
+ *                  selection).
+ */
 void BKE_nurb_handle_calc_ex(BezTriple *bezt,
                              BezTriple *prev,
                              BezTriple *next,
-                             const int handle_sel_flag,
+                             const eBezTriple_Flag__Alias handle_sel_flag,
                              const bool is_fcurve,
                              const char smoothing)
 {
@@ -4113,14 +4123,21 @@ void BKE_nurb_handle_calc_simple_auto(Nurb *nu, BezTriple *bezt)
 }
 
 /**
+ * Update selected handle types to ensure valid state, e.g. deduce "Auto" types to concrete ones.
+ * Thereby \a sel_flag defines what qualifies as selected.
  * Use when something has changed handle positions.
  *
  * The caller needs to recalculate handles.
  *
  * \param sel_flag: The flag (bezt.f1/2/3) value to use to determine selection. Usually `SELECT`,
- *                  but may want to use a different one at times.
+ *                  but may want to use a different one at times (if caller does not operate on
+ *                  selection).
+ * \param use_handle: Check selection state of individual handles, otherwise always update both
+ *                    handles if the key is selected.
  */
-void BKE_nurb_bezt_handle_test(BezTriple *bezt, const int sel_flag, const bool use_handle)
+void BKE_nurb_bezt_handle_test(BezTriple *bezt,
+                               const eBezTriple_Flag__Alias sel_flag,
+                               const bool use_handle)
 {
   short flag = 0;
 
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 0b72ca44004..1709e7a61dd 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1036,10 +1036,14 @@ static BezTriple *cycle_offset_triple(
   return out;
 }
 
-/* This function recalculates the handles of an F-Curve
- * If the BezTriples have been rearranged, sort them first before using this.
+/**
+ * Variant of #calchandles_fcurve() that allows calculating based on a different select flag.
+ *
+ * \param sel_flag: The flag (bezt.f1/2/3) value to use to determine selection. Usually `SELECT`,
+ *                  but may want to use a different one at times (if caller does not operate on
+ *                  selection).
  */
-void calchandles_fcurve_ex(FCurve *fcu, int handle_sel_flag)
+void calchandles_fcurve_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
 {
   BezTriple *bezt, *prev, *next;
   int a = fcu->totvert;
@@ -1120,12 +1124,30 @@ void calchandles_fcurve_ex(FCurve *fcu, int handle_sel_flag)
     BKE_nurb_handle_smooth_fcurve(fcu->bezt, fcu->totvert, cycle);
   }
 }
+
+/**
+ * This function recalculates the handles of an F-Curve. Acts based on selection with `SELECT`
+ * flag. To use a different flag, use #calchandles_fcurve_ex().
+ *
+ * If the BezTriples have been rearranged, sort them first before using this.
+ */
 void calchandles_fcurve(FCurve *fcu)
 {
   calchandles_fcurve_ex(fcu, SELECT);
 }
 
-void testhandles_fcurve(FCurve *fcu, const int sel_flag, const bool use_handle)
+/**
+ * Update handles, making sure the handle-types are valid (e.g. correctly deduced from an "Auto"
+ * type), and recalculating their position vectors.
+ * Use when something has changed handle positions.
+ *
+ * \param sel_flag: The flag (bezt.f1/2/3) value to use to determine selection. Usually `SELECT`,
+ *                  but may want to use a different one at times (if caller does not operate on
+ *                  selection).
+ * \param use_handle: Check selection state of individual handles, otherwise always update both
+ *                    handles if the key is selected.
+ */
+void testhandles_fcurve(FCurve *fcu, eBezTriple_Flag sel_flag, const bool use_handle)
 {
   BezTriple *bezt;
   unsigned int a;
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index b03c9024b69..28460df7ab4 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -1423,7 +1423,7 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot)
 /* option 1) select keyframe directly under mouse */
 static int mouse_graph_keys(bAnimContext *ac,
                             const int mval[2],
-                            short select_mode,
+                            eEditKeyframes_Select select_mode,
                             const bool deselect_all,
                             const bool curves_only,
                             bool wait_to_deselect_others)
@@ -1495,7 +1495,6 @@ static int mouse_graph_keys(bAnimContext *ac,
         }
       }
       else {
-        /* Select the handle that applied */
         if (nvi->hpoint == NEAREST_HANDLE_KEY) {
           bezt->f2 |= SELECT;
         }
@@ -1579,7 +1578,7 @@ static int mouse_graph_keys(bAnimContext *ac,
 /* Option 3) Selects all visible keyframes in the same frame as the mouse click */
 static int graphkeys_mselect_column(bAnimContext *ac,
                                     const int mval[2],
-                                    short select_mode,
+                                    eEditKeyframes_Select select_mode,
                                     bool wait_to_deselect_others)
 {
   ListBase anim_data = {NULL, NULL};
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 82aad5953f7..3347997ecf6 100644
--- a/source/blender/editors/transform/transform_convert.

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list