From 019681b9841d7e34bac56211d645cf0497f8e9cf Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 20 May 2022 10:56:19 +0200 Subject: Cleanup: Simplify loop syntax for curve points --- source/blender/editors/sculpt_paint/curves_sculpt_comb.cc | 8 ++++---- source/blender/editors/sculpt_paint/curves_sculpt_delete.cc | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc b/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc index 72257659c52..cecb13fbf7f 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc @@ -381,11 +381,11 @@ struct CombOperationExecutor { threading::parallel_for(changed_curves.index_range(), 256, [&](const IndexRange range) { for (const int curve_i : changed_curves.as_span().slice(range)) { const IndexRange points = curves_->points_for_curve(curve_i); - for (const int segment_i : IndexRange(points.size() - 1)) { - const float3 &p1_cu = positions_cu[points[segment_i]]; - float3 &p2_cu = positions_cu[points[segment_i] + 1]; + for (const int segment_i : points.drop_back(1)) { + const float3 &p1_cu = positions_cu[segment_i]; + float3 &p2_cu = positions_cu[segment_i + 1]; const float3 direction = math::normalize(p2_cu - p1_cu); - const float expected_length_cu = expected_lengths_cu[points[segment_i]]; + const float expected_length_cu = expected_lengths_cu[segment_i]; p2_cu = p1_cu + direction * expected_length_cu; } } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc b/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc index f07c0a65933..9446f38891e 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc @@ -162,9 +162,9 @@ struct DeleteOperationExecutor { threading::parallel_for(curves_->curves_range(), 512, [&](IndexRange curve_range) { for (const int curve_i : curve_range) { const IndexRange points = curves_->points_for_curve(curve_i); - for (const int segment_i : IndexRange(points.size() - 1)) { - const float3 pos1_cu = brush_transform_inv * positions_cu[points[segment_i]]; - const float3 pos2_cu = brush_transform_inv * positions_cu[points[segment_i + 1]]; + for (const int segment_i : points.drop_back(1)) { + const float3 pos1_cu = brush_transform_inv * positions_cu[segment_i]; + const float3 pos2_cu = brush_transform_inv * positions_cu[segment_i + 1]; float2 pos1_re, pos2_re; ED_view3d_project_float_v2_m4(region_, pos1_cu, pos1_re, projection.values); @@ -220,9 +220,9 @@ struct DeleteOperationExecutor { threading::parallel_for(curves_->curves_range(), 512, [&](IndexRange curve_range) { for (const int curve_i : curve_range) { const IndexRange points = curves_->points_for_curve(curve_i); - for (const int segment_i : IndexRange(points.size() - 1)) { - const float3 pos1_cu = positions_cu[points[segment_i]]; - const float3 pos2_cu = positions_cu[points[segment_i] + 1]; + for (const int segment_i : points.drop_back(1)) { + const float3 &pos1_cu = positions_cu[segment_i]; + const float3 &pos2_cu = positions_cu[segment_i + 1]; float3 closest_segment_cu, closest_brush_cu; isect_seg_seg_v3(pos1_cu, -- cgit v1.2.3