From 8551e890687de7185388eed9e77171b0df7943a3 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 6 Apr 2022 16:30:27 -0500 Subject: Curves: Name mutable data retrieval functions explicitly Add "for_write" on function names that retrieve mutable data arrays. Though this makes function names longer, it's likely worth it because it allows more easily using the const functions in a non-const context, and reduces cases of mistakenly retrieving with edit access. In the long term, this situation might change more if we implement attributes storage that is accessible directly on `CurvesGeometry` without duplicating the attribute API on geometry components, which is currently the rough plan. Differential Revision: https://developer.blender.org/D14562 --- source/blender/blenkernel/BKE_curves.hh | 28 ++++---- source/blender/blenkernel/intern/curve_eval.cc | 4 +- source/blender/blenkernel/intern/curves.cc | 6 +- .../blender/blenkernel/intern/curves_geometry.cc | 81 ++++++++++------------ .../blenkernel/intern/curves_geometry_test.cc | 78 ++++++++++----------- source/blender/editors/curves/intern/curves_add.cc | 4 +- source/blender/editors/curves/intern/curves_ops.cc | 2 +- .../editors/sculpt_paint/curves_sculpt_add.cc | 12 ++-- .../editors/sculpt_paint/curves_sculpt_comb.cc | 6 +- .../editors/sculpt_paint/curves_sculpt_delete.cc | 2 +- .../sculpt_paint/curves_sculpt_grow_shrink.cc | 6 +- .../editors/sculpt_paint/curves_sculpt_ops.cc | 4 +- .../sculpt_paint/curves_sculpt_snake_hook.cc | 4 +- .../geometry/intern/mesh_to_curve_convert.cc | 10 +-- .../blender/geometry/intern/realize_instances.cc | 6 +- .../geometry/nodes/node_geo_curve_primitive_arc.cc | 8 +-- .../node_geo_curve_primitive_bezier_segment.cc | 12 ++-- .../nodes/node_geo_curve_primitive_circle.cc | 8 +-- .../nodes/node_geo_curve_primitive_line.cc | 8 +-- .../node_geo_curve_primitive_quadratic_bezier.cc | 2 +- .../node_geo_curve_primitive_quadrilateral.cc | 4 +- .../nodes/node_geo_curve_primitive_spiral.cc | 2 +- .../nodes/node_geo_curve_primitive_star.cc | 4 +- .../geometry/nodes/node_geo_curve_resample.cc | 12 ++-- .../nodes/node_geo_curve_set_handle_type.cc | 4 +- .../geometry/nodes/node_geo_duplicate_elements.cc | 4 +- .../geometry/nodes/node_geo_set_curve_handles.cc | 17 ++--- 27 files changed, 167 insertions(+), 171 deletions(-) diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index 4117f8b9bdc..8d24b6136b2 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -141,7 +141,7 @@ class CurvesGeometry : public ::CurvesGeometry { * number of curves. Consider using #points_for_curve rather than using the offsets directly. */ Span offsets() const; - MutableSpan offsets(); + MutableSpan offsets_for_write(); /** * Access a range of indices of point data for a specific curve. @@ -152,19 +152,19 @@ class CurvesGeometry : public ::CurvesGeometry { /** The type (#CurveType) of each curve, or potentially a single if all are the same type. */ VArray curve_types() const; /** Mutable access to curve types. Call #tag_topology_changed after changing any type. */ - MutableSpan curve_types(); + MutableSpan curve_types_for_write(); bool has_curve_with_type(const CurveType type) const; /** Return the number of curves with each type. */ std::array count_curve_types() const; - MutableSpan positions(); Span positions() const; + MutableSpan positions_for_write(); /** Whether the curve loops around to connect to itself, on the curve domain. */ VArray cyclic() const; /** Mutable access to curve cyclic values. Call #tag_topology_changed after changes. */ - MutableSpan cyclic(); + MutableSpan cyclic_for_write(); /** * How many evaluated points to create for each segment when evaluating Bezier, @@ -172,15 +172,15 @@ class CurvesGeometry : public ::CurvesGeometry { */ VArray resolution() const; /** Mutable access to curve resolution. Call #tag_topology_changed after changes. */ - MutableSpan resolution(); + MutableSpan resolution_for_write(); /** * Handle types for Bezier control points. Call #tag_topology_changed after changes. */ VArray handle_types_left() const; - MutableSpan handle_types_left(); + MutableSpan handle_types_left_for_write(); VArray handle_types_right() const; - MutableSpan handle_types_right(); + MutableSpan handle_types_right_for_write(); /** * The positions of Bezier curve handles. Though these are really control points for the Bezier @@ -189,36 +189,36 @@ class CurvesGeometry : public ::CurvesGeometry { * after changes. */ Span handle_positions_left() const; - MutableSpan handle_positions_left(); + MutableSpan handle_positions_left_for_write(); Span handle_positions_right() const; - MutableSpan handle_positions_right(); + MutableSpan handle_positions_right_for_write(); /** * The order (degree plus one) of each NURBS curve, on the curve domain. * Call #tag_topology_changed after changes. */ VArray nurbs_orders() const; - MutableSpan nurbs_orders(); + MutableSpan nurbs_orders_for_write(); /** * The automatic generation mode for each NURBS curve's knots vector, on the curve domain. * Call #tag_topology_changed after changes. */ VArray nurbs_knots_modes() const; - MutableSpan nurbs_knots_modes(); + MutableSpan nurbs_knots_modes_for_write(); /** * The weight for each control point for NURBS curves. Call #tag_positions_changed after changes. */ Span nurbs_weights() const; - MutableSpan nurbs_weights(); + MutableSpan nurbs_weights_for_write(); /** * The index of a triangle (#MLoopTri) that a curve is attached to. * The index is -1, if the curve is not attached. */ VArray surface_triangle_indices() const; - MutableSpan surface_triangle_indices(); + MutableSpan surface_triangle_indices_for_write(); /** * Barycentric coordinates of the attachment point within a triangle. @@ -229,7 +229,7 @@ class CurvesGeometry : public ::CurvesGeometry { * The span can be empty, when all triangle indices are -1. */ Span surface_triangle_coords() const; - MutableSpan surface_triangle_coords(); + MutableSpan surface_triangle_coords_for_write(); /** * Calculate the largest and smallest position values, only including control points diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc index 2cf83b57881..7761b7acc49 100644 --- a/source/blender/blenkernel/intern/curve_eval.cc +++ b/source/blender/blenkernel/intern/curve_eval.cc @@ -462,8 +462,8 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval) dst_component.replace(curves, GeometryOwnershipType::Editable); blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap(curves->geometry); - geometry.offsets().copy_from(curve_eval.control_point_offsets()); - MutableSpan curve_types = geometry.curve_types(); + geometry.offsets_for_write().copy_from(curve_eval.control_point_offsets()); + MutableSpan curve_types = geometry.curve_types_for_write(); OutputAttribute_Typed nurbs_weight; OutputAttribute_Typed nurbs_order; diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 82db1176759..ebbdff55a55 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -318,7 +318,7 @@ static Curves *curves_evaluate_modifiers(struct Depsgraph *depsgraph, /* Created deformed coordinates array on demand. */ blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap( curves->geometry); - MutableSpan positions = geometry.positions(); + MutableSpan positions = geometry.positions_for_write(); mti->deformVerts(md, &mectx, @@ -378,8 +378,8 @@ Curves *curves_new_nomain_single(const int points_num, const CurveType type) { Curves *curves = curves_new_nomain(points_num, 1); CurvesGeometry &geometry = CurvesGeometry::wrap(curves->geometry); - geometry.offsets().last() = points_num; - geometry.curve_types().first() = type; + geometry.offsets_for_write().last() = points_num; + geometry.curve_types_for_write().first() = type; return curves; } diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 552d7622932..9296aeafd52 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -78,7 +78,7 @@ static void copy_curves_geometry(CurvesGeometry &dst, const CurvesGeometry &src) MEM_SAFE_FREE(dst.curve_offsets); dst.curve_offsets = (int *)MEM_calloc_arrayN(dst.point_size + 1, sizeof(int), __func__); - dst.offsets().copy_from(src.offsets()); + dst.offsets_for_write().copy_from(src.offsets()); dst.tag_topology_changed(); @@ -224,7 +224,7 @@ VArray CurvesGeometry::curve_types() const *this, ATTR_DOMAIN_CURVE, ATTR_CURVE_TYPE, CURVE_TYPE_CATMULL_ROM); } -MutableSpan CurvesGeometry::curve_types() +MutableSpan CurvesGeometry::curve_types_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_CURVE_TYPE); } @@ -277,22 +277,22 @@ std::array CurvesGeometry::count_curve_types() const }); } -MutableSpan CurvesGeometry::positions() +Span CurvesGeometry::positions() const +{ + return {(const float3 *)this->position, this->point_size}; +} +MutableSpan CurvesGeometry::positions_for_write() { this->position = (float(*)[3])CustomData_duplicate_referenced_layer_named( &this->point_data, CD_PROP_FLOAT3, ATTR_POSITION.c_str(), this->point_size); return {(float3 *)this->position, this->point_size}; } -Span CurvesGeometry::positions() const -{ - return {(const float3 *)this->position, this->point_size}; -} -MutableSpan CurvesGeometry::offsets() +Span CurvesGeometry::offsets() const { return {this->curve_offsets, this->curve_size + 1}; } -Span CurvesGeometry::offsets() const +MutableSpan CurvesGeometry::offsets_for_write() { return {this->curve_offsets, this->curve_size + 1}; } @@ -301,8 +301,7 @@ VArray CurvesGeometry::cyclic() const { return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_CYCLIC, false); } - -MutableSpan CurvesGeometry::cyclic() +MutableSpan CurvesGeometry::cyclic_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_CYCLIC); } @@ -311,8 +310,7 @@ VArray CurvesGeometry::resolution() const { return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_RESOLUTION, 12); } - -MutableSpan CurvesGeometry::resolution() +MutableSpan CurvesGeometry::resolution_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_RESOLUTION); } @@ -321,7 +319,7 @@ VArray CurvesGeometry::handle_types_left() const { return get_varray_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_LEFT, 0); } -MutableSpan CurvesGeometry::handle_types_left() +MutableSpan CurvesGeometry::handle_types_left_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_LEFT); } @@ -330,7 +328,7 @@ VArray CurvesGeometry::handle_types_right() const { return get_varray_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_RIGHT, 0); } -MutableSpan CurvesGeometry::handle_types_right() +MutableSpan CurvesGeometry::handle_types_right_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_RIGHT); } @@ -339,7 +337,7 @@ Span CurvesGeometry::handle_positions_left() const { return get_span_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_LEFT); } -MutableSpan CurvesGeometry::handle_positions_left() +MutableSpan CurvesGeometry::handle_positions_left_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_LEFT); } @@ -348,7 +346,7 @@ Span CurvesGeometry::handle_positions_right() const { return get_span_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_RIGHT); } -MutableSpan CurvesGeometry::handle_positions_right() +MutableSpan CurvesGeometry::handle_positions_right_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_RIGHT); } @@ -357,7 +355,7 @@ VArray CurvesGeometry::nurbs_orders() const { return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_ORDER, 4); } -MutableSpan CurvesGeometry::nurbs_orders() +MutableSpan CurvesGeometry::nurbs_orders_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_ORDER); } @@ -366,7 +364,7 @@ Span CurvesGeometry::nurbs_weights() const { return get_span_attribute(*this, ATTR_DOMAIN_POINT, ATTR_NURBS_WEIGHT); } -MutableSpan CurvesGeometry::nurbs_weights() +MutableSpan CurvesGeometry::nurbs_weights_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_NURBS_WEIGHT); } @@ -375,7 +373,7 @@ VArray CurvesGeometry::nurbs_knots_modes() const { return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_KNOTS_MODE, 0); } -MutableSpan CurvesGeometry::nurbs_knots_modes() +MutableSpan CurvesGeometry::nurbs_knots_modes_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_KNOTS_MODE); } @@ -385,7 +383,7 @@ VArray CurvesGeometry::surface_triangle_indices() const return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_INDEX, -1); } -MutableSpan CurvesGeometry::surface_triangle_indices() +MutableSpan CurvesGeometry::surface_triangle_indices_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_INDEX); } @@ -395,7 +393,7 @@ Span CurvesGeometry::surface_triangle_coords() const return get_span_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_COORDINATE); } -MutableSpan CurvesGeometry::surface_triangle_coords() +MutableSpan CurvesGeometry::surface_triangle_coords_for_write() { return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_COORDINATE); } @@ -768,20 +766,19 @@ static void transform_positions(MutableSpan positions, const float4x4 &m void CurvesGeometry::calculate_bezier_auto_handles() { - const VArray types = std::as_const(*this).curve_types(); + const VArray types = this->curve_types(); if (types.is_single() && types.get_internal_single() != CURVE_TYPE_BEZIER) { return; } - if (std::as_const(*this).handle_positions_left().is_empty() || - std::as_const(*this).handle_positions_right().is_empty()) { + if (this->handle_positions_left().is_empty() || this->handle_positions_right().is_empty()) { return; } - const VArray cyclic = std::as_const(*this).cyclic(); - const Span types_left = this->handle_types_left(); - const Span types_right = this->handle_types_right(); + const VArray cyclic = this->cyclic(); + const VArray_Span types_left{this->handle_types_left()}; + const VArray_Span types_right{this->handle_types_right()}; const Span positions = this->positions(); - MutableSpan positions_left = this->handle_positions_left(); - MutableSpan positions_right = this->handle_positions_right(); + MutableSpan positions_left = this->handle_positions_left_for_write(); + MutableSpan positions_right = this->handle_positions_right_for_write(); threading::parallel_for(this->curves_range(), 128, [&](IndexRange range) { for (const int i_curve : range) { @@ -800,26 +797,24 @@ void CurvesGeometry::calculate_bezier_auto_handles() void CurvesGeometry::translate(const float3 &translation) { - /* Use `as_const` because the non-const functions can add the handle attributes. */ - translate_positions(this->positions(), translation); - if (!std::as_const(*this).handle_positions_left().is_empty()) { - translate_positions(this->handle_positions_left(), translation); + translate_positions(this->positions_for_write(), translation); + if (!this->handle_positions_left().is_empty()) { + translate_positions(this->handle_positions_left_for_write(), translation); } - if (!std::as_const(*this).handle_positions_right().is_empty()) { - translate_positions(this->handle_positions_right(), translation); + if (!this->handle_positions_right().is_empty()) { + translate_positions(this->handle_positions_right_for_write(), translation); } this->tag_positions_changed(); } void CurvesGeometry::transform(const float4x4 &matrix) { - /* Use `as_const` because the non-const functions can add the handle attributes. */ - transform_positions(this->positions(), matrix); - if (!std::as_const(*this).handle_positions_left().is_empty()) { - transform_positions(this->handle_positions_left(), matrix); + transform_positions(this->positions_for_write(), matrix); + if (!this->handle_positions_left().is_empty()) { + transform_positions(this->handle_positions_left_for_write(), matrix); } - if (!std::as_const(*this).handle_positions_right().is_empty()) { - transform_positions(this->handle_positions_right(), matrix); + if (!this->handle_positions_right().is_empty()) { + transform_positions(this->handle_positions_right_for_write(), matrix); } this->tag_positions_changed(); } @@ -896,7 +891,7 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves, threading::parallel_invoke( /* Initialize curve offsets. */ [&]() { - MutableSpan new_offsets = new_curves.offsets(); + MutableSpan new_offsets = new_curves.offsets_for_write(); new_offsets.last() = new_tot_points; threading::parallel_for( old_curve_ranges.index_range(), 128, [&](const IndexRange ranges_range) { diff --git a/source/blender/blenkernel/intern/curves_geometry_test.cc b/source/blender/blenkernel/intern/curves_geometry_test.cc index baa47bb7cf6..56e488b9034 100644 --- a/source/blender/blenkernel/intern/curves_geometry_test.cc +++ b/source/blender/blenkernel/intern/curves_geometry_test.cc @@ -16,12 +16,12 @@ static CurvesGeometry create_basic_curves(const int points_size, const int curve const int curve_length = points_size / curves_size; for (const int i : curves.curves_range()) { - curves.offsets()[i] = points_size * curve_length; + curves.offsets_for_write()[i] = points_size * curve_length; } - curves.offsets().last() = points_size; + curves.offsets_for_write().last() = points_size; for (const int i : curves.points_range()) { - curves.positions()[i] = {float(i), float(i % curve_length), 0.0f}; + curves.positions_for_write()[i] = {float(i), float(i % curve_length), 0.0f}; } return curves; @@ -66,7 +66,7 @@ TEST(curves_geometry, Move) TEST(curves_geometry, TypeCount) { CurvesGeometry curves = create_basic_curves(100, 10); - curves.curve_types().copy_from({ + curves.curve_types_for_write().copy_from({ CURVE_TYPE_BEZIER, CURVE_TYPE_NURBS, CURVE_TYPE_NURBS, @@ -88,12 +88,12 @@ TEST(curves_geometry, TypeCount) TEST(curves_geometry, CatmullRomEvaluation) { CurvesGeometry curves(4, 1); - curves.curve_types().fill(CURVE_TYPE_CATMULL_ROM); - curves.resolution().fill(12); - curves.offsets().last() = 4; - curves.cyclic().fill(false); + curves.curve_types_for_write().fill(CURVE_TYPE_CATMULL_ROM); + curves.resolution_for_write().fill(12); + curves.offsets_for_write().last() = 4; + curves.cyclic_for_write().fill(false); - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); positions[0] = {1, 1, 0}; positions[1] = {0, 1, 0}; positions[2] = {0, 0, 0}; @@ -156,7 +156,7 @@ TEST(curves_geometry, CatmullRomEvaluation) positions[1] = {1, 1, 0}; positions[2] = {0, 1, 0}; positions[3] = {0, 0, 0}; - curves.cyclic().fill(true); + curves.cyclic_for_write().fill(true); /* Tag topology changed because the new cyclic value is different. */ curves.tag_topology_changed(); @@ -221,10 +221,10 @@ TEST(curves_geometry, CatmullRomEvaluation) TEST(curves_geometry, CatmullRomTwoPointCyclic) { CurvesGeometry curves(2, 1); - curves.curve_types().fill(CURVE_TYPE_CATMULL_ROM); - curves.resolution().fill(12); - curves.offsets().last() = 2; - curves.cyclic().fill(true); + curves.curve_types_for_write().fill(CURVE_TYPE_CATMULL_ROM); + curves.resolution_for_write().fill(12); + curves.offsets_for_write().last() = 2; + curves.cyclic_for_write().fill(true); /* The curve should still be cyclic when there are only two control points. */ EXPECT_EQ(curves.evaluated_points_num(), 24); @@ -233,13 +233,13 @@ TEST(curves_geometry, CatmullRomTwoPointCyclic) TEST(curves_geometry, BezierPositionEvaluation) { CurvesGeometry curves(2, 1); - curves.curve_types().fill(CURVE_TYPE_BEZIER); - curves.resolution().fill(12); - curves.offsets().last() = 2; + curves.curve_types_for_write().fill(CURVE_TYPE_BEZIER); + curves.resolution_for_write().fill(12); + curves.offsets_for_write().last() = 2; - MutableSpan handles_left = curves.handle_positions_left(); - MutableSpan handles_right = curves.handle_positions_right(); - MutableSpan positions = curves.positions(); + MutableSpan handles_left = curves.handle_positions_left_for_write(); + MutableSpan handles_right = curves.handle_positions_right_for_write(); + MutableSpan positions = curves.positions_for_write(); positions.first() = {-1, 0, 0}; positions.last() = {1, 0, 0}; handles_right.first() = {-0.5f, 0.5f, 0.0f}; @@ -270,12 +270,12 @@ TEST(curves_geometry, BezierPositionEvaluation) } curves.resize(4, 2); - curves.curve_types().fill(CURVE_TYPE_BEZIER); - curves.resolution().fill(9); - curves.offsets().last() = 4; - handles_left = curves.handle_positions_left(); - handles_right = curves.handle_positions_right(); - positions = curves.positions(); + curves.curve_types_for_write().fill(CURVE_TYPE_BEZIER); + curves.resolution_for_write().fill(9); + curves.offsets_for_write().last() = 4; + handles_left = curves.handle_positions_left_for_write(); + handles_right = curves.handle_positions_right_for_write(); + positions = curves.positions_for_write(); positions[2] = {-1, 1, 0}; positions[3] = {1, 1, 0}; handles_right[2] = {-0.5f, 1.5f, 0.0f}; @@ -317,11 +317,11 @@ TEST(curves_geometry, BezierPositionEvaluation) TEST(curves_geometry, NURBSEvaluation) { CurvesGeometry curves(4, 1); - curves.curve_types().fill(CURVE_TYPE_NURBS); - curves.resolution().fill(10); - curves.offsets().last() = 4; + curves.curve_types_for_write().fill(CURVE_TYPE_NURBS); + curves.resolution_for_write().fill(10); + curves.offsets_for_write().last() = 4; - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); positions[0] = {1, 1, 0}; positions[1] = {0, 1, 0}; positions[2] = {0, 0, 0}; @@ -345,7 +345,7 @@ TEST(curves_geometry, NURBSEvaluation) } /* Test a cyclic curve. */ - curves.cyclic().fill(true); + curves.cyclic_for_write().fill(true); curves.tag_topology_changed(); evaluated_positions = curves.evaluated_positions(); static const Array result_2{{ @@ -379,8 +379,8 @@ TEST(curves_geometry, NURBSEvaluation) positions[1] = {1, 1, 0}; positions[2] = {0, 1, 0}; positions[3] = {0, 0, 0}; - curves.nurbs_weights().fill(1.0f); - curves.nurbs_weights()[0] = 4.0f; + curves.nurbs_weights_for_write().fill(1.0f); + curves.nurbs_weights_for_write()[0] = 4.0f; curves.tag_positions_changed(); static const Array result_3{{ {0.888889, 0.555556, 0}, {0.837792, 0.643703, 0}, {0.773885, 0.727176, 0}, @@ -407,13 +407,13 @@ TEST(curves_geometry, NURBSEvaluation) TEST(curves_geometry, BezierGenericEvaluation) { CurvesGeometry curves(3, 1); - curves.curve_types().fill(CURVE_TYPE_BEZIER); - curves.resolution().fill(8); - curves.offsets().last() = 3; + curves.curve_types_for_write().fill(CURVE_TYPE_BEZIER); + curves.resolution_for_write().fill(8); + curves.offsets_for_write().last() = 3; - MutableSpan handles_left = curves.handle_positions_left(); - MutableSpan handles_right = curves.handle_positions_right(); - MutableSpan positions = curves.positions(); + MutableSpan handles_left = curves.handle_positions_left_for_write(); + MutableSpan handles_right = curves.handle_positions_right_for_write(); + MutableSpan positions = curves.positions_for_write(); positions.first() = {-1, 0, 0}; handles_right.first() = {-1, 1, 0}; handles_left[1] = {0, 0, 0}; diff --git a/source/blender/editors/curves/intern/curves_add.cc b/source/blender/editors/curves/intern/curves_add.cc index 17108619a4d..7d9e663c444 100644 --- a/source/blender/editors/curves/intern/curves_add.cc +++ b/source/blender/editors/curves/intern/curves_add.cc @@ -16,8 +16,8 @@ bke::CurvesGeometry primitive_random_sphere(const int curves_size, const int poi { bke::CurvesGeometry curves(points_per_curve * curves_size, curves_size); - MutableSpan offsets = curves.offsets(); - MutableSpan positions = curves.positions(); + MutableSpan offsets = curves.offsets_for_write(); + MutableSpan positions = curves.positions_for_write(); float *radius_data = (float *)CustomData_add_layer_named( &curves.point_data, CD_PROP_FLOAT, CD_DEFAULT, nullptr, curves.point_size, "radius"); diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index 07dd650d433..c6dd4508b5a 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -134,7 +134,7 @@ static int curves_convert_to_particle_system_exec(bContext *C, wmOperator *UNUSE Mesh &surface_me = *static_cast(surface_ob.data); const Span positions_cu = curves.positions(); - const VArray looptri_indices = std::as_const(curves).surface_triangle_indices(); + const VArray looptri_indices = curves.surface_triangle_indices(); const Span looptris{BKE_mesh_runtime_looptri_ensure(&surface_me), BKE_mesh_runtime_looptri_len(&surface_me)}; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc index 809511d0106..5f262384945 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc @@ -527,7 +527,7 @@ struct AddOperationExecutor { void initialize_curve_offsets(const int tot_added_curves) { - MutableSpan offsets = curves_->offsets(); + MutableSpan offsets = curves_->offsets_for_write(); threading::parallel_for(IndexRange(tot_added_curves), 1024, [&](const IndexRange range) { for (const int i : range) { const int curve_i = tot_old_curves_ + i; @@ -656,8 +656,8 @@ struct AddOperationExecutor { void initialize_surface_attachment(const AddedPoints &added_points) { - MutableSpan surface_triangle_indices = curves_->surface_triangle_indices(); - MutableSpan surface_triangle_coords = curves_->surface_triangle_coords(); + MutableSpan surface_triangle_indices = curves_->surface_triangle_indices_for_write(); + MutableSpan surface_triangle_coords = curves_->surface_triangle_coords_for_write(); threading::parallel_for( added_points.bary_coords.index_range(), 1024, [&](const IndexRange range) { for (const int i : range) { @@ -675,7 +675,7 @@ struct AddOperationExecutor { const Span lengths_cu, const MutableSpan normals_su) { - MutableSpan positions_cu = curves_->positions(); + MutableSpan positions_cu = curves_->positions_for_write(); threading::parallel_for( added_points.bary_coords.index_range(), 256, [&](const IndexRange range) { @@ -701,8 +701,8 @@ struct AddOperationExecutor { const Span new_normals_su, const Span new_lengths_cu) { - MutableSpan positions_cu = curves_->positions(); - const Span surface_triangle_indices = curves_->surface_triangle_indices(); + MutableSpan positions_cu = curves_->positions_for_write(); + const VArray_Span surface_triangle_indices{curves_->surface_triangle_indices()}; const Span surface_triangle_coords = curves_->surface_triangle_coords(); threading::parallel_for( diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc b/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc index d062fe32cfe..6a47f90d4ac 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc @@ -191,7 +191,7 @@ struct CombOperationExecutor { */ void comb_projected(EnumerableThreadSpecific> &r_changed_curves) { - MutableSpan positions_cu = curves_->positions(); + MutableSpan positions_cu = curves_->positions_for_write(); float4x4 projection; ED_view3d_ob_project_mat_get(rv3d_, object_, projection.values); @@ -246,7 +246,7 @@ struct CombOperationExecutor { */ void comb_spherical(EnumerableThreadSpecific> &r_changed_curves) { - MutableSpan positions_cu = curves_->positions(); + MutableSpan positions_cu = curves_->positions_for_write(); float4x4 projection; ED_view3d_ob_project_mat_get(rv3d_, object_, projection.values); @@ -344,7 +344,7 @@ struct CombOperationExecutor { void restore_segment_lengths(EnumerableThreadSpecific> &changed_curves) { const Span expected_lengths_cu = self_->segment_lengths_cu_; - MutableSpan positions_cu = curves_->positions(); + MutableSpan positions_cu = curves_->positions_for_write(); threading::parallel_for_each(changed_curves, [&](const Vector &changed_curves) { threading::parallel_for(changed_curves.index_range(), 256, [&](const IndexRange range) { diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc b/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc index ae87f414dd5..018c8c2a34f 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc @@ -60,7 +60,7 @@ class DeleteOperation : public CurvesSculptStrokeOperation { Curves &curves_id = *static_cast(object.data); CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); - MutableSpan positions = curves.positions(); + Span positions = curves.positions(); const float2 mouse_start = stroke_extension.is_first ? stroke_extension.mouse_position : last_mouse_position_; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc index 230da61c95b..7cc5e524c30 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc @@ -79,7 +79,7 @@ class ShrinkCurvesEffect : public CurvesEffect { const Span curve_indices, const Span move_distances_cu) override { - MutableSpan positions_cu = curves.positions(); + MutableSpan positions_cu = curves.positions_for_write(); threading::parallel_for(curve_indices.index_range(), 256, [&](const IndexRange range) { for (const int influence_i : range) { const int curve_i = curve_indices[influence_i]; @@ -132,7 +132,7 @@ class ExtrapolateCurvesEffect : public CurvesEffect { const Span curve_indices, const Span move_distances_cu) override { - MutableSpan positions_cu = curves.positions(); + MutableSpan positions_cu = curves.positions_for_write(); threading::parallel_for(curve_indices.index_range(), 256, [&](const IndexRange range) { for (const int influence_i : range) { const int curve_i = curve_indices[influence_i]; @@ -214,7 +214,7 @@ class ScaleCurvesEffect : public CurvesEffect { const Span curve_indices, const Span move_distances_cu) override { - MutableSpan positions_cu = curves.positions(); + MutableSpan positions_cu = curves.positions_for_write(); threading::parallel_for(curve_indices.index_range(), 256, [&](const IndexRange range) { for (const int influence_i : range) { const int curve_i = curve_indices[influence_i]; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 8afdd7f3481..dcfda658bbd 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -480,8 +480,8 @@ class DensityAddOperation : public CurvesSculptStrokeOperation { curves.resize(curves.points_num() + tot_new_curves * points_per_curve, curves.curves_num() + tot_new_curves); - MutableSpan offsets = curves.offsets(); - MutableSpan positions = curves.positions(); + MutableSpan offsets = curves.offsets_for_write(); + MutableSpan positions = curves.positions_for_write(); for (const int i : IndexRange(tot_new_curves)) { const int curve_i = curves.curves_num() - tot_new_curves + i; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc b/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc index 1fb3931e00f..39321243553 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc @@ -148,7 +148,7 @@ struct SnakeHookOperatorExecutor { void projected_snake_hook() { - MutableSpan positions_cu = curves_->positions(); + MutableSpan positions_cu = curves_->positions_for_write(); float4x4 projection; ED_view3d_ob_project_mat_get(rv3d_, object_, projection.values); @@ -184,7 +184,7 @@ struct SnakeHookOperatorExecutor { void spherical_snake_hook() { - MutableSpan positions_cu = curves_->positions(); + MutableSpan positions_cu = curves_->positions_for_write(); float4x4 projection; ED_view3d_ob_project_mat_get(rv3d_, object_, projection.values); diff --git a/source/blender/geometry/intern/mesh_to_curve_convert.cc b/source/blender/geometry/intern/mesh_to_curve_convert.cc index 5ba9bc066fd..a8eaa828caf 100644 --- a/source/blender/geometry/intern/mesh_to_curve_convert.cc +++ b/source/blender/geometry/intern/mesh_to_curve_convert.cc @@ -36,12 +36,12 @@ static Curves *create_curve_from_vert_indices(const MeshComponent &mesh_componen { Curves *curves_id = bke::curves_new_nomain(vert_indices.size(), curve_offsets.size()); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - curves.offsets().drop_back(1).copy_from(curve_offsets); - curves.offsets().last() = vert_indices.size(); - curves.curve_types().fill(CURVE_TYPE_POLY); + curves.offsets_for_write().drop_back(1).copy_from(curve_offsets); + curves.offsets_for_write().last() = vert_indices.size(); + curves.curve_types_for_write().fill(CURVE_TYPE_POLY); - curves.cyclic().fill(false); - curves.cyclic().slice(cyclic_curves).fill(true); + curves.cyclic_for_write().fill(false); + curves.cyclic_for_write().slice(cyclic_curves).fill(true); Set source_attribute_ids = mesh_component.attribute_ids(); diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc index 623bce35a15..0a0f01c1ff2 100644 --- a/source/blender/geometry/intern/realize_instances.cc +++ b/source/blender/geometry/intern/realize_instances.cc @@ -1143,7 +1143,7 @@ static void execute_realize_curve_task(const RealizeInstancesOptions &options, const IndexRange dst_curve_range{task.start_indices.curve, curves.curves_num()}; copy_transformed_positions( - curves.positions(), task.transform, dst_curves.positions().slice(dst_point_range)); + curves.positions(), task.transform, dst_curves.positions_for_write().slice(dst_point_range)); /* Copy and transform handle positions if necessary. */ if (all_curves_info.create_handle_postion_attributes) { @@ -1175,7 +1175,7 @@ static void execute_realize_curve_task(const RealizeInstancesOptions &options, /* Copy curve offsets. */ const Span src_offsets = curves.offsets(); - const MutableSpan dst_offsets = dst_curves.offsets().slice(dst_curve_range); + const MutableSpan dst_offsets = dst_curves.offsets_for_write().slice(dst_curve_range); threading::parallel_for(curves.curves_range(), 2048, [&](const IndexRange range) { for (const int i : range) { dst_offsets[i] = task.start_indices.point + src_offsets[i]; @@ -1223,7 +1223,7 @@ static void execute_realize_curve_tasks(const RealizeInstancesOptions &options, /* Allocate new curves data-block. */ Curves *dst_curves_id = bke::curves_new_nomain(points_size, curves_size); bke::CurvesGeometry &dst_curves = bke::CurvesGeometry::wrap(dst_curves_id->geometry); - dst_curves.offsets().last() = points_size; + dst_curves.offsets_for_write().last() = points_size; CurveComponent &dst_component = r_realized_geometry.get_component_for_write(); dst_component.replace(dst_curves_id); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc index 38d81c54933..ba8c9a893c2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc @@ -171,7 +171,7 @@ static Curves *create_arc_curve_from_points(const int resolution, const int stepcount = resolution - 1; const int centerpoint = resolution; - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); const bool is_colinear = colinear_f3_f3_f3(a, b, c); @@ -261,7 +261,7 @@ static Curves *create_arc_curve_from_points(const int resolution, } if (connect_center) { - curves.cyclic().first() = true; + curves.cyclic_for_write().first() = true; positions[centerpoint] = center; } @@ -289,7 +289,7 @@ static Curves *create_arc_curve_from_radius(const int resolution, const int stepcount = resolution - 1; const int centerpoint = resolution; - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); const float sweep = (invert_arc) ? -(2.0f * M_PI - sweep_angle) : sweep_angle; @@ -302,7 +302,7 @@ static Curves *create_arc_curve_from_radius(const int resolution, } if (connect_center) { - curves.cyclic().first() = true; + curves.cyclic_for_write().first() = true; positions[centerpoint] = float3(0.0f, 0.0f, 0.0f); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc index 297674e11f4..875664c41fa 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc @@ -64,17 +64,17 @@ static Curves *create_bezier_segment_curve(const float3 start, { Curves *curves_id = bke::curves_new_nomain_single(2, CURVE_TYPE_BEZIER); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - curves.resolution().fill(resolution); + curves.resolution_for_write().fill(resolution); - MutableSpan positions = curves.positions(); - curves.handle_types_left().fill(BEZIER_HANDLE_ALIGN); - curves.handle_types_right().fill(BEZIER_HANDLE_ALIGN); + MutableSpan positions = curves.positions_for_write(); + curves.handle_types_left_for_write().fill(BEZIER_HANDLE_ALIGN); + curves.handle_types_right_for_write().fill(BEZIER_HANDLE_ALIGN); positions.first() = start; positions.last() = end; - MutableSpan handles_right = curves.handle_positions_right(); - MutableSpan handles_left = curves.handle_positions_left(); + MutableSpan handles_right = curves.handle_positions_right_for_write(); + MutableSpan handles_left = curves.handle_positions_left_for_write(); if (mode == GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT_POSITION) { handles_left.first() = 2.0f * start - start_handle_right; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index aa4b3a785f1..c33ba3e2a4c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -111,9 +111,9 @@ static Curves *create_point_circle_curve( Curves *curves_id = bke::curves_new_nomain_single(resolution, CURVE_TYPE_POLY); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - curves.cyclic().first() = true; + curves.cyclic_for_write().first() = true; - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); float3 center; /* Midpoints of `P1->P2` and `P2->P3`. */ @@ -164,9 +164,9 @@ static Curves *create_radius_circle_curve(const int resolution, const float radi { Curves *curves_id = bke::curves_new_nomain_single(resolution, CURVE_TYPE_POLY); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - curves.cyclic().first() = true; + curves.cyclic_for_write().first() = true; - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); const float theta_step = (2.0f * M_PI) / float(resolution); for (int i : IndexRange(resolution)) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc index 62dbcc91cc6..4cfa606d8eb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc @@ -73,8 +73,8 @@ static Curves *create_point_line_curve(const float3 start, const float3 end) Curves *curves_id = bke::curves_new_nomain_single(2, CURVE_TYPE_POLY); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - curves.positions().first() = start; - curves.positions().last() = end; + curves.positions_for_write().first() = start; + curves.positions_for_write().last() = end; return curves_id; } @@ -86,8 +86,8 @@ static Curves *create_direction_line_curve(const float3 start, Curves *curves_id = bke::curves_new_nomain_single(2, CURVE_TYPE_POLY); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - curves.positions().first() = start; - curves.positions().last() = math::normalize(direction) * length + start; + curves.positions_for_write().first() = start; + curves.positions_for_write().last() = math::normalize(direction) * length + start; return curves_id; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc index 37810ccaff5..9eae371d948 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc @@ -36,7 +36,7 @@ static Curves *create_quadratic_bezier_curve(const float3 p1, Curves *curves_id = bke::curves_new_nomain_single(resolution + 1, CURVE_TYPE_POLY); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); const float step = 1.0f / resolution; for (const int i : IndexRange(resolution + 1)) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc index ad3123a6a4a..fec4e31701f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc @@ -218,9 +218,9 @@ static void node_geo_exec(GeoNodeExecParams params) Curves *curves_id = bke::curves_new_nomain_single(4, CURVE_TYPE_POLY); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - curves.cyclic().first() = true; + curves.cyclic_for_write().first() = true; - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); switch (mode) { case GEO_NODE_CURVE_PRIMITIVE_QUAD_MODE_RECTANGLE: diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc index 22619577d04..4aaf57d57cb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc @@ -51,7 +51,7 @@ static Curves *create_spiral_curve(const float rotations, Curves *curves_id = bke::curves_new_nomain_single(totalpoints + 1, CURVE_TYPE_POLY); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); for (const int i : IndexRange(totalpoints + 1)) { const float theta = i * delta_theta; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc index e7e899881cf..91ba5f2845f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc @@ -40,9 +40,9 @@ static Curves *create_star_curve(const float inner_radius, { Curves *curves_id = bke::curves_new_nomain_single(points * 2, CURVE_TYPE_POLY); bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); - curves.cyclic().first() = true; + curves.cyclic_for_write().first() = true; - MutableSpan positions = curves.positions(); + MutableSpan positions = curves.positions_for_write(); const float theta_step = (2.0f * M_PI) / float(points); for (const int i : IndexRange(points)) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index 139b17138fa..fababfd027b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -301,7 +301,7 @@ static Curves *resample_to_uniform_count(const CurveComponent &src_component, CD_MASK_ALL, CD_DUPLICATE, src_curves.curves_num()); - MutableSpan dst_offsets = dst_curves.offsets(); + MutableSpan dst_offsets = dst_curves.offsets_for_write(); GeometryComponentFieldContext field_context{src_component, ATTR_DOMAIN_CURVE}; fn::FieldEvaluator evaluator{field_context, src_curves.curves_num()}; @@ -318,12 +318,12 @@ static Curves *resample_to_uniform_count(const CurveComponent &src_component, dst_curves.resize(dst_offsets.last(), dst_curves.curves_num()); /* All resampled curves are poly curves. */ - dst_curves.curve_types().fill_indices(selection, CURVE_TYPE_POLY); + dst_curves.curve_types_for_write().fill_indices(selection, CURVE_TYPE_POLY); VArray curves_cyclic = src_curves.cyclic(); VArray curve_types = src_curves.curve_types(); Span evaluated_positions = src_curves.evaluated_positions(); - MutableSpan dst_positions = dst_curves.positions(); + MutableSpan dst_positions = dst_curves.positions_for_write(); AttributesForInterpolation attributes; gather_point_attributes_to_interpolate(src_component, dst_component, attributes); @@ -464,8 +464,8 @@ static Curves *resample_to_evaluated(const CurveComponent &src_component, CD_DUPLICATE, src_curves.curves_num()); /* All resampled curves are poly curves. */ - dst_curves.curve_types().fill_indices(selection, CURVE_TYPE_POLY); - MutableSpan dst_offsets = dst_curves.offsets(); + dst_curves.curve_types_for_write().fill_indices(selection, CURVE_TYPE_POLY); + MutableSpan dst_offsets = dst_curves.offsets_for_write(); src_curves.ensure_evaluated_offsets(); threading::parallel_for(selection.index_range(), 4096, [&](IndexRange range) { @@ -480,7 +480,7 @@ static Curves *resample_to_evaluated(const CurveComponent &src_component, /* Create the correct number of uniform-length samples for every selected curve. */ Span evaluated_positions = src_curves.evaluated_positions(); - MutableSpan dst_positions = dst_curves.positions(); + MutableSpan dst_positions = dst_curves.positions_for_write(); AttributesForInterpolation attributes; gather_point_attributes_to_interpolate(src_component, dst_component, attributes); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc index 169f808c473..469d8d8d13b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc @@ -66,10 +66,10 @@ static void set_type_in_component(CurveComponent &component, const IndexMask selection = evaluator.get_evaluated_selection_as_mask(); if (mode & GEO_NODE_CURVE_HANDLE_LEFT) { - curves.handle_types_left().fill_indices(selection, new_handle_type); + curves.handle_types_left_for_write().fill_indices(selection, new_handle_type); } if (mode & GEO_NODE_CURVE_HANDLE_RIGHT) { - curves.handle_types_right().fill_indices(selection, new_handle_type); + curves.handle_types_right_for_write().fill_indices(selection, new_handle_type); } /* Eagerly calculate automatically derived handle positions if necessary. */ diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index 2aa768129cd..1e170dd5350 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -365,7 +365,7 @@ static void duplicate_curves(GeometrySet &geometry_set, Curves *new_curves_id = bke::curves_new_nomain(dst_points_size, dst_curves_size); bke::CurvesGeometry &new_curves = bke::CurvesGeometry::wrap(new_curves_id->geometry); - MutableSpan all_dst_offsets = new_curves.offsets(); + MutableSpan all_dst_offsets = new_curves.offsets_for_write(); threading::parallel_for(selection.index_range(), 512, [&](IndexRange range) { for (const int i_selection : range) { @@ -818,7 +818,7 @@ static void duplicate_points_curve(GeometrySet &geometry_set, Curves *new_curves_id = bke::curves_new_nomain(dst_size, dst_size); bke::CurvesGeometry &new_curves = bke::CurvesGeometry::wrap(new_curves_id->geometry); - MutableSpan new_curve_offsets = new_curves.offsets(); + MutableSpan new_curve_offsets = new_curves.offsets_for_write(); for (const int i : new_curves.curves_range()) { new_curve_offsets[i] = i; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc index 31b9f1765a5..73e49c7d037 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc @@ -95,14 +95,15 @@ static void set_position_in_component(CurveComponent &component, Span positions = curves.positions(); const bool use_left = mode == GEO_NODE_CURVE_HANDLE_LEFT; - MutableSpan handle_types = use_left ? curves.handle_types_left() : - curves.handle_types_right(); - MutableSpan handle_types_other = use_left ? curves.handle_types_right() : - curves.handle_types_left(); - MutableSpan handle_positions = use_left ? curves.handle_positions_left() : - curves.handle_positions_right(); - MutableSpan handle_positions_other = use_left ? curves.handle_positions_right() : - curves.handle_positions_left(); + MutableSpan handle_types = use_left ? curves.handle_types_left_for_write() : + curves.handle_types_right_for_write(); + MutableSpan handle_types_other = use_left ? curves.handle_types_right_for_write() : + curves.handle_types_left_for_write(); + MutableSpan handle_positions = use_left ? curves.handle_positions_left_for_write() : + curves.handle_positions_right_for_write(); + MutableSpan handle_positions_other = use_left ? + curves.handle_positions_right_for_write() : + curves.handle_positions_left_for_write(); threading::parallel_for(selection.index_range(), 2048, [&](IndexRange range) { for (const int i : selection.slice(range)) { -- cgit v1.2.3