[Bf-blender-cvs] [6e72e3fdb29] master: Cleanup: Further renaming in new curves code

Hans Goudey noreply at git.blender.org
Fri Mar 25 02:48:19 CET 2022


Commit: 6e72e3fdb295fdfd3e252bd48be96e2d832e43f2
Author: Hans Goudey
Date:   Thu Mar 24 20:48:08 2022 -0500
Branches: master
https://developer.blender.org/rB6e72e3fdb295fdfd3e252bd48be96e2d832e43f2

Cleanup: Further renaming in new curves code

A follow-up to e253f9f66d6f. Follow the policy from T85728
completely (using "num" as a prefix) and rename another function.

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

M	source/blender/blenkernel/BKE_curves.hh
M	source/blender/blenkernel/intern/curve_catmull_rom.cc
M	source/blender/blenkernel/intern/curve_nurbs.cc
M	source/blender/blenkernel/intern/curves.cc
M	source/blender/blenkernel/intern/curves_geometry.cc
M	source/blender/blenkernel/intern/curves_geometry_test.cc
M	source/blender/blenkernel/intern/geometry_component_curves.cc
M	source/blender/blenlib/BLI_math_statistics.h
M	source/blender/draw/intern/draw_cache_impl_curves.cc
M	source/blender/editors/curves/intern/curves_add.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_add.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_comb.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
M	source/blender/geometry/intern/realize_instances.cc
M	source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc
M	source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc
M	source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc

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

diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh
index 5039b6f0f57..6a95bc7d2d2 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -122,8 +122,8 @@ class CurvesGeometry : public ::CurvesGeometry {
    * Accessors.
    */
 
-  int num_points() const;
-  int num_curves() const;
+  int points_num() const;
+  int curves_num() const;
   IndexRange points_range() const;
   IndexRange curves_range() const;
 
@@ -243,7 +243,7 @@ class CurvesGeometry : public ::CurvesGeometry {
    * The total number of points in the evaluated poly curve.
    * This can depend on the resolution attribute if it exists.
    */
-  int evaluated_points_size() const;
+  int evaluated_points_num() const;
 
   /**
    * Access a range of indices of point data for a specific curve.
@@ -275,7 +275,7 @@ class CurvesGeometry : public ::CurvesGeometry {
    * Change the number of elements. New values for existing attributes should be properly
    * initialized afterwards.
    */
-  void resize(int num_points, int num_curves);
+  void resize(int points_num, int curves_num);
 
   /** Call after deforming the position attribute. */
   void tag_positions_changed();
@@ -314,9 +314,9 @@ namespace curves {
  * and the fact that curves with two points cannot be cyclic. The logic is simple, but this
  * function should be used to make intentions clearer.
  */
-inline int curve_segment_size(const int num_points, const bool cyclic)
+inline int curve_segment_size(const int points_num, const bool cyclic)
 {
-  return (cyclic && num_points > 2) ? num_points : num_points - 1;
+  return (cyclic && points_num > 2) ? points_num : points_num - 1;
 }
 
 namespace bezier {
@@ -381,10 +381,10 @@ namespace catmull_rom {
 
 /**
  * Calculate the number of evaluated points that #interpolate_to_evaluated is expected to produce.
- * \param num_points: The number of points in the curve.
+ * \param points_num: The number of points in the curve.
  * \param resolution: The resolution for each segment.
  */
-int calculate_evaluated_size(int num_points, bool cyclic, int resolution);
+int calculate_evaluated_size(int points_num, bool cyclic, int resolution);
 
 /**
  * Evaluate the Catmull Rom curve. The length of the #dst span should be calculated with
@@ -399,7 +399,7 @@ namespace nurbs {
 /**
  * Checks the conditions that a NURBS curve needs to evaluate.
  */
-bool check_valid_size_and_order(int num_points, int8_t order, bool cyclic, KnotsMode knots_mode);
+bool check_valid_size_and_order(int points_num, int8_t order, bool cyclic, KnotsMode knots_mode);
 
 /**
  * Calculate the standard evaluated size for a NURBS curve, using the standard that
@@ -410,14 +410,14 @@ bool check_valid_size_and_order(int num_points, int8_t order, bool cyclic, Knots
  * shared.
  */
 int calculate_evaluated_size(
-    int num_points, int8_t order, bool cyclic, int resolution, KnotsMode knots_mode);
+    int points_num, int8_t order, bool cyclic, int resolution, KnotsMode knots_mode);
 
 /**
  * Calculate the length of the knot vector for a NURBS curve with the given properties.
  * The knots must be longer for a cyclic curve, for example, in order to provide weights for the
  * last evaluated points that are also influenced by the first control points.
  */
-int knots_size(int num_points, int8_t order, bool cyclic);
+int knots_size(int points_num, int8_t order, bool cyclic);
 
 /**
  * Calculate the knots for a spline given its properties, based on built-in standards defined by
@@ -428,7 +428,7 @@ int knots_size(int num_points, int8_t order, bool cyclic);
  * changes, and is generally more intuitive than defining the knot vector manually.
  */
 void calculate_knots(
-    int num_points, KnotsMode mode, int8_t order, bool cyclic, MutableSpan<float> knots);
+    int points_num, KnotsMode mode, int8_t order, bool cyclic, MutableSpan<float> knots);
 
 /**
  * Based on the knots, the order, and other properties of a NURBS curve, calculate a cache that can
@@ -436,7 +436,7 @@ void calculate_knots(
  * two pieces of information for every evaluated point: the first control point that influences it,
  * and a weight for each control point.
  */
-void calculate_basis_cache(int num_points,
+void calculate_basis_cache(int points_num,
                            int evaluated_size,
                            int8_t order,
                            bool cyclic,
@@ -461,11 +461,11 @@ void interpolate_to_evaluated(const BasisCache &basis_cache,
 
 }  // namespace curves
 
-Curves *curves_new_nomain(int num_points, int num_curves);
+Curves *curves_new_nomain(int points_num, int curves_num);
 
 /**
  * Create a new curves data-block containing a single curve with the given length and type.
  */
-Curves *curves_new_nomain_single(int num_points, CurveType type);
+Curves *curves_new_nomain_single(int points_num, CurveType type);
 
 }  // namespace blender::bke
diff --git a/source/blender/blenkernel/intern/curve_catmull_rom.cc b/source/blender/blenkernel/intern/curve_catmull_rom.cc
index 5b6d0cac21f..ea3672dd56b 100644
--- a/source/blender/blenkernel/intern/curve_catmull_rom.cc
+++ b/source/blender/blenkernel/intern/curve_catmull_rom.cc
@@ -9,11 +9,11 @@
 
 namespace blender::bke::curves::catmull_rom {
 
-int calculate_evaluated_size(const int num_points, const bool cyclic, const int resolution)
+int calculate_evaluated_size(const int points_num, const bool cyclic, const int resolution)
 {
-  const int eval_size = resolution * curve_segment_size(num_points, cyclic);
+  const int eval_size = resolution * curve_segment_size(points_num, cyclic);
   /* If the curve isn't cyclic, one last point is added to the final point. */
-  return (cyclic && num_points > 2) ? eval_size : eval_size + 1;
+  return (cyclic && points_num > 2) ? eval_size : eval_size + 1;
 }
 
 /* Adapted from Cycles #catmull_rom_basis_eval function. */
diff --git a/source/blender/blenkernel/intern/curve_nurbs.cc b/source/blender/blenkernel/intern/curve_nurbs.cc
index bd6bd222aa3..31fe5426b5b 100644
--- a/source/blender/blenkernel/intern/curve_nurbs.cc
+++ b/source/blender/blenkernel/intern/curve_nurbs.cc
@@ -10,53 +10,53 @@
 
 namespace blender::bke::curves::nurbs {
 
-bool check_valid_size_and_order(const int num_points,
+bool check_valid_size_and_order(const int points_num,
                                 const int8_t order,
                                 const bool cyclic,
                                 const KnotsMode knots_mode)
 {
-  if (num_points < order) {
+  if (points_num < order) {
     return false;
   }
 
   if (ELEM(knots_mode, NURBS_KNOT_MODE_BEZIER, NURBS_KNOT_MODE_ENDPOINT_BEZIER)) {
-    if (knots_mode == NURBS_KNOT_MODE_BEZIER && num_points <= order) {
+    if (knots_mode == NURBS_KNOT_MODE_BEZIER && points_num <= order) {
       return false;
     }
-    return (!cyclic || num_points % (order - 1) == 0);
+    return (!cyclic || points_num % (order - 1) == 0);
   }
 
   return true;
 }
 
-int calculate_evaluated_size(const int num_points,
+int calculate_evaluated_size(const int points_num,
                              const int8_t order,
                              const bool cyclic,
                              const int resolution,
                              const KnotsMode knots_mode)
 {
-  if (!check_valid_size_and_order(num_points, order, cyclic, knots_mode)) {
+  if (!check_valid_size_and_order(points_num, order, cyclic, knots_mode)) {
     return 0;
   }
-  return resolution * curve_segment_size(num_points, cyclic);
+  return resolution * curve_segment_size(points_num, cyclic);
 }
 
-int knots_size(const int num_points, const int8_t order, const bool cyclic)
+int knots_size(const int points_num, const int8_t order, const bool cyclic)
 {
   if (cyclic) {
-    return num_points + order * 2 - 1;
+    return points_num + order * 2 - 1;
   }
-  return num_points + order;
+  return points_num + order;
 }
 
-void calculate_knots(const int num_points,
+void calculate_knots(const int points_num,
                      const KnotsMode mode,
                      const int8_t order,
                      const bool cyclic,
                      MutableSpan<float> knots)
 {
-  BLI_assert(knots.size() == knots_size(num_points, order, cyclic));
-  UNUSED_VARS_NDEBUG(num_points);
+  BLI_assert(knots.size() == knots_size(points_num, order, cyclic));
+  UNUSED_VARS_NDEBUG(points_num);
 
   const bool is_bezier = ELEM(mode, NURBS_KNOT_MODE_BEZIER, NURBS_KNOT_MODE_ENDPOINT_BEZIER);
   const bool is_end_point = ELEM(mode, NURBS_KNOT_MODE_ENDPOINT, NURBS_KNOT_MODE_ENDPOINT_BEZIER);
@@ -94,7 +94,7 @@ void calculate_knots(const int num_points,
 }
 
 static void calculate_basis_for_point(const float parameter,
-                                      const int num_points,
+                                      const int points_num,
                                       const int degree,
                                       const Span<float> knots,
                                       MutableSpan<float> r_weights,
@@ -104,7 +104,7 @@ static void calculate_basis_for_point(const float parameter,
 
   int start = 0;
   int end = 0;
-  for (const int i : IndexRange(num_points + degree)) {
+  for (const int i : IndexRange(points_num + degree)) {
     const bool knots_equal = knots[i] == knots[i + 1];
     if (knots_equal || parameter < knots[i] || parameter > knots[i + 1]) {
       continue;
@@ -121,7 +121,7 @@ static void calculate_basis_for_point(const float parameter,
 
   for (const int i_order : IndexRange(2, degree)) {
     if (end + i_order >= knots.size()) {
-      end = num_points + degree - i_order;
+      end = points_num + degree - i_order;
     }
     for (const int i : IndexRange(end - start + 1)) {
       const int knot_index = start + i;
@@ -146,14 +146,14 @@ static void calculate_basis_for_point(const float parameter,
   r_start_index = start;
 }
 
-void calculate_basis_cache(const int num_points,
+void calculate_basis_cache(const int points_num,
                            const int evaluated_size,
                            const int8_t order,
                            const bool cyclic,
                            const Span<float> knots,
                     

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list