From e253f9f66d6f63592ffd97afe207ef7c72547d03 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 23 Mar 2022 23:01:02 -0500 Subject: Cleanup: Adjust naming in new curves code Rename "size" variables and functions to use "num" instead, based on T85728 (though this doesn't apply to simple C++ containers, it applies here). Rename "range" to "points" in some functions, so be more specific. Differential Revision: https://developer.blender.org/D14431 --- source/blender/blenkernel/BKE_curves.hh | 38 +++++----- .../blender/blenkernel/intern/curve_catmull_rom.cc | 6 +- source/blender/blenkernel/intern/curve_eval.cc | 4 +- source/blender/blenkernel/intern/curve_nurbs.cc | 40 +++++------ source/blender/blenkernel/intern/curves.cc | 10 +-- .../blender/blenkernel/intern/curves_geometry.cc | 84 +++++++++++----------- .../blenkernel/intern/curves_geometry_test.cc | 2 +- .../blenkernel/intern/geometry_component_curves.cc | 4 +- 8 files changed, 94 insertions(+), 94 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index eb4f8f5d5c8..5039b6f0f57 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -122,14 +122,14 @@ class CurvesGeometry : public ::CurvesGeometry { * Accessors. */ - int points_size() const; - int curves_size() const; + int num_points() const; + int num_curves() const; IndexRange points_range() const; IndexRange curves_range() const; /** * The index of the first point in every curve. The size of this span is one larger than the - * number of curves. Consider using #range_for_curve rather than using the offsets directly. + * number of curves. Consider using #points_for_curve rather than using the offsets directly. */ Span offsets() const; MutableSpan offsets(); @@ -137,8 +137,8 @@ class CurvesGeometry : public ::CurvesGeometry { /** * Access a range of indices of point data for a specific curve. */ - IndexRange range_for_curve(int index) const; - IndexRange range_for_curves(IndexRange curves) const; + IndexRange points_for_curve(int index) const; + IndexRange points_for_curves(IndexRange curves) const; /** The type (#CurveType) of each curve, or potentially a single if all are the same type. */ VArray curve_types() const; @@ -249,11 +249,11 @@ class CurvesGeometry : public ::CurvesGeometry { * Access a range of indices of point data for a specific curve. * Call #evaluated_offsets() first to ensure that the evaluated offsets cache is current. */ - IndexRange evaluated_range_for_curve(int index) const; + IndexRange evaluated_points_for_curve(int index) const; /** * The index of the first evaluated point for every curve. The size of this span is one larger - * than the number of curves. Consider using #evaluated_range_for_curve rather than using the + * than the number of curves. Consider using #evaluated_points_for_curve rather than using the * offsets directly. */ Span evaluated_offsets() const; @@ -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 point_size, int curve_size); + void resize(int num_points, int num_curves); /** 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 size, const bool cyclic) +inline int curve_segment_size(const int num_points, const bool cyclic) { - return (cyclic && size > 2) ? size : size - 1; + return (cyclic && num_points > 2) ? num_points : num_points - 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 size: The number of points in the curve. + * \param num_points: The number of points in the curve. * \param resolution: The resolution for each segment. */ -int calculate_evaluated_size(int size, bool cyclic, int resolution); +int calculate_evaluated_size(int num_points, 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 size, int8_t order, bool cyclic, KnotsMode knots_mode); +bool check_valid_size_and_order(int num_points, 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 size, int8_t order, bool cyclic, KnotsMode k * shared. */ int calculate_evaluated_size( - int size, int8_t order, bool cyclic, int resolution, KnotsMode knots_mode); + int num_points, 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 size, int8_t order, bool cyclic); +int knots_size(int num_points, 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 size, int8_t order, bool cyclic); * changes, and is generally more intuitive than defining the knot vector manually. */ void calculate_knots( - int size, KnotsMode mode, int8_t order, bool cyclic, MutableSpan knots); + int num_points, KnotsMode mode, int8_t order, bool cyclic, MutableSpan 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 size, +void calculate_basis_cache(int num_points, 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 point_size, int curves_size); +Curves *curves_new_nomain(int num_points, int num_curves); /** * Create a new curves data-block containing a single curve with the given length and type. */ -Curves *curves_new_nomain_single(int point_size, CurveType type); +Curves *curves_new_nomain_single(int num_points, 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 27687eb736f..5b6d0cac21f 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 size, const bool cyclic, const int resolution) +int calculate_evaluated_size(const int num_points, const bool cyclic, const int resolution) { - const int eval_size = resolution * curve_segment_size(size, cyclic); + const int eval_size = resolution * curve_segment_size(num_points, cyclic); /* If the curve isn't cyclic, one last point is added to the final point. */ - return (cyclic && size > 2) ? eval_size : eval_size + 1; + return (cyclic && num_points > 2) ? eval_size : eval_size + 1; } /* Adapted from Cycles #catmull_rom_basis_eval function. */ diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc index b2399f25638..2cf83b57881 100644 --- a/source/blender/blenkernel/intern/curve_eval.cc +++ b/source/blender/blenkernel/intern/curve_eval.cc @@ -398,7 +398,7 @@ std::unique_ptr curves_to_curve_eval(const Curves &curves) VArray curve_types = geometry.curve_types(); std::unique_ptr curve_eval = std::make_unique(); for (const int curve_index : curve_types.index_range()) { - const IndexRange point_range = geometry.range_for_curve(curve_index); + const IndexRange point_range = geometry.points_for_curve(curve_index); std::unique_ptr spline; switch (curve_types[curve_index]) { @@ -489,7 +489,7 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval) const Spline &spline = *curve_eval.splines()[curve_index]; curve_types[curve_index] = curve_eval.splines()[curve_index]->type(); - const IndexRange point_range = geometry.range_for_curve(curve_index); + const IndexRange point_range = geometry.points_for_curve(curve_index); switch (spline.type()) { case CURVE_TYPE_POLY: diff --git a/source/blender/blenkernel/intern/curve_nurbs.cc b/source/blender/blenkernel/intern/curve_nurbs.cc index a4cdbbca654..bd6bd222aa3 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 size, +bool check_valid_size_and_order(const int num_points, const int8_t order, const bool cyclic, const KnotsMode knots_mode) { - if (size < order) { + if (num_points < order) { return false; } if (ELEM(knots_mode, NURBS_KNOT_MODE_BEZIER, NURBS_KNOT_MODE_ENDPOINT_BEZIER)) { - if (knots_mode == NURBS_KNOT_MODE_BEZIER && size <= order) { + if (knots_mode == NURBS_KNOT_MODE_BEZIER && num_points <= order) { return false; } - return (!cyclic || size % (order - 1) == 0); + return (!cyclic || num_points % (order - 1) == 0); } return true; } -int calculate_evaluated_size(const int size, +int calculate_evaluated_size(const int num_points, const int8_t order, const bool cyclic, const int resolution, const KnotsMode knots_mode) { - if (!check_valid_size_and_order(size, order, cyclic, knots_mode)) { + if (!check_valid_size_and_order(num_points, order, cyclic, knots_mode)) { return 0; } - return resolution * curve_segment_size(size, cyclic); + return resolution * curve_segment_size(num_points, cyclic); } -int knots_size(const int size, const int8_t order, const bool cyclic) +int knots_size(const int num_points, const int8_t order, const bool cyclic) { if (cyclic) { - return size + order * 2 - 1; + return num_points + order * 2 - 1; } - return size + order; + return num_points + order; } -void calculate_knots(const int size, +void calculate_knots(const int num_points, const KnotsMode mode, const int8_t order, const bool cyclic, MutableSpan knots) { - BLI_assert(knots.size() == knots_size(size, order, cyclic)); - UNUSED_VARS_NDEBUG(size); + BLI_assert(knots.size() == knots_size(num_points, order, cyclic)); + UNUSED_VARS_NDEBUG(num_points); 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 size, } static void calculate_basis_for_point(const float parameter, - const int size, + const int num_points, const int degree, const Span knots, MutableSpan 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(size + degree)) { + for (const int i : IndexRange(num_points + 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 = size + degree - i_order; + end = num_points + 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 size, +void calculate_basis_cache(const int num_points, const int evaluated_size, const int8_t order, const bool cyclic, const Span knots, BasisCache &basis_cache) { - BLI_assert(size > 0); + BLI_assert(num_points > 0); BLI_assert(evaluated_size > 0); const int8_t degree = order - 1; @@ -168,7 +168,7 @@ void calculate_basis_cache(const int size, MutableSpan basis_weights(basis_cache.weights); MutableSpan basis_start_indices(basis_cache.start_indices); - const int last_control_point_index = cyclic ? size + degree : size; + const int last_control_point_index = cyclic ? num_points + degree : num_points; 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 size, 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[size + degree]); + const float parameter = std::clamp(start + step * i, knots[0], knots[num_points + degree]); MutableSpan point_weights = basis_weights.slice(i * order, order); diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 838f7f28e93..e88d25ae56a 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -366,19 +366,19 @@ void BKE_curves_batch_cache_free(Curves *curves) namespace blender::bke { -Curves *curves_new_nomain(const int point_size, const int curves_size) +Curves *curves_new_nomain(const int num_points, const int num_curves) { Curves *curves = static_cast(BKE_id_new_nomain(ID_CV, nullptr)); CurvesGeometry &geometry = CurvesGeometry::wrap(curves->geometry); - geometry.resize(point_size, curves_size); + geometry.resize(num_points, num_curves); return curves; } -Curves *curves_new_nomain_single(const int point_size, const CurveType type) +Curves *curves_new_nomain_single(const int num_points, const CurveType type) { - Curves *curves = curves_new_nomain(point_size, 1); + Curves *curves = curves_new_nomain(num_points, 1); CurvesGeometry &geometry = CurvesGeometry::wrap(curves->geometry); - geometry.offsets().last() = point_size; + geometry.offsets().last() = num_points; geometry.curve_types().first() = type; return curves; } diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index db69fbc4063..f9c925b626d 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -149,24 +149,24 @@ CurvesGeometry::~CurvesGeometry() /** \name Accessors * \{ */ -int CurvesGeometry::points_size() const +int CurvesGeometry::num_points() const { return this->point_size; } -int CurvesGeometry::curves_size() const +int CurvesGeometry::num_curves() const { return this->curve_size; } IndexRange CurvesGeometry::points_range() const { - return IndexRange(this->points_size()); + return IndexRange(this->num_points()); } IndexRange CurvesGeometry::curves_range() const { - return IndexRange(this->curves_size()); + return IndexRange(this->num_curves()); } -IndexRange CurvesGeometry::range_for_curve(const int index) const +IndexRange CurvesGeometry::points_for_curve(const int index) const { BLI_assert(this->curve_size > 0); BLI_assert(this->curve_offsets != nullptr); @@ -175,7 +175,7 @@ IndexRange CurvesGeometry::range_for_curve(const int index) const return {offset, offset_next - offset}; } -IndexRange CurvesGeometry::range_for_curves(const IndexRange curves) const +IndexRange CurvesGeometry::points_for_curves(const IndexRange curves) const { BLI_assert(this->curve_size > 0); BLI_assert(this->curve_offsets != nullptr); @@ -186,7 +186,7 @@ IndexRange CurvesGeometry::range_for_curves(const IndexRange curves) const static int domain_size(const CurvesGeometry &curves, const AttributeDomain domain) { - return domain == ATTR_DOMAIN_POINT ? curves.points_size() : curves.curves_size(); + return domain == ATTR_DOMAIN_POINT ? curves.num_points() : curves.num_curves(); } static CustomData &domain_custom_data(CurvesGeometry &curves, const AttributeDomain domain) @@ -431,7 +431,7 @@ static void calculate_evaluated_offsets(const CurvesGeometry &curves, VArray nurbs_knots_modes = curves.nurbs_knots_modes(); build_offsets(offsets, [&](const int curve_index) -> int { - const IndexRange points = curves.range_for_curve(curve_index); + const IndexRange points = curves.points_for_curve(curve_index); switch (types[curve_index]) { case CURVE_TYPE_CATMULL_ROM: return curves::catmull_rom::calculate_evaluated_size( @@ -463,7 +463,7 @@ int CurvesGeometry::evaluated_points_size() const return this->evaluated_offsets().last(); } -IndexRange CurvesGeometry::evaluated_range_for_curve(int index) const +IndexRange CurvesGeometry::evaluated_points_for_curve(int index) const { BLI_assert(!this->runtime->offsets_cache_dirty); return offsets_to_range(this->runtime->evaluated_offsets_cache.as_span(), index); @@ -482,10 +482,10 @@ Span CurvesGeometry::evaluated_offsets() const } threading::isolate_task([&]() { - this->runtime->evaluated_offsets_cache.resize(this->curves_size() + 1); + this->runtime->evaluated_offsets_cache.resize(this->num_curves() + 1); if (this->has_curve_with_type(CURVE_TYPE_BEZIER)) { - this->runtime->bezier_evaluated_offsets.resize(this->points_size()); + this->runtime->bezier_evaluated_offsets.resize(this->num_points()); } else { this->runtime->bezier_evaluated_offsets.clear_and_make_inline(); @@ -536,7 +536,7 @@ void CurvesGeometry::ensure_nurbs_basis_cache() const return; } - this->runtime->nurbs_basis_cache.resize(this->curves_size()); + this->runtime->nurbs_basis_cache.resize(this->num_curves()); MutableSpan basis_caches(this->runtime->nurbs_basis_cache); VArray cyclic = this->cyclic(); @@ -545,8 +545,8 @@ void CurvesGeometry::ensure_nurbs_basis_cache() const threading::parallel_for(nurbs_mask.index_range(), 64, [&](const IndexRange range) { for (const int curve_index : nurbs_mask.slice(range)) { - const IndexRange points = this->range_for_curve(curve_index); - const IndexRange evaluated_points = this->evaluated_range_for_curve(curve_index); + const IndexRange points = this->points_for_curve(curve_index); + const IndexRange evaluated_points = this->evaluated_points_for_curve(curve_index); const int8_t order = orders[curve_index]; const bool is_cyclic = cyclic[curve_index]; @@ -598,8 +598,8 @@ Span CurvesGeometry::evaluated_positions() const threading::parallel_for(this->curves_range(), 128, [&](IndexRange curves_range) { for (const int curve_index : curves_range) { - const IndexRange points = this->range_for_curve(curve_index); - const IndexRange evaluated_points = this->evaluated_range_for_curve(curve_index); + const IndexRange points = this->points_for_curve(curve_index); + const IndexRange evaluated_points = this->evaluated_points_for_curve(curve_index); switch (types[curve_index]) { case CURVE_TYPE_CATMULL_ROM: @@ -645,16 +645,16 @@ Span CurvesGeometry::evaluated_positions() const /** \name Operations * \{ */ -void CurvesGeometry::resize(const int point_size, const int curve_size) +void CurvesGeometry::resize(const int num_points, const int num_curves) { - if (point_size != this->point_size) { - CustomData_realloc(&this->point_data, point_size); - this->point_size = point_size; + if (num_points != this->point_size) { + CustomData_realloc(&this->point_data, num_points); + this->point_size = num_points; } - if (curve_size != this->curve_size) { - CustomData_realloc(&this->curve_data, curve_size); - this->curve_size = curve_size; - this->curve_offsets = (int *)MEM_reallocN(this->curve_offsets, sizeof(int) * (curve_size + 1)); + if (num_curves != this->curve_size) { + CustomData_realloc(&this->curve_data, num_curves); + this->curve_size = num_curves; + this->curve_offsets = (int *)MEM_reallocN(this->curve_offsets, sizeof(int) * (num_curves + 1)); } this->tag_topology_changed(); this->update_customdata_pointers(); @@ -727,7 +727,7 @@ static std::optional> curves_bounds(const CurvesGeo { Span positions = curves.positions(); if (curves.radius) { - Span radii{curves.radius, curves.points_size()}; + Span radii{curves.radius, curves.num_points()}; return bounds::min_max_with_radii(positions, radii); } return bounds::min_max(positions); @@ -784,7 +784,7 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves, new_curve_ranges.append(IndexRange(new_tot_curves, curve_range.size())); new_tot_curves += curve_range.size(); - const IndexRange old_point_range = curves.range_for_curves(curve_range); + const IndexRange old_point_range = curves.points_for_curves(curve_range); old_point_ranges.append(old_point_range); new_point_ranges.append(IndexRange(new_tot_points, old_point_range.size())); new_tot_points += old_point_range.size(); @@ -889,7 +889,7 @@ static void reverse_curve_point_data(const CurvesGeometry &curves, { threading::parallel_for(curve_selection.index_range(), 256, [&](IndexRange range) { for (const int curve_i : curve_selection.slice(range)) { - data.slice(curves.range_for_curve(curve_i)).reverse(); + data.slice(curves.points_for_curve(curve_i)).reverse(); } }); } @@ -902,7 +902,7 @@ static void reverse_swap_curve_point_data(const CurvesGeometry &curves, { threading::parallel_for(curve_selection.index_range(), 256, [&](IndexRange range) { for (const int curve_i : curve_selection.slice(range)) { - const IndexRange points = curves.range_for_curve(curve_i); + const IndexRange points = curves.points_for_curve(curve_i); MutableSpan a = data_a.slice(points); MutableSpan b = data_b.slice(points); for (const int i : IndexRange(points.size() / 2)) { @@ -926,7 +926,7 @@ static bool layer_matches_name_and_type(const CustomDataLayer &layer, void CurvesGeometry::reverse_curves(const IndexMask curves_to_reverse) { - CustomData_duplicate_referenced_layers(&this->point_data, this->points_size()); + CustomData_duplicate_referenced_layers(&this->point_data, this->num_points()); /* Collect the Bezier handle attributes while iterating through the point custom data layers; * they need special treatment later. */ @@ -940,22 +940,22 @@ void CurvesGeometry::reverse_curves(const IndexMask curves_to_reverse) if (positions_left.is_empty() && layer_matches_name_and_type(layer, ATTR_HANDLE_POSITION_LEFT, CD_PROP_FLOAT3)) { - positions_left = {static_cast(layer.data), this->points_size()}; + positions_left = {static_cast(layer.data), this->num_points()}; continue; } if (positions_right.is_empty() && layer_matches_name_and_type(layer, ATTR_HANDLE_POSITION_RIGHT, CD_PROP_FLOAT3)) { - positions_right = {static_cast(layer.data), this->points_size()}; + positions_right = {static_cast(layer.data), this->num_points()}; continue; } if (types_left.is_empty() && layer_matches_name_and_type(layer, ATTR_HANDLE_TYPE_LEFT, CD_PROP_INT8)) { - types_left = {static_cast(layer.data), this->points_size()}; + types_left = {static_cast(layer.data), this->num_points()}; continue; } if (types_right.is_empty() && layer_matches_name_and_type(layer, ATTR_HANDLE_TYPE_RIGHT, CD_PROP_INT8)) { - types_right = {static_cast(layer.data), this->points_size()}; + types_right = {static_cast(layer.data), this->num_points()}; continue; } @@ -963,7 +963,7 @@ void CurvesGeometry::reverse_curves(const IndexMask curves_to_reverse) attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); reverse_curve_point_data( - *this, curves_to_reverse, {static_cast(layer.data), this->points_size()}); + *this, curves_to_reverse, {static_cast(layer.data), this->num_points()}); }); } @@ -1001,8 +1001,8 @@ static void adapt_curve_domain_point_to_curve_impl(const CurvesGeometry &curves, MutableSpan r_values) { attribute_math::DefaultMixer mixer(r_values); - for (const int i_curve : IndexRange(curves.curves_size())) { - for (const int i_point : curves.range_for_curve(i_curve)) { + for (const int i_curve : IndexRange(curves.num_curves())) { + for (const int i_point : curves.points_for_curve(i_curve)) { mixer.mix_in(i_curve, old_values[i_point]); } } @@ -1022,8 +1022,8 @@ void adapt_curve_domain_point_to_curve_impl(const CurvesGeometry &curves, MutableSpan r_values) { r_values.fill(true); - for (const int i_curve : IndexRange(curves.curves_size())) { - for (const int i_point : curves.range_for_curve(i_curve)) { + for (const int i_curve : IndexRange(curves.num_curves())) { + for (const int i_point : curves.points_for_curve(i_curve)) { if (!old_values[i_point]) { r_values[i_curve] = false; break; @@ -1039,7 +1039,7 @@ static GVArray adapt_curve_domain_point_to_curve(const CurvesGeometry &curves, attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) { using T = decltype(dummy); if constexpr (!std::is_void_v>) { - Array values(curves.curves_size()); + Array values(curves.num_curves()); adapt_curve_domain_point_to_curve_impl(curves, varray.typed(), values); new_varray = VArray::ForContainer(std::move(values)); } @@ -1059,8 +1059,8 @@ static void adapt_curve_domain_curve_to_point_impl(const CurvesGeometry &curves, const VArray &old_values, MutableSpan r_values) { - for (const int i_curve : IndexRange(curves.curves_size())) { - r_values.slice(curves.range_for_curve(i_curve)).fill(old_values[i_curve]); + for (const int i_curve : IndexRange(curves.num_curves())) { + r_values.slice(curves.points_for_curve(i_curve)).fill(old_values[i_curve]); } } @@ -1070,7 +1070,7 @@ static GVArray adapt_curve_domain_curve_to_point(const CurvesGeometry &curves, GVArray new_varray; attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) { using T = decltype(dummy); - Array values(curves.points_size()); + Array values(curves.num_points()); adapt_curve_domain_curve_to_point_impl(curves, varray.typed(), values); new_varray = VArray::ForContainer(std::move(values)); }); diff --git a/source/blender/blenkernel/intern/curves_geometry_test.cc b/source/blender/blenkernel/intern/curves_geometry_test.cc index 1b3b3f54451..fd994d5abf4 100644 --- a/source/blender/blenkernel/intern/curves_geometry_test.cc +++ b/source/blender/blenkernel/intern/curves_geometry_test.cc @@ -46,7 +46,7 @@ TEST(curves_geometry, Move) CurvesGeometry other = std::move(curves); /* The old curves should be empty, and the offsets are expected to be null. */ - EXPECT_EQ(curves.points_size(), 0); /* NOLINT: bugprone-use-after-move */ + EXPECT_EQ(curves.num_points(), 0); /* NOLINT: bugprone-use-after-move */ EXPECT_EQ(curves.curve_offsets, nullptr); /* NOLINT: bugprone-use-after-move */ /* Just a basic check that the new curves work okay. */ diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index 7cf6fc5a03e..83b8e5fb262 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -236,10 +236,10 @@ int CurveComponent::attribute_domain_size(const AttributeDomain domain) const const blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap( curves_->geometry); if (domain == ATTR_DOMAIN_POINT) { - return geometry.points_size(); + return geometry.num_points(); } if (domain == ATTR_DOMAIN_CURVE) { - return geometry.curves_size(); + return geometry.num_curves(); } return 0; } -- cgit v1.2.3