diff options
author | Hans Goudey <h.goudey@me.com> | 2022-03-25 04:48:08 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-03-25 04:48:08 +0300 |
commit | 6e72e3fdb295fdfd3e252bd48be96e2d832e43f2 (patch) | |
tree | 70e439dfb872a2bb6dc2be33163f5fa13f82c434 /source/blender/blenkernel/intern/curve_nurbs.cc | |
parent | d3999683ff5ac8b42de74cb453b459096f76f542 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern/curve_nurbs.cc')
-rw-r--r-- | source/blender/blenkernel/intern/curve_nurbs.cc | 40 |
1 files changed, 20 insertions, 20 deletions
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, BasisCache &basis_cache) { - BLI_assert(num_points > 0); + BLI_assert(points_num > 0); BLI_assert(evaluated_size > 0); const int8_t degree = order - 1; @@ -168,7 +168,7 @@ void calculate_basis_cache(const int num_points, MutableSpan<float> basis_weights(basis_cache.weights); MutableSpan<int> basis_start_indices(basis_cache.start_indices); - const int last_control_point_index = cyclic ? num_points + degree : num_points; + const int last_control_point_index = cyclic ? points_num + degree : points_num; const int evaluated_segment_size = curve_segment_size(evaluated_size, cyclic); const float start = knots[degree]; @@ -176,7 +176,7 @@ void calculate_basis_cache(const int num_points, const float step = (end - start) / evaluated_segment_size; for (const int i : IndexRange(evaluated_size)) { /* Clamp parameter due to floating point inaccuracy. */ - const float parameter = std::clamp(start + step * i, knots[0], knots[num_points + degree]); + const float parameter = std::clamp(start + step * i, knots[0], knots[points_num + degree]); MutableSpan<float> point_weights = basis_weights.slice(i * order, order); |