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/editors/sculpt_paint | |
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/editors/sculpt_paint')
6 files changed, 17 insertions, 17 deletions
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); |