[Bf-blender-cvs] [6b33bd1067d] master: GPencil: For Stroke select don't display points

Antonio Vazquez noreply at git.blender.org
Thu Aug 29 10:44:30 CEST 2019


Commit: 6b33bd1067dc34711e0e076070cfaeaf0e3259a5
Author: Antonio Vazquez
Date:   Thu Aug 29 10:35:22 2019 +0200
Branches: master
https://developer.blender.org/rB6b33bd1067dc34711e0e076070cfaeaf0e3259a5

GPencil: For Stroke select don't display points

Now, when it's selected the stroke select mode, the points are not displayed and the stroke is fully selected automatically extending the selection.

Differential Revision: https://developer.blender.org/D5622

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

M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index f4b390fb4a4..bef72b9a054 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -944,6 +944,11 @@ static void gpencil_add_editpoints_vertexdata(GpencilBatchCache *cache,
                                                               GP_SCULPT_MASK_SELECTMODE_STROKE |
                                                               GP_SCULPT_MASK_SELECTMODE_SEGMENT)));
 
+  const bool show_sculpt_points = (GPENCIL_SCULPT_MODE(gpd) &&
+                                   (ts->gpencil_selectmode_sculpt &
+                                    (GP_SCULPT_MASK_SELECTMODE_POINT |
+                                     GP_SCULPT_MASK_SELECTMODE_SEGMENT)));
+
   MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
 
   /* alpha factor for edit points/line to make them more subtle */
@@ -955,8 +960,19 @@ static void gpencil_add_editpoints_vertexdata(GpencilBatchCache *cache,
       return;
     }
     const bool is_weight_paint = (gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE);
+
+    /* If Sculpt mode and the mask is disabled, the select must be hidden. */
     const bool hide_select = GPENCIL_SCULPT_MODE(gpd) && !use_sculpt_mask;
 
+    /* Show Edit points if:
+     *  Edit mode: Not in Stroke selection mode
+     *  Sculpt mode: Not in Stroke mask mode and any other mask mode enabled
+     *  Weight mode: Always
+     */
+    const bool show_points = (show_sculpt_points) || (is_weight_paint) ||
+                             (GPENCIL_EDIT_MODE(gpd) &&
+                              ((ts->gpencil_selectmode_edit & GP_SELECTMODE_STROKE) == 0));
+
     if (cache->is_dirty) {
       if ((obact == ob) && ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) &&
           (v3d->gp_flag & V3D_GP_SHOW_EDIT_LINES)) {
@@ -976,8 +992,8 @@ static void gpencil_add_editpoints_vertexdata(GpencilBatchCache *cache,
                                                    &cache->grp_used);
       }
 
-      /* In sculpt mode, the point are only visible if masking is enabled. */
-      if (hide_select) {
+      /* If the points are hidden return. */
+      if ((!show_points) || (hide_select)) {
         return;
       }
 
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index b4f545e3c5e..f37ee5ff817 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -749,6 +749,35 @@ static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value)
   }
 }
 
+static void rna_Gpencil_selectmode_update(bContext *C, PointerRNA *ptr)
+{
+  ToolSettings *ts = (ToolSettings *)ptr->data;
+  /* If the mode is not Stroke, don't extend selection. */
+  if ((ts->gpencil_selectmode_edit & GP_SELECTMODE_STROKE) == 0) {
+    return;
+  }
+
+  /* Extend selection to all points in all selected strokes. */
+  ViewLayer *view_layer = CTX_data_view_layer(C);
+  Object *ob = OBACT(view_layer);
+  if ((ob) && (ob->type == OB_GPENCIL)) {
+    bGPdata *gpd = (bGPdata *)ob->data;
+    CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
+      if ((gps->flag & GP_STROKE_SELECT) && (gps->totpoints > 1)) {
+        bGPDspoint *pt;
+        for (int i = 0; i < gps->totpoints; i++) {
+          pt = &gps->points[i];
+          pt->flag |= GP_SPOINT_SELECT;
+        }
+      }
+    }
+    CTX_DATA_END;
+
+    gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
+    DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+  }
+}
+
 static void rna_Gpencil_mask_point_update(Main *UNUSED(bmain),
                                           Scene *UNUSED(scene),
                                           PointerRNA *ptr)
@@ -3119,6 +3148,8 @@ static void rna_def_tool_settings(BlenderRNA *brna)
   RNA_def_property_enum_items(prop, gpencil_selectmode_items);
   RNA_def_property_ui_text(prop, "Select Mode", "");
   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+  RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+  RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Gpencil_selectmode_update");
 
   /* Grease Pencil - Select mode Sculpt */
   prop = RNA_def_property(srna, "use_gpencil_select_mask_point", PROP_BOOLEAN, PROP_NONE);



More information about the Bf-blender-cvs mailing list