diff options
author | Hans Goudey <h.goudey@me.com> | 2022-04-07 00:30:27 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-04-07 00:30:27 +0300 |
commit | 8551e890687de7185388eed9e77171b0df7943a3 (patch) | |
tree | 7833056784792f3a46ac8fb6bd9776f3ced33367 /source/blender/geometry | |
parent | 8b04308953adae983562026a2aa7bbd38e74174d (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/geometry')
-rw-r--r-- | source/blender/geometry/intern/mesh_to_curve_convert.cc | 10 | ||||
-rw-r--r-- | source/blender/geometry/intern/realize_instances.cc | 6 |
2 files changed, 8 insertions, 8 deletions
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); |