Commit: 0aa0d9b346cd4c04e8b9100b4100af1aabc09eec
Author: Antonio Vazquez
Date: Fri Jan 24 10:15:36 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB0aa0d9b346cd4c04e8b9100b4100af1aabc09eec
GPencil: Cleanup - Replace frame loops by Macro LISTBASE_FOREACH
===================================================================
M source/blender/editors/gpencil/editaction_gpencil.c
M source/blender/editors/gpencil/gpencil_data.c
M source/blender/editors/gpencil/gpencil_edit.c
M source/blender/editors/gpencil/gpencil_utils.c
M source/blender/editors/gpencil/gpencil_vertex_ops.c
M source/blender/editors/gpencil/gpencil_vertex_paint.c
M source/blender/editors/gpencil/gpencil_weight_paint.c
===================================================================
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c
b/source/blender/editors/gpencil/editaction_gpencil.c
index 773d77b0592..83165fd4930 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -58,15 +58,13 @@
/* Loops over the gp-frames for a gp-layer, and applies the given callback */
bool ED_gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short
(*gpf_cb)(bGPDframe *, Scene *))
{
- bGPDframe *gpf;
-
/* error checker */
if (gpl == NULL) {
return false;
}
/* do loop */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
/* execute callback */
if (gpf_cb(gpf, scene)) {
return true;
@@ -83,7 +81,6 @@ bool ED_gplayer_frames_looper(bGPDlayer *gpl, Scene *scene,
short (*gpf_cb)(bGPD
/* make a listing all the gp-frames in a layer as cfraelems */
void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, bool onlysel)
{
- bGPDframe *gpf;
CfraElem *ce;
/* error checking */
@@ -92,7 +89,7 @@ void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase
*elems, bool onlysel)
}
/* loop through gp-frames, adding */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
if ((onlysel == 0) || (gpf->flag & GP_FRAME_SELECT)) {
ce = MEM_callocN(sizeof(CfraElem), "CfraElem");
@@ -110,15 +107,13 @@ void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase
*elems, bool onlysel)
/* check if one of the frames in this layer is selected */
bool ED_gplayer_frame_select_check(bGPDlayer *gpl)
{
- bGPDframe *gpf;
-
/* error checking */
if (gpl == NULL) {
return false;
}
/* stop at the first one found */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
if (gpf->flag & GP_FRAME_SELECT) {
return true;
}
@@ -151,15 +146,13 @@ static void gpframe_select(bGPDframe *gpf, short
select_mode)
/* set all/none/invert select (like above, but with SELECT_* modes) */
void ED_gpencil_select_frames(bGPDlayer *gpl, short select_mode)
{
- bGPDframe *gpf;
-
/* error checking */
if (gpl == NULL) {
return;
}
/* handle according to mode */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
gpframe_select(gpf, select_mode);
}
}
@@ -195,14 +188,12 @@ void ED_gpencil_select_frame(bGPDlayer *gpl, int selx,
short select_mode)
/* select the frames in this layer that occur within the bounds specified */
void ED_gplayer_frames_select_box(bGPDlayer *gpl, float min, float max, short
select_mode)
{
- bGPDframe *gpf;
-
if (gpl == NULL) {
return;
}
/* only select those frames which are in bounds */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
if (IN_RANGE(gpf->framenum, min, max)) {
gpframe_select(gpf, select_mode);
}
@@ -215,14 +206,12 @@ void ED_gplayer_frames_select_region(KeyframeEditData
*ked,
short tool,
short select_mode)
{
- bGPDframe *gpf;
-
if (gpl == NULL) {
return;
}
/* only select frames which are within the region */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
/* construct a dummy point coordinate to do this testing with */
float pt[2] = {0};
@@ -304,13 +293,11 @@ void ED_gplayer_frames_duplicate(bGPDlayer *gpl)
*/
void ED_gplayer_frames_keytype_set(bGPDlayer *gpl, short type)
{
- bGPDframe *gpf;
-
if (gpl == NULL) {
return;
}
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
if (gpf->flag & GP_FRAME_SELECT) {
gpf->key_type = type;
}
@@ -370,10 +357,9 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac)
for (ale = anim_data.first; ale; ale = ale->next) {
ListBase copied_frames = {NULL, NULL};
bGPDlayer *gpl = (bGPDlayer *)ale->data;
- bGPDframe *gpf;
/* loop over frames, and copy only selected frames */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
/* if frame is selected, make duplicate it and its strokes */
if (gpf->flag & GP_FRAME_SELECT) {
/* make a copy of this frame */
diff --git a/source/blender/editors/gpencil/gpencil_data.c
b/source/blender/editors/gpencil/gpencil_data.c
index 208e0bd5896..b2e025166a9 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -2532,7 +2532,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator
*op)
BLI_addtail(&ob_active->defbase, vgroup);
/* update vertex groups in strokes in original data */
for (bGPDlayer *gpl_src = gpd->layers.first; gpl_src; gpl_src =
gpl_src->next) {
- for (bGPDframe *gpf = gpl_src->frames.first; gpf; gpf = gpf->next)
{
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_src->frames) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next)
{
MDeformVert *dvert;
int i;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c
b/source/blender/editors/gpencil/gpencil_edit.c
index dfe67d4db50..c24f5647b31 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2898,7 +2898,7 @@ static int gp_stroke_apply_thickness_exec(bContext *C,
wmOperator *UNUSED(op))
}
/* loop all strokes */
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* Apply thickness */
if ((gps->thickness == 0) && (gpl->line_change == 0)) {
diff --git a/source/blender/editors/gpencil/gpencil_utils.c
b/source/blender/editors/gpencil/gpencil_utils.c
index d17613fadaf..60a676aff2d 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -2021,7 +2021,7 @@ void ED_gpencil_update_color_uv(Main *bmain, Material
*mat)
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* only editable and visible layers are considered */
if (BKE_gpencil_layer_is_editable(gpl)) {
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if it is editable */
if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
@@ -2430,10 +2430,9 @@ void ED_gpencil_select_toggle_all(bContext *C, int
action)
* nothing should be able to touch it
*/
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- bGPDframe *gpf;
/* deselect all strokes on all frames */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
bGPDstroke *gps;
for (gps = gpf->strokes.first; gps; gps = gps->next) {
diff --git a/source/blender/editors/gpencil/gpencil_vertex_ops.c
b/source/blender/editors/gpencil/gpencil_vertex_ops.c
index 6c1a04abcbd..0d71ac8d79a 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_ops.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_ops.c
@@ -509,7 +509,7 @@ static bool gp_extract_palette_from_vertex(bContext *C,
const bool selected, con
/* Extract all colors. */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@@ -695,7 +695,7 @@ static int gp_material_to_vertex_exec(bContext *C,
wmOperator *op)
/* Update stroke material index. */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c
b/source/blender/editors/gpencil/gpencil_vertex_paint.c
index eff2c8b490e..268149dff30 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_paint.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c
@@ -1092,7 +1092,7 @@ static bool gp_vertexpaint_brush_apply_to_layers(bContext
*C, tGP_BrushVertexpai
BKE_gpencil_get_range_selected(gpl, &f_init, &f_end);
}
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
/* Always do active frame; Otherwise, only include selected frames */
if ((gpf == gpl->actframe) || (gpf->flag & GP_FRAME_SELECT)) {
/* compute multiframe falloff factor */
diff --git a/source/blender/editors/gpencil/gpencil_weight_paint.c
b/source/blender/editors/gpencil/gpencil_weight_paint.c
index 62972207912..1051bce82cd 100644
--- a/source/blender/editors/gpencil/gpencil_weight_paint.c
+++ b/source/blender/editors/gpencil/gpencil_weight_paint.c
@@ -634,7 +634,7 @@ static bool gp_weightpaint_brush_apply_to_layers(bContext
*C, tGP_BrushWeightpai
BKE_gpencil_get_range_selected(gpl, &f_init, &f_end);
}
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
/* Always do active frame; Otherwise, only include selected frames */
if ((gpf == gpl->actframe) || (gpf->flag & GP_FRAME_SELECT)) {
/* compute multiframe falloff factor */
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs