[Bf-blender-cvs] [a46f947138d] temp-gpencil-bezier-v2: Merge branch 'master' into temp-gpencil-bezier-v2

Falk David noreply at git.blender.org
Sat Feb 20 19:52:28 CET 2021


Commit: a46f947138dc5145832891d2dfa1a39d2ba453ed
Author: Falk David
Date:   Sat Feb 20 19:38:59 2021 +0100
Branches: temp-gpencil-bezier-v2
https://developer.blender.org/rBa46f947138dc5145832891d2dfa1a39d2ba453ed

Merge branch 'master' into temp-gpencil-bezier-v2

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



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

diff --cc source/blender/blenkernel/intern/gpencil.c
index 86b293e8e6c,28477e9dc30..e46df81f4d4
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@@ -1169,7 -1169,8 +1169,7 @@@ void BKE_gpencil_curve_sync_selection(b
      return;
    }
  
-   BKE_gpencil_stroke_select_index_set(NULL, gps, true);
 -  gps->flag &= ~GP_STROKE_SELECT;
+   BKE_gpencil_stroke_select_index_reset(gps);
    gpc->flag &= ~GP_CURVE_SELECT;
  
    bool is_selected = false;
@@@ -1191,7 -1192,8 +1191,7 @@@
  
    if (is_selected) {
      gpc->flag |= GP_CURVE_SELECT;
-     BKE_gpencil_stroke_select_index_set(gpd, gps, false);
 -    gps->flag |= GP_STROKE_SELECT;
+     BKE_gpencil_stroke_select_index_set(gpd, gps);
    }
  }
  
diff --cc source/blender/editors/gpencil/gpencil_merge.c
index 8d8734dfd1f,259b2882589..c7e0063dbca
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@@ -243,11 -243,11 +243,8 @@@ static void gpencil_calc_points_factor(
            }
          }
          gps->flag &= ~GP_STROKE_SELECT;
-         BKE_gpencil_stroke_select_index_set(NULL, gps, true);
-       }
-     }
+         BKE_gpencil_stroke_select_index_reset(gps);
 -      }
 -    }
    }
--  CTX_DATA_END;
  
    /* project in 2d plane */
    int direction = 0;
diff --cc source/blender/editors/gpencil/gpencil_select.c
index c49d2e452f1,e01c1ec54d7..ef183224cd2
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@@ -162,32 -162,33 +162,33 @@@ static void deselect_all_selected(bCont
    gpd->select_last_index = 0;
  
    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;
 +    if (GPENCIL_STROKE_IS_CURVE(gps)) {
 +      bGPDcurve *gpc = gps->editcurve;
  
 -      /* deselect points */
 -      for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
 -        pt->flag &= ~GP_SPOINT_SELECT;
 +      if (gpc->flag & GP_CURVE_SELECT) {
 +        /* Deselect the curve points. */
 +        for (uint32_t i = 0; i < gpc->tot_curve_points; i++) {
 +          bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
 +          BezTriple *bezt = &gpc_pt->bezt;
 +          gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
 +          BEZT_DESEL_ALL(bezt);
 +        }
 +        gpc->flag &= ~GP_CURVE_SELECT;
++        BKE_gpencil_stroke_select_index_reset(gps);
        }
 -
 -      /* deselect stroke itself too */
 -      gps->flag &= ~GP_STROKE_SELECT;
 -      BKE_gpencil_stroke_select_index_reset(gps);
      }
 -
 -    /* deselect curve and curve points */
 -    if (gps->editcurve != NULL) {
 -      bGPDcurve *gpc = gps->editcurve;
 -      for (int j = 0; j < gpc->tot_curve_points; j++) {
 -        bGPDcurve_point *gpc_pt = &gpc->curve_points[j];
 -        BezTriple *bezt = &gpc_pt->bezt;
 -        gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
 -        BEZT_DESEL_ALL(bezt);
 +    else {
 +      if (gps->flag & GP_STROKE_SELECT) {
 +        /* Deselect the points. */
 +        for (uint32_t i = 0; i < gps->totpoints; i++) {
 +          bGPDspoint *pt = &gps->points[i];
 +          pt->flag &= ~GP_SPOINT_SELECT;
 +        }
 +        gps->flag &= ~GP_STROKE_SELECT;
        }
 -
 -      gpc->flag &= ~GP_CURVE_SELECT;
      }
 +
 +    BKE_gpencil_stroke_select_index_set(NULL, gps, true);
    }
    CTX_DATA_END;
  }
@@@ -552,36 -559,39 +553,37 @@@ static bool gpencil_select_same_layer(b
  
      /* Select all if found */
      if (found) {
 -      if (is_curve_edit) {
 -        for (gps = gpf->strokes.first; gps; gps = gps->next) {
 -          if (gps->editcurve != NULL && ED_gpencil_stroke_can_use(C, gps)) {
 -            bGPDcurve *gpc = gps->editcurve;
 -            for (int i = 0; i < gpc->tot_curve_points; i++) {
 -              bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
 -              gpc_pt->flag |= GP_CURVE_POINT_SELECT;
 -              BEZT_SEL_ALL(&gpc_pt->bezt);
 -            }
 -            gpc->flag |= GP_CURVE_SELECT;
 -            gps->flag |= GP_STROKE_SELECT;
 -            BKE_gpencil_stroke_select_index_set(gpd, gps);
 +      for (gps = gpf->strokes.first; gps; gps = gps->next) {
 +        if (!ED_gpencil_stroke_can_use(C, gps)) {
 +          continue;
 +        }
  
 -            changed = true;
 +        if (GPENCIL_STROKE_IS_CURVE(gps)) {
 +          bGPDcurve *gpc = gps->editcurve;
 +          for (int i = 0; i < gpc->tot_curve_points; i++) {
 +            bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
 +            gpc_pt->flag |= GP_CURVE_POINT_SELECT;
 +            BEZT_SEL_ALL(&gpc_pt->bezt);
            }
 +          gpc->flag |= GP_CURVE_SELECT;
 +
 +          changed = true;
          }
 -      }
 -      else {
 -        for (gps = gpf->strokes.first; gps; gps = gps->next) {
 -          if (ED_gpencil_stroke_can_use(C, gps)) {
 -            bGPDspoint *pt;
 -            int i;
 +        else {
 +          bGPDspoint *pt;
 +          int i;
  
 -            for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
 -              pt->flag |= GP_SPOINT_SELECT;
 -            }
 +          for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
 +            pt->flag |= GP_SPOINT_SELECT;
 +          }
  
 -            gps->flag |= GP_STROKE_SELECT;
 -            BKE_gpencil_stroke_select_index_set(gpd, gps);
 +          gps->flag |= GP_STROKE_SELECT;
++          BKE_gpencil_stroke_select_index_set(gpd, gps);
  
 -            changed = true;
 -          }
 +          changed = true;
          }
 +
 +        BKE_gpencil_stroke_select_index_set(gpd, gps, false);
        }
      }
    }
@@@ -773,10 -795,8 +776,10 @@@ static int gpencil_select_first_exec(bC
            pt->flag &= ~GP_SPOINT_SELECT;
          }
        }
 -      changed = true;
      }
 +
 +    changed = true;
-     BKE_gpencil_stroke_select_index_set(gpd, gps, false);
++    BKE_gpencil_stroke_select_index_set(gpd, gps);
    }
    CTX_DATA_END;
  
@@@ -852,19 -871,22 +855,19 @@@ static int gpencil_select_last_exec(bCo
      /* select last point */
      BLI_assert(gps->totpoints >= 1);
  
 -    if (is_curve_edit) {
 -      if (gps->editcurve != NULL) {
 -        bGPDcurve *gpc = gps->editcurve;
 -        gpc->curve_points[gpc->tot_curve_points - 1].flag |= GP_CURVE_POINT_SELECT;
 -        BEZT_SEL_ALL(&gpc->curve_points[gpc->tot_curve_points - 1].bezt);
 -        gpc->flag |= GP_CURVE_SELECT;
 -        gps->flag |= GP_STROKE_SELECT;
 -        BKE_gpencil_stroke_select_index_set(gpd, gps);
 -        if ((extend == false) && (gps->totpoints > 1)) {
 -          for (int i = 0; i < gpc->tot_curve_points - 1; i++) {
 -            bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
 -            gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
 -            BEZT_DESEL_ALL(&gpc_pt->bezt);
 -          }
 +    if (GPENCIL_STROKE_IS_CURVE(gps)) {
 +      bGPDcurve *gpc = gps->editcurve;
 +
 +      gpc->curve_points[gpc->tot_curve_points - 1].flag |= GP_CURVE_POINT_SELECT;
 +      BEZT_SEL_ALL(&gpc->curve_points[gpc->tot_curve_points - 1].bezt);
 +      gpc->flag |= GP_CURVE_SELECT;
- 
++      BKE_gpencil_stroke_select_index_set(gpd, gps);
 +      if ((extend == false) && (gps->totpoints > 1)) {
 +        for (int i = 0; i < gpc->tot_curve_points - 1; i++) {
 +          bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
 +          gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
 +          BEZT_DESEL_ALL(&gpc_pt->bezt);
          }
 -        changed = true;
        }
      }
      else {
diff --cc source/blender/editors/gpencil/gpencil_utils.c
index 168a19dd643,5c041134a74..460dde72129
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@@ -2612,27 -2603,20 +2612,27 @@@ void ED_gpencil_select_toggle_all(bCont
  
        /* deselect all strokes on all frames */
        LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
 -        bGPDstroke *gps;
 -
 -        for (gps = gpf->strokes.first; gps; gps = gps->next) {
 -          bGPDspoint *pt;
 -          int i;
 -
 +        for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
            /* only edit strokes that are valid in this view... */
 -          if (ED_gpencil_stroke_can_use(C, gps)) {
 -            for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
 +          if (!ED_gpencil_stroke_can_use(C, gps))
 +            continue;
 +
 +          if (GPENCIL_STROKE_IS_CURVE(gps)) {
 +            bGPDcurve *gpc = gps->editcurve;
 +            for (uint32_t i = 0; i < gpc->tot_curve_points; i++) {
 +              bGPDcurve_point *pt = &gpc->curve_points[i];
 +              pt->flag &= ~GP_CURVE_POINT_SELECT;
 +              BEZT_DESEL_ALL(&pt->bezt);
 +            }
 +            gpc->flag &= ~GP_CURVE_SELECT;
 +          }
 +          else {
 +            for (uint32_t i = 0; i < gps->totpoints; i++) {
 +              bGPDspoint *pt = &gps->points[i];
                pt->flag &= ~GP_SPOINT_SELECT;
              }
 -
              gps->flag &= ~GP_STROKE_SELECT;
-             BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+             BKE_gpencil_stroke_select_index_reset(gps);
            }
          }
        }
@@@ -2642,68 -2626,39 +2642,68 @@@
    else {
      /* select or deselect all strokes */
      CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
 -      bGPDspoint *pt;
 -      int i;
        bool selected = false;
  
 -      /* Change selection status of all points, then make the stroke match */
 -      for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
 -        switch (action) {
 -          case SEL_SELECT:
 -            pt->flag |= GP_SPOINT_SELECT;
 -            break;
 -#if 0
 -          case SEL_DESELECT:
 -           pt->flag &= ~GP_SPOINT_SELECT;
 -           break;
 -#endif
 -          case SEL_INVERT:
 -            pt->flag ^= GP_SPOINT_SELECT;
 -            break;
 -        }
 +      if (GPENCIL_STROKE_IS_CURVE(gps)) {
 +        bGPDcurve *gpc = gps->editcurve;
 +
 +        for (uint32_t i = 0; i < gpc->tot_curve_points; i++) {
 +          bGPDcurve_point *gpc_pt = &g

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list