[Bf-blender-cvs] [4ec1c8bc9c0] master: Cleanup: Use helper variable, const argument

Hans Goudey noreply at git.blender.org
Sun Mar 13 23:02:09 CET 2022


Commit: 4ec1c8bc9c0cb9b87ff1bf7e7642d144a7b4b38f
Author: Hans Goudey
Date:   Sun Mar 13 15:41:31 2022 -0500
Branches: master
https://developer.blender.org/rB4ec1c8bc9c0cb9b87ff1bf7e7642d144a7b4b38f

Cleanup: Use helper variable, const argument

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

M	source/blender/blenkernel/intern/spline_nurbs.cc

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

diff --git a/source/blender/blenkernel/intern/spline_nurbs.cc b/source/blender/blenkernel/intern/spline_nurbs.cc
index 1138250cffc..a8a17b7aee6 100644
--- a/source/blender/blenkernel/intern/spline_nurbs.cc
+++ b/source/blender/blenkernel/intern/spline_nurbs.cc
@@ -223,7 +223,7 @@ Span<float> NURBSpline::knots() const
 static void calculate_basis_for_point(const float parameter,
                                       const int size,
                                       const int degree,
-                                      Span<float> knots,
+                                      const Span<float> knots,
                                       MutableSpan<float> r_weights,
                                       int &r_start_index)
 {
@@ -303,8 +303,10 @@ const NURBSpline::BasisCache &NURBSpline::calculate_basis_cache() const
   const Span<float> control_weights = this->weights();
   const Span<float> knots = this->knots();
 
+  const int last_control_point_index = is_cyclic_ ? size + degree : size;
+
   const float start = knots[degree];
-  const float end = is_cyclic_ ? knots[size + degree] : knots[size];
+  const float end = knots[last_control_point_index];
   const float step = (end - start) / this->evaluated_edges_size();
   for (const int i : IndexRange(eval_size)) {
     /* Clamp parameter due to floating point inaccuracy. */
@@ -312,12 +314,8 @@ const NURBSpline::BasisCache &NURBSpline::calculate_basis_cache() const
 
     MutableSpan<float> point_weights = basis_weights.slice(i * order, order);
 
-    calculate_basis_for_point(parameter,
-                              size + (is_cyclic_ ? degree : 0),
-                              degree,
-                              knots,
-                              point_weights,
-                              basis_start_indices[i]);
+    calculate_basis_for_point(
+        parameter, last_control_point_index, degree, knots, point_weights, basis_start_indices[i]);
 
     for (const int j : point_weights.index_range()) {
       const int point_index = (basis_start_indices[i] + j) % size;



More information about the Bf-blender-cvs mailing list