[Bf-blender-cvs] [5c48b97e8c8] blender2.8: GP: Deselect points if click outside selection area

Antonioya noreply at git.blender.org
Wed Nov 28 19:44:56 CET 2018


Commit: 5c48b97e8c86c34e605e052dc1c30dd1a1ad4621
Author: Antonioya
Date:   Wed Nov 28 19:44:41 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB5c48b97e8c86c34e605e052dc1c30dd1a1ad4621

GP: Deselect points if click outside selection area

To make consistent with Left click select, now if click outside any point, all points are deselected.

Reduced the circle of selection to get more precission. The radius used before was too wide.

Note: There is a minimum distance to consider outside selection area.

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index b3606d26bee..bf90a13b584 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -1306,7 +1306,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
 	ToolSettings *ts = CTX_data_tool_settings(C);
 
 	/* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */
-	const float radius = 0.75f * U.widget_unit;
+	const float radius = 0.50f * U.widget_unit;
 	const int radius_squared = (int)(radius * radius);
 
 	bool extend = RNA_boolean_get(op->ptr, "extend");
@@ -1374,6 +1374,30 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
 
 	/* Abort if nothing hit... */
 	if (ELEM(NULL, hit_stroke, hit_point)) {
+
+		/* since left mouse select change, deselect all if click outside any hit */
+		CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
+		{
+			/* deselect stroke and its points if selected */
+			if (gps->flag & GP_STROKE_SELECT) {
+				bGPDspoint *pt;
+				int i;
+
+				/* deselect points */
+				for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+					pt->flag &= ~GP_SPOINT_SELECT;
+				}
+
+				/* deselect stroke itself too */
+				gps->flag &= ~GP_STROKE_SELECT;
+			}
+		}
+		CTX_DATA_END;
+		/* copy on write tag is needed, or else no refresh happens */
+		DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+		DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+		WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+
 		return OPERATOR_CANCELLED;
 	}



More information about the Bf-blender-cvs mailing list