[Bf-blender-cvs] [df5cb4d66ff] blender2.8: GP: Add multiframe support to select by color

Antonioya noreply at git.blender.org
Tue Sep 25 18:17:55 CEST 2018


Commit: df5cb4d66ffa5fbd4af553c433f7742406665686
Author: Antonioya
Date:   Tue Sep 25 18:17:34 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBdf5cb4d66ffa5fbd4af553c433f7742406665686

GP: Add multiframe support to select by color

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

M	source/blender/editors/gpencil/gpencil_data.c

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

diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 6202720883c..3f159c87b3c 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -2581,37 +2581,52 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *UNUSED(op))
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
 	Object *ob = CTX_data_active_object(C);
 	MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, ob->actcol);
+	bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
 
 	/* sanity checks */
 	if (ELEM(NULL, gpd, gp_style))
 		return OPERATOR_CANCELLED;
 
 	/* read all strokes and select*/
-	for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
-		/* only editable and visible layers are considered */
-		if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
-			/* verify something to do */
-			for (bGPDstroke *gps = gpl->actframe->strokes.first; gps; gps = gps->next) {
-				/* skip strokes that are invalid for current view */
-				if (ED_gpencil_stroke_can_use(C, gps) == false)
-					continue;
-				/* check if the color is editable */
-				if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
-					continue;
+	CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
+	{
+		bGPDframe *init_gpf = gpl->actframe;
+		if (is_multiedit) {
+			init_gpf = gpl->frames.first;
+		}
+		for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
+			if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
+
+				/* verify something to do */
+				for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+					/* skip strokes that are invalid for current view */
+					if (ED_gpencil_stroke_can_use(C, gps) == false)
+						continue;
+					/* check if the color is editable */
+					if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+						continue;
 
-				/* select */
-				if (ob->actcol == gps->mat_nr + 1) {
-					bGPDspoint *pt;
-					int i;
+					/* select */
+					if (ob->actcol == gps->mat_nr + 1) {
+						bGPDspoint *pt;
+						int i;
 
-					gps->flag |= GP_STROKE_SELECT;
-					for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
-						pt->flag |= GP_SPOINT_SELECT;
+						gps->flag |= GP_STROKE_SELECT;
+						for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+							pt->flag |= GP_SPOINT_SELECT;
+						}
 					}
 				}
 			}
+			/* if not multiedit, exit loop*/
+			if (!is_multiedit) {
+				break;
+			}
+
 		}
 	}
+	CTX_DATA_END;
+
 	/* copy on write tag is needed, or else no refresh happens */
 	DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);



More information about the Bf-blender-cvs mailing list