[Bf-blender-cvs] [c8443d83405] master: GPencil: Fix unreported select not working in multiframe mode

Antonio Vazquez noreply at git.blender.org
Sat Sep 21 10:40:07 CEST 2019


Commit: c8443d83405e7658f72afa8288134b7de0d95c3d
Author: Antonio Vazquez
Date:   Fri Sep 20 12:17:21 2019 +0200
Branches: master
https://developer.blender.org/rBc8443d83405e7658f72afa8288134b7de0d95c3d

GPencil: Fix unreported select not working in multiframe mode

The selection was not working because the evaluated frame was only working for active frame, so when the evaluation was changed to use eval data instead of original data, the data was not available and the loop did not use it.

Related to T70116

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index d0c6905b07e..a8f8ec0e8c5 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -670,7 +670,9 @@ struct GP_EditableStrokes_Iter {
             ED_gpencil_parent_location(depsgraph_, obact_, gpd_, gpl, gpstroke_iter.diff_mat); \
             invert_m4_m4(gpstroke_iter.inverse_diff_mat, gpstroke_iter.diff_mat); \
             /* get evaluated frame with modifiers applied */ \
-            bGPDframe *gpf_eval_ = &obeval_->runtime.gpencil_evaluated_frames[idx_eval]; \
+            bGPDframe *gpf_eval_ = (!is_multiedit_) ? \
+                                       &obeval_->runtime.gpencil_evaluated_frames[idx_eval] : \
+                                       gpf_; \
             /* loop over strokes */ \
             for (bGPDstroke *gps = gpf_eval_->strokes.first; gps; gps = gps->next) { \
               /* skip strokes that are invalid for current view */ \
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index b7b73c1b501..bffdf6d0d08 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -832,7 +832,8 @@ void GPENCIL_OT_select_less(wmOperatorType *ot)
  * from gpencil_paint.c #gp_stroke_eraser_dostroke().
  * It would be great to de-duplicate the logic here sometime, but that can wait.
  */
-static bool gp_stroke_do_circle_sel(bGPDlayer *gpl,
+static bool gp_stroke_do_circle_sel(bGPdata *gpd,
+                                    bGPDlayer *gpl,
                                     bGPDstroke *gps,
                                     GP_SpaceConversion *gsc,
                                     const int mx,
@@ -844,12 +845,14 @@ static bool gp_stroke_do_circle_sel(bGPDlayer *gpl,
                                     const int selectmode,
                                     const float scale)
 {
+  const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
   bGPDspoint *pt1 = NULL;
   bGPDspoint *pt2 = NULL;
-  bGPDstroke *gps_orig = gps->runtime.gps_orig;
   int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
   int i;
   bool changed = false;
+  bGPDstroke *gps_active = (!is_multiedit) ? gps->runtime.gps_orig : gps;
+  bGPDspoint *pt_active = NULL;
 
   if (gps->totpoints == 1) {
     bGPDspoint pt_temp;
@@ -862,12 +865,12 @@ static bool gp_stroke_do_circle_sel(bGPDlayer *gpl,
       if (((x0 - mx) * (x0 - mx) + (y0 - my) * (y0 - my)) <= radius * radius) {
         /* change selection */
         if (select) {
-          gps_orig->points->flag |= GP_SPOINT_SELECT;
-          gps_orig->flag |= GP_STROKE_SELECT;
+          gps_active->points->flag |= GP_SPOINT_SELECT;
+          gps_active->flag |= GP_STROKE_SELECT;
         }
         else {
-          gps_orig->points->flag &= ~GP_SPOINT_SELECT;
-          gps_orig->flag &= ~GP_STROKE_SELECT;
+          gps_active->points->flag &= ~GP_SPOINT_SELECT;
+          gps_active->flag &= ~GP_STROKE_SELECT;
         }
 
         return true;
@@ -907,20 +910,24 @@ static bool gp_stroke_do_circle_sel(bGPDlayer *gpl,
            */
           hit = true;
           if (select) {
-            if (pt1->runtime.pt_orig != NULL) {
-              pt1->runtime.pt_orig->flag |= GP_SPOINT_SELECT;
+            pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1;
+            if (pt_active != NULL) {
+              pt_active->flag |= GP_SPOINT_SELECT;
             }
-            if (pt2->runtime.pt_orig != NULL) {
-              pt2->runtime.pt_orig->flag |= GP_SPOINT_SELECT;
+            pt_active = (!is_multiedit) ? pt2->runtime.pt_orig : pt2;
+            if (pt_active != NULL) {
+              pt_active->flag |= GP_SPOINT_SELECT;
             }
             changed = true;
           }
           else {
-            if (pt1->runtime.pt_orig != NULL) {
-              pt1->runtime.pt_orig->flag &= ~GP_SPOINT_SELECT;
+            pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1;
+            if (pt_active != NULL) {
+              pt_active->flag &= ~GP_SPOINT_SELECT;
             }
-            if (pt2->runtime.pt_orig != NULL) {
-              pt2->runtime.pt_orig->flag &= ~GP_SPOINT_SELECT;
+            pt_active = (!is_multiedit) ? pt2->runtime.pt_orig : pt2;
+            if (pt_active != NULL) {
+              pt_active->flag &= ~GP_SPOINT_SELECT;
             }
             changed = true;
           }
@@ -935,28 +942,29 @@ static bool gp_stroke_do_circle_sel(bGPDlayer *gpl,
     /* if stroke mode expand selection */
     if ((hit) && (selectmode == GP_SELECTMODE_STROKE)) {
       for (i = 0, pt1 = gps->points; i < gps->totpoints; i++, pt1++) {
-        if (pt1->runtime.pt_orig != NULL) {
+        pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1;
+        if (pt_active != NULL) {
           if (select) {
-            pt1->runtime.pt_orig->flag |= GP_SPOINT_SELECT;
+            pt_active->flag |= GP_SPOINT_SELECT;
           }
           else {
-            pt1->runtime.pt_orig->flag &= ~GP_SPOINT_SELECT;
+            pt_active->flag &= ~GP_SPOINT_SELECT;
           }
         }
       }
     }
 
     /* expand selection to segment */
-    if ((hit) && (selectmode == GP_SELECTMODE_SEGMENT) && (select) &&
-        (pt1->runtime.pt_orig != NULL)) {
+    pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1;
+    if ((hit) && (selectmode == GP_SELECTMODE_SEGMENT) && (select) && (pt_active != NULL)) {
       float r_hita[3], r_hitb[3];
       bool hit_select = (bool)(pt1->flag & GP_SPOINT_SELECT);
       ED_gpencil_select_stroke_segment(
-          gpl, gps_orig, pt1->runtime.pt_orig, hit_select, false, scale, r_hita, r_hitb);
+          gpl, gps_active, pt_active, hit_select, false, scale, r_hita, r_hitb);
     }
 
     /* Ensure that stroke selection is in sync with its points */
-    BKE_gpencil_stroke_sync_selection(gps_orig);
+    BKE_gpencil_stroke_sync_selection(gps_active);
   }
 
   return changed;
@@ -1016,8 +1024,18 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
   /* find visible strokes, and select if hit */
   GP_EVALUATED_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
   {
-    changed |= gp_stroke_do_circle_sel(
-        gpl, gps, &gsc, mx, my, radius, select, &rect, gpstroke_iter.diff_mat, selectmode, scale);
+    changed |= gp_stroke_do_circle_sel(gpd,
+                                       gpl,
+                                       gps,
+                                       &gsc,
+                                       mx,
+                                       my,
+                                       radius,
+                                       select,
+                                       &rect,
+                                       gpstroke_iter.diff_mat,
+                                       selectmode,
+                                       scale);
   }
   GP_EVALUATED_STROKES_END(gpstroke_iter);
 
@@ -1090,6 +1108,8 @@ static int gpencil_generic_select_exec(bContext *C,
                            ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0));
   const bool segmentmode = ((selectmode == GP_SELECTMODE_SEGMENT) &&
                             ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0));
+  const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+
   const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
   const float scale = ts->gp_sculpt.isect_threshold;
 
@@ -1125,36 +1145,32 @@ static int gpencil_generic_select_exec(bContext *C,
   /* select/deselect points */
   GP_EVALUATED_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
   {
+    bGPDstroke *gps_active = (!is_multiedit) ? gps->runtime.gps_orig : gps;
 
     bGPDspoint *pt;
     int i;
     bool hit = false;
     for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
-      if (pt->runtime.pt_orig == NULL) {
+      if ((!is_multiedit) && (pt->runtime.pt_orig == NULL)) {
         continue;
       }
+      bGPDspoint *pt_active = (!is_multiedit) ? pt->runtime.pt_orig : pt;
 
       /* convert point coords to screenspace */
       const bool is_inside = is_inside_fn(gps, pt, &gsc, gpstroke_iter.diff_mat, user_data);
       if (strokemode == false) {
-        const bool is_select = (pt->runtime.pt_orig->flag & GP_SPOINT_SELECT) != 0;
+        const bool is_select = (pt_active->flag & GP_SPOINT_SELECT) != 0;
         const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
         if (sel_op_result != -1) {
-          SET_FLAG_FROM_TEST(pt->runtime.pt_orig->flag, sel_op_result, GP_SPOINT_SELECT);
+          SET_FLAG_FROM_TEST(pt_active->flag, sel_op_result, GP_SPOINT_SELECT);
           changed = true;
 
           /* expand selection to segment */
           if ((sel_op_result != -1) && (segmentmode)) {
-            bool hit_select = (bool)(pt->runtime.pt_orig->flag & GP_SPOINT_SELECT);
+            bool hit_select = (bool)(pt_active->flag & GP_SPOINT_SELECT);
             float r_hita[3], r_hitb[3];
-            ED_gpencil_select_stroke_segment(gpl,
-                                             gps->runtime.gps_orig,
-                                             pt->runtime.pt_orig,
-                                             hit_select,
-                                             false,
-                                             scale,
-                                             r_hita,
-                                             r_hitb);
+            ED_gpencil_select_stroke_segment(
+                gpl, gps_active, pt_active, hit_select, false, scale, r_hita, r_hitb);
           }
         }
       }
@@ -1168,19 +1184,21 @@ static int gpencil_generic_select_exec(bContext *C,
 
     /* if stroke mode expand selection */
     if (strokemode) {
-      const bool is_select = BKE_gpencil_stroke_select_check(gps->runtime.gps_orig);
+      const bool is_select = BKE_gpencil_stroke_select_check(gps_active);
       const bool is_inside = hit;
       const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
       if (sel_op_result != -1) {
         for (i = 0, pt = gps->points; i < gps->totpoints;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list