diff options
-rw-r--r-- | source/blender/blenkernel/intern/spline_base.cc | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/spline_bezier.cc | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/spline_nurbs.cc | 22 |
3 files changed, 28 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/spline_base.cc b/source/blender/blenkernel/intern/spline_base.cc index b3514f23784..c18f44e07b2 100644 --- a/source/blender/blenkernel/intern/spline_base.cc +++ b/source/blender/blenkernel/intern/spline_base.cc @@ -74,9 +74,9 @@ float Spline::length() const int Spline::segments_size() const { - const int points_len = this->size(); + const int size = this->size(); - return is_cyclic_ ? points_len : points_len - 1; + return is_cyclic_ ? size : size - 1; } bool Spline::is_cyclic() const @@ -411,23 +411,23 @@ Array<float> Spline::sample_uniform_index_factors(const int samples_size) const Spline::LookupResult Spline::lookup_data_from_index_factor(const float index_factor) const { - const int points_len = this->evaluated_points_size(); + const int eval_size = this->evaluated_points_size(); if (is_cyclic_) { - if (index_factor < points_len) { + if (index_factor < eval_size) { const int index = std::floor(index_factor); - const int next_index = (index < points_len - 1) ? index + 1 : 0; + const int next_index = (index < eval_size - 1) ? index + 1 : 0; return LookupResult{index, next_index, index_factor - index}; } - return LookupResult{points_len - 1, 0, 1.0f}; + return LookupResult{eval_size - 1, 0, 1.0f}; } - if (index_factor < points_len - 1) { + if (index_factor < eval_size - 1) { const int index = std::floor(index_factor); const int next_index = index + 1; return LookupResult{index, next_index, index_factor - index}; } - return LookupResult{points_len - 2, points_len - 1, 1.0f}; + return LookupResult{eval_size - 2, eval_size - 1, 1.0f}; } void Spline::bounds_min_max(float3 &min, float3 &max, const bool use_evaluated) const diff --git a/source/blender/blenkernel/intern/spline_bezier.cc b/source/blender/blenkernel/intern/spline_bezier.cc index e4f26eaf466..daae03167ef 100644 --- a/source/blender/blenkernel/intern/spline_bezier.cc +++ b/source/blender/blenkernel/intern/spline_bezier.cc @@ -392,13 +392,13 @@ Span<int> BezierSpline::control_point_offsets() const return offset_cache_; } - const int points_len = this->size(); - offset_cache_.resize(points_len + 1); + const int size = this->size(); + offset_cache_.resize(size + 1); MutableSpan<int> offsets = offset_cache_; int offset = 0; - for (const int i : IndexRange(points_len)) { + for (const int i : IndexRange(size)) { offsets[i] = offset; offset += this->segment_is_vector(i) ? 1 : resolution_; } @@ -527,23 +527,23 @@ Span<float3> BezierSpline::evaluated_positions() const BezierSpline::InterpolationData BezierSpline::interpolation_data_from_index_factor( const float index_factor) const { - const int points_len = this->size(); + const int size = this->size(); if (is_cyclic_) { - if (index_factor < points_len) { + if (index_factor < size) { const int index = std::floor(index_factor); - const int next_index = (index < points_len - 1) ? index + 1 : 0; + const int next_index = (index < size - 1) ? index + 1 : 0; return InterpolationData{index, next_index, index_factor - index}; } - return InterpolationData{points_len - 1, 0, 1.0f}; + return InterpolationData{size - 1, 0, 1.0f}; } - if (index_factor < points_len - 1) { + if (index_factor < size - 1) { const int index = std::floor(index_factor); const int next_index = index + 1; return InterpolationData{index, next_index, index_factor - index}; } - return InterpolationData{points_len - 2, points_len - 1, 1.0f}; + return InterpolationData{size - 2, size - 1, 1.0f}; } /* Use a spline argument to avoid adding this to the header. */ diff --git a/source/blender/blenkernel/intern/spline_nurbs.cc b/source/blender/blenkernel/intern/spline_nurbs.cc index 90aadb319b7..31ac23589be 100644 --- a/source/blender/blenkernel/intern/spline_nurbs.cc +++ b/source/blender/blenkernel/intern/spline_nurbs.cc @@ -271,18 +271,18 @@ Span<float> NURBSpline::knots() const } static void calculate_basis_for_point(const float parameter, - const int points_len, + const int size, const int order, Span<float> knots, MutableSpan<float> basis_buffer, NURBSpline::BasisCache &basis_cache) { /* Clamp parameter due to floating point inaccuracy. */ - const float t = std::clamp(parameter, knots[0], knots[points_len + order - 1]); + const float t = std::clamp(parameter, knots[0], knots[size + order - 1]); int start = 0; int end = 0; - for (const int i : IndexRange(points_len + order - 1)) { + for (const int i : IndexRange(size + order - 1)) { const bool knots_equal = knots[i] == knots[i + 1]; if (knots_equal || t < knots[i] || t > knots[i + 1]) { basis_buffer[i] = 0.0f; @@ -292,14 +292,14 @@ static void calculate_basis_for_point(const float parameter, basis_buffer[i] = 1.0f; start = std::max(i - order - 1, 0); end = i; - basis_buffer.slice(i + 1, points_len + order - 1 - i).fill(0.0f); + basis_buffer.slice(i + 1, size + order - 1 - i).fill(0.0f); break; } - basis_buffer[points_len + order - 1] = 0.0f; + basis_buffer[size + order - 1] = 0.0f; for (const int i_order : IndexRange(2, order - 1)) { - if (end + i_order >= points_len + order) { - end = points_len + order - 1 - i_order; + if (end + i_order >= size + order) { + end = size + order - 1 - i_order; } for (const int i : IndexRange(start, end - start + 1)) { float new_basis = 0.0f; @@ -340,7 +340,7 @@ Span<NURBSpline::BasisCache> NURBSpline::calculate_basis_cache() const return basis_cache_; } - const int points_len = this->size(); + const int size = this->size(); const int eval_size = this->evaluated_points_size(); BLI_assert(this->evaluated_edges_size() > 0); basis_cache_.resize(eval_size); @@ -356,17 +356,17 @@ Span<NURBSpline::BasisCache> NURBSpline::calculate_basis_cache() const Array<float> basis_buffer(this->knots_size()); const float start = knots[order - 1]; - const float end = is_cyclic_ ? knots[points_len + order - 1] : knots[points_len]; + const float end = is_cyclic_ ? knots[size + order - 1] : knots[size]; const float step = (end - start) / this->evaluated_edges_size(); float parameter = start; for (const int i : IndexRange(eval_size)) { BasisCache &basis = basis_cache[i]; calculate_basis_for_point( - parameter, points_len + (is_cyclic_ ? order - 1 : 0), order, knots, basis_buffer, basis); + parameter, size + (is_cyclic_ ? order - 1 : 0), order, knots, basis_buffer, basis); BLI_assert(basis.weights.size() <= order); for (const int j : basis.weights.index_range()) { - const int point_index = (basis.start_index + j) % points_len; + const int point_index = (basis.start_index + j) % size; basis.weights[j] *= control_weights[point_index]; } |