Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-04-07 00:30:27 +0300
committerHans Goudey <h.goudey@me.com>2022-04-07 00:30:27 +0300
commit8551e890687de7185388eed9e77171b0df7943a3 (patch)
tree7833056784792f3a46ac8fb6bd9776f3ced33367
parent8b04308953adae983562026a2aa7bbd38e74174d (diff)
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
-rw-r--r--source/blender/blenkernel/BKE_curves.hh28
-rw-r--r--source/blender/blenkernel/intern/curve_eval.cc4
-rw-r--r--source/blender/blenkernel/intern/curves.cc6
-rw-r--r--source/blender/blenkernel/intern/curves_geometry.cc81
-rw-r--r--source/blender/blenkernel/intern/curves_geometry_test.cc78
-rw-r--r--source/blender/editors/curves/intern/curves_add.cc4
-rw-r--r--source/blender/editors/curves/intern/curves_ops.cc2
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_add.cc12
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_comb.cc6
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_delete.cc2
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc6
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_ops.cc4
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc4
-rw-r--r--source/blender/geometry/intern/mesh_to_curve_convert.cc10
-rw-r--r--source/blender/geometry/intern/realize_instances.cc6
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc8
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc12
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc8
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc8
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc12
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc17
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<int> offsets() const;
- MutableSpan<int> offsets();
+ MutableSpan<int> 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<int8_t> curve_types() const;
/** Mutable access to curve types. Call #tag_topology_changed after changing any type. */
- MutableSpan<int8_t> curve_types();
+ MutableSpan<int8_t> curve_types_for_write();
bool has_curve_with_type(const CurveType type) const;
/** Return the number of curves with each type. */
std::array<int, CURVE_TYPES_NUM> count_curve_types() const;
- MutableSpan<float3> positions();
Span<float3> positions() const;
+ MutableSpan<float3> positions_for_write();
/** Whether the curve loops around to connect to itself, on the curve domain. */
VArray<bool> cyclic() const;
/** Mutable access to curve cyclic values. Call #tag_topology_changed after changes. */
- MutableSpan<bool> cyclic();
+ MutableSpan<bool> cyclic_for_write();
/**
* How many evaluated points to create for each segment when evaluating Bezier,
@@ -172,15 +172,15 @@ class CurvesGeometry : public ::CurvesGeometry {
*/
VArray<int> resolution() const;
/** Mutable access to curve resolution. Call #tag_topology_changed after changes. */
- MutableSpan<int> resolution();
+ MutableSpan<int> resolution_for_write();
/**
* Handle types for Bezier control points. Call #tag_topology_changed after changes.
*/
VArray<int8_t> handle_types_left() const;
- MutableSpan<int8_t> handle_types_left();
+ MutableSpan<int8_t> handle_types_left_for_write();
VArray<int8_t> handle_types_right() const;
- MutableSpan<int8_t> handle_types_right();
+ MutableSpan<int8_t> 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<float3> handle_positions_left() const;
- MutableSpan<float3> handle_positions_left();
+ MutableSpan<float3> handle_positions_left_for_write();
Span<float3> handle_positions_right() const;
- MutableSpan<float3> handle_positions_right();
+ MutableSpan<float3> 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<int8_t> nurbs_orders() const;
- MutableSpan<int8_t> nurbs_orders();
+ MutableSpan<int8_t> 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<int8_t> nurbs_knots_modes() const;
- MutableSpan<int8_t> nurbs_knots_modes();
+ MutableSpan<int8_t> nurbs_knots_modes_for_write();
/**
* The weight for each control point for NURBS curves. Call #tag_positions_changed after changes.
*/
Span<float> nurbs_weights() const;
- MutableSpan<float> nurbs_weights();
+ MutableSpan<float> 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<int> surface_triangle_indices() const;
- MutableSpan<int> surface_triangle_indices();
+ MutableSpan<int> 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<float2> surface_triangle_coords() const;
- MutableSpan<float2> surface_triangle_coords();
+ MutableSpan<float2> 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<int8_t> curve_types = geometry.curve_types();
+ geometry.offsets_for_write().copy_from(curve_eval.control_point_offsets());
+ MutableSpan<int8_t> curve_types = geometry.curve_types_for_write();
OutputAttribute_Typed<float> nurbs_weight;
OutputAttribute_Typed<int> 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<float3> positions = geometry.positions();
+ MutableSpan<float3> 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<int8_t> CurvesGeometry::curve_types() const
*this, ATTR_DOMAIN_CURVE, ATTR_CURVE_TYPE, CURVE_TYPE_CATMULL_ROM);
}
-MutableSpan<int8_t> CurvesGeometry::curve_types()
+MutableSpan<int8_t> CurvesGeometry::curve_types_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_CURVE_TYPE);
}
@@ -277,22 +277,22 @@ std::array<int, CURVE_TYPES_NUM> CurvesGeometry::count_curve_types() const
});
}
-MutableSpan<float3> CurvesGeometry::positions()
+Span<float3> CurvesGeometry::positions() const
+{
+ return {(const float3 *)this->position, this->point_size};
+}
+MutableSpan<float3> 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<float3> CurvesGeometry::positions() const
-{
- return {(const float3 *)this->position, this->point_size};
-}
-MutableSpan<int> CurvesGeometry::offsets()
+Span<int> CurvesGeometry::offsets() const
{
return {this->curve_offsets, this->curve_size + 1};
}
-Span<int> CurvesGeometry::offsets() const
+MutableSpan<int> CurvesGeometry::offsets_for_write()
{
return {this->curve_offsets, this->curve_size + 1};
}
@@ -301,8 +301,7 @@ VArray<bool> CurvesGeometry::cyclic() const
{
return get_varray_attribute<bool>(*this, ATTR_DOMAIN_CURVE, ATTR_CYCLIC, false);
}
-
-MutableSpan<bool> CurvesGeometry::cyclic()
+MutableSpan<bool> CurvesGeometry::cyclic_for_write()
{
return get_mutable_attribute<bool>(*this, ATTR_DOMAIN_CURVE, ATTR_CYCLIC);
}
@@ -311,8 +310,7 @@ VArray<int> CurvesGeometry::resolution() const
{
return get_varray_attribute<int>(*this, ATTR_DOMAIN_CURVE, ATTR_RESOLUTION, 12);
}
-
-MutableSpan<int> CurvesGeometry::resolution()
+MutableSpan<int> CurvesGeometry::resolution_for_write()
{
return get_mutable_attribute<int>(*this, ATTR_DOMAIN_CURVE, ATTR_RESOLUTION);
}
@@ -321,7 +319,7 @@ VArray<int8_t> CurvesGeometry::handle_types_left() const
{
return get_varray_attribute<int8_t>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_LEFT, 0);
}
-MutableSpan<int8_t> CurvesGeometry::handle_types_left()
+MutableSpan<int8_t> CurvesGeometry::handle_types_left_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_LEFT);
}
@@ -330,7 +328,7 @@ VArray<int8_t> CurvesGeometry::handle_types_right() const
{
return get_varray_attribute<int8_t>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_RIGHT, 0);
}
-MutableSpan<int8_t> CurvesGeometry::handle_types_right()
+MutableSpan<int8_t> CurvesGeometry::handle_types_right_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_RIGHT);
}
@@ -339,7 +337,7 @@ Span<float3> CurvesGeometry::handle_positions_left() const
{
return get_span_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_LEFT);
}
-MutableSpan<float3> CurvesGeometry::handle_positions_left()
+MutableSpan<float3> CurvesGeometry::handle_positions_left_for_write()
{
return get_mutable_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_LEFT);
}
@@ -348,7 +346,7 @@ Span<float3> CurvesGeometry::handle_positions_right() const
{
return get_span_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_RIGHT);
}
-MutableSpan<float3> CurvesGeometry::handle_positions_right()
+MutableSpan<float3> CurvesGeometry::handle_positions_right_for_write()
{
return get_mutable_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_RIGHT);
}
@@ -357,7 +355,7 @@ VArray<int8_t> CurvesGeometry::nurbs_orders() const
{
return get_varray_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_ORDER, 4);
}
-MutableSpan<int8_t> CurvesGeometry::nurbs_orders()
+MutableSpan<int8_t> CurvesGeometry::nurbs_orders_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_ORDER);
}
@@ -366,7 +364,7 @@ Span<float> CurvesGeometry::nurbs_weights() const
{
return get_span_attribute<float>(*this, ATTR_DOMAIN_POINT, ATTR_NURBS_WEIGHT);
}
-MutableSpan<float> CurvesGeometry::nurbs_weights()
+MutableSpan<float> CurvesGeometry::nurbs_weights_for_write()
{
return get_mutable_attribute<float>(*this, ATTR_DOMAIN_POINT, ATTR_NURBS_WEIGHT);
}
@@ -375,7 +373,7 @@ VArray<int8_t> CurvesGeometry::nurbs_knots_modes() const
{
return get_varray_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_KNOTS_MODE, 0);
}
-MutableSpan<int8_t> CurvesGeometry::nurbs_knots_modes()
+MutableSpan<int8_t> CurvesGeometry::nurbs_knots_modes_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_KNOTS_MODE);
}
@@ -385,7 +383,7 @@ VArray<int> CurvesGeometry::surface_triangle_indices() const
return get_varray_attribute<int>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_INDEX, -1);
}
-MutableSpan<int> CurvesGeometry::surface_triangle_indices()
+MutableSpan<int> CurvesGeometry::surface_triangle_indices_for_write()
{
return get_mutable_attribute<int>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_INDEX);
}
@@ -395,7 +393,7 @@ Span<float2> CurvesGeometry::surface_triangle_coords() const
return get_span_attribute<float2>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_COORDINATE);
}
-MutableSpan<float2> CurvesGeometry::surface_triangle_coords()
+MutableSpan<float2> CurvesGeometry::surface_triangle_coords_for_write()
{
return get_mutable_attribute<float2>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_COORDINATE);
}
@@ -768,20 +766,19 @@ static void transform_positions(MutableSpan<float3> positions, const float4x4 &m
void CurvesGeometry::calculate_bezier_auto_handles()
{
- const VArray<int8_t> types = std::as_const(*this).curve_types();
+ const VArray<int8_t> 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<bool> cyclic = std::as_const(*this).cyclic();
- const Span<int8_t> types_left = this->handle_types_left();
- const Span<int8_t> types_right = this->handle_types_right();
+ const VArray<bool> cyclic = this->cyclic();
+ const VArray_Span<int8_t> types_left{this->handle_types_left()};
+ const VArray_Span<int8_t> types_right{this->handle_types_right()};
const Span<float3> positions = this->positions();
- MutableSpan<float3> positions_left = this->handle_positions_left();
- MutableSpan<float3> positions_right = this->handle_positions_right();
+ MutableSpan<float3> positions_left = this->handle_positions_left_for_write();
+ MutableSpan<float3> 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<int> new_offsets = new_curves.offsets();
+ MutableSpan<int> 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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<float3> handles_left = curves.handle_positions_left();
- MutableSpan<float3> handles_right = curves.handle_positions_right();
- MutableSpan<float3> positions = curves.positions();
+ MutableSpan<float3> handles_left = curves.handle_positions_left_for_write();
+ MutableSpan<float3> handles_right = curves.handle_positions_right_for_write();
+ MutableSpan<float3> 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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<float3> 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<float3> 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<float3> handles_left = curves.handle_positions_left();
- MutableSpan<float3> handles_right = curves.handle_positions_right();
- MutableSpan<float3> positions = curves.positions();
+ MutableSpan<float3> handles_left = curves.handle_positions_left_for_write();
+ MutableSpan<float3> handles_right = curves.handle_positions_right_for_write();
+ MutableSpan<float3> 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<int> offsets = curves.offsets();
- MutableSpan<float3> positions = curves.positions();
+ MutableSpan<int> offsets = curves.offsets_for_write();
+ MutableSpan<float3> 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<Mesh *>(surface_ob.data);
const Span<float3> positions_cu = curves.positions();
- const VArray<int> looptri_indices = std::as_const(curves).surface_triangle_indices();
+ const VArray<int> looptri_indices = curves.surface_triangle_indices();
const Span<MLoopTri> 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<int> offsets = curves_->offsets();
+ MutableSpan<int> 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<int> surface_triangle_indices = curves_->surface_triangle_indices();
- MutableSpan<float2> surface_triangle_coords = curves_->surface_triangle_coords();
+ MutableSpan<int> surface_triangle_indices = curves_->surface_triangle_indices_for_write();
+ MutableSpan<float2> 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<float> lengths_cu,
const MutableSpan<float3> normals_su)
{
- MutableSpan<float3> positions_cu = curves_->positions();
+ MutableSpan<float3> 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<float3> new_normals_su,
const Span<float> new_lengths_cu)
{
- MutableSpan<float3> positions_cu = curves_->positions();
- const Span<int> surface_triangle_indices = curves_->surface_triangle_indices();
+ MutableSpan<float3> positions_cu = curves_->positions_for_write();
+ const VArray_Span<int> surface_triangle_indices{curves_->surface_triangle_indices()};
const Span<float2> 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<Vector<int>> &r_changed_curves)
{
- MutableSpan<float3> positions_cu = curves_->positions();
+ MutableSpan<float3> 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<Vector<int>> &r_changed_curves)
{
- MutableSpan<float3> positions_cu = curves_->positions();
+ MutableSpan<float3> 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<Vector<int>> &changed_curves)
{
const Span<float> expected_lengths_cu = self_->segment_lengths_cu_;
- MutableSpan<float3> positions_cu = curves_->positions();
+ MutableSpan<float3> positions_cu = curves_->positions_for_write();
threading::parallel_for_each(changed_curves, [&](const Vector<int> &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<Curves *>(object.data);
CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry);
- MutableSpan<float3> positions = curves.positions();
+ Span<float3> 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<int> curve_indices,
const Span<float> move_distances_cu) override
{
- MutableSpan<float3> positions_cu = curves.positions();
+ MutableSpan<float3> 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<int> curve_indices,
const Span<float> move_distances_cu) override
{
- MutableSpan<float3> positions_cu = curves.positions();
+ MutableSpan<float3> 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<int> curve_indices,
const Span<float> move_distances_cu) override
{
- MutableSpan<float3> positions_cu = curves.positions();
+ MutableSpan<float3> 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<int> offsets = curves.offsets();
- MutableSpan<float3> positions = curves.positions();
+ MutableSpan<int> offsets = curves.offsets_for_write();
+ MutableSpan<float3> 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<float3> positions_cu = curves_->positions();
+ MutableSpan<float3> 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<float3> positions_cu = curves_->positions();
+ MutableSpan<float3> 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<bke::AttributeIDRef> 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<int> src_offsets = curves.offsets();
- const MutableSpan<int> dst_offsets = dst_curves.offsets().slice(dst_curve_range);
+ const MutableSpan<int> 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<CurveComponent>();
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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<float3> positions = curves.positions();
- curves.handle_types_left().fill(BEZIER_HANDLE_ALIGN);
- curves.handle_types_right().fill(BEZIER_HANDLE_ALIGN);
+ MutableSpan<float3> 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<float3> handles_right = curves.handle_positions_right();
- MutableSpan<float3> handles_left = curves.handle_positions_left();
+ MutableSpan<float3> handles_right = curves.handle_positions_right_for_write();
+ MutableSpan<float3> 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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<float3> positions = curves.positions();
+ MutableSpan<float3> 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<int> dst_offsets = dst_curves.offsets();
+ MutableSpan<int> 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<bool> curves_cyclic = src_curves.cyclic();
VArray<int8_t> curve_types = src_curves.curve_types();
Span<float3> evaluated_positions = src_curves.evaluated_positions();
- MutableSpan<float3> dst_positions = dst_curves.positions();
+ MutableSpan<float3> 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<int> dst_offsets = dst_curves.offsets();
+ dst_curves.curve_types_for_write().fill_indices(selection, CURVE_TYPE_POLY);
+ MutableSpan<int> 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<float3> evaluated_positions = src_curves.evaluated_positions();
- MutableSpan<float3> dst_positions = dst_curves.positions();
+ MutableSpan<float3> 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<int> all_dst_offsets = new_curves.offsets();
+ MutableSpan<int> 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<int> new_curve_offsets = new_curves.offsets();
+ MutableSpan<int> 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<float3> positions = curves.positions();
const bool use_left = mode == GEO_NODE_CURVE_HANDLE_LEFT;
- MutableSpan<int8_t> handle_types = use_left ? curves.handle_types_left() :
- curves.handle_types_right();
- MutableSpan<int8_t> handle_types_other = use_left ? curves.handle_types_right() :
- curves.handle_types_left();
- MutableSpan<float3> handle_positions = use_left ? curves.handle_positions_left() :
- curves.handle_positions_right();
- MutableSpan<float3> handle_positions_other = use_left ? curves.handle_positions_right() :
- curves.handle_positions_left();
+ MutableSpan<int8_t> handle_types = use_left ? curves.handle_types_left_for_write() :
+ curves.handle_types_right_for_write();
+ MutableSpan<int8_t> handle_types_other = use_left ? curves.handle_types_right_for_write() :
+ curves.handle_types_left_for_write();
+ MutableSpan<float3> handle_positions = use_left ? curves.handle_positions_left_for_write() :
+ curves.handle_positions_right_for_write();
+ MutableSpan<float3> 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)) {