[Bf-blender-cvs] [934316b925d] gpencil-new-data-proposal: Cleanup: Use LISTBASE_FOREACH_INDEX
Hans Goudey
noreply at git.blender.org
Mon Dec 12 20:35:47 CET 2022
Commit: 934316b925dd580a58aad5906a63eff001a7ac69
Author: Hans Goudey
Date: Mon Dec 12 12:20:42 2022 -0600
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB934316b925dd580a58aad5906a63eff001a7ac69
Cleanup: Use LISTBASE_FOREACH_INDEX
Avoid the need to manually incremend the index
===================================================================
M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index c81e200c25c..964b0bd10e8 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -22,24 +22,20 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, old_gpf->framenum)};
GPFrame &new_gpf{new_gpd.frames_for_write(new_gpf_index)};
- int stroke_index{0};
- LISTBASE_FOREACH (const bGPDstroke *, old_gps, &old_gpf->strokes) {
+ int stroke_index;
+ LISTBASE_FOREACH_INDEX (const bGPDstroke *, old_gps, &old_gpf->strokes, stroke_index) {
new_gpf.add_new_stroke(old_gps->totpoints);
- ++stroke_index;
}
CurvesGeometry &new_gps{new_gpf.strokes_as_curves()};
MutableSpan<float3> new_gps_positions{new_gps.positions_for_write()};
- stroke_index = 0;
- LISTBASE_FOREACH (const bGPDstroke *, old_gps, &old_gpf->strokes) {
+ LISTBASE_FOREACH_INDEX (const bGPDstroke *, old_gps, &old_gpf->strokes, stroke_index) {
IndexRange point_index_in_curve{new_gps.points_for_curve(stroke_index)};
for (int point_index = 0; point_index < old_gps->totpoints; point_index++) {
bGPDspoint *old_pt{old_gps->points + point_index};
new_gps_positions[point_index_in_curve[point_index]] = {old_pt->x, old_pt->y, old_pt->z};
}
-
- ++stroke_index;
}
}
@@ -113,4 +109,4 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData &new_gpd)
return old_gpd;
}
-} // namespace blender::bke
\ No newline at end of file
+} // namespace blender::bke
More information about the Bf-blender-cvs
mailing list