[Bf-blender-cvs] [019681b9841] master: Cleanup: Simplify loop syntax for curve points

Hans Goudey noreply at git.blender.org
Fri May 20 10:56:21 CEST 2022


Commit: 019681b9841d7e34bac56211d645cf0497f8e9cf
Author: Hans Goudey
Date:   Fri May 20 10:56:19 2022 +0200
Branches: master
https://developer.blender.org/rB019681b9841d7e34bac56211d645cf0497f8e9cf

Cleanup: Simplify loop syntax for curve points

===================================================================

M	source/blender/editors/sculpt_paint/curves_sculpt_comb.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_delete.cc

===================================================================

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,



More information about the Bf-blender-cvs mailing list