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 /source/blender/blenkernel
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
Diffstat (limited to 'source/blender/blenkernel')
-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
5 files changed, 96 insertions, 101 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};