[Bf-blender-cvs] [5a804e3d6f5] greasepencil-edit-curve: Merge branch 'master' into greasepencil-edit-curve

Antonio Vazquez noreply at git.blender.org
Sun Jun 28 11:31:50 CEST 2020


Commit: 5a804e3d6f56184a85b7f30a626a2037bdebefa0
Author: Antonio Vazquez
Date:   Sun Jun 28 11:31:37 2020 +0200
Branches: greasepencil-edit-curve
https://developer.blender.org/rB5a804e3d6f56184a85b7f30a626a2037bdebefa0

Merge branch 'master' into greasepencil-edit-curve

 Conflicts:
	source/blender/editors/gpencil/gpencil_select.c
	source/blender/editors/gpencil/gpencil_utils.c

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



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

diff --cc source/blender/editors/gpencil/gpencil_select.c
index bbb4116c246,d698a9e2289..06b933106a9
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@@ -1703,50 -1471,38 +1703,42 @@@ static int gpencil_select_exec(bContex
      whole = (bool)(ts->gpencil_selectmode_edit == GP_SELECTMODE_STROKE);
    }
  
 -  /* init space conversion stuff */
 -  gp_point_conversion_init(C, &gsc);
 +  if (is_curve_edit) {
 +    gpencil_select_curve_point(
 +        C, mval, radius_squared, &hit_curve, &hit_curve_point, &hit_curve_handle);
 +  }
  
 -  /* get mouse location */
 -  RNA_int_get_array(op->ptr, "location", mval);
 +  if (hit_curve_point == NULL) {
 +    /* init space conversion stuff */
 +    gp_point_conversion_init(C, &gsc);
  
 -  /* First Pass: Find stroke point which gets hit */
 -  GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
 -    bGPDstroke *gps_active = (gps->runtime.gps_orig) ? gps->runtime.gps_orig : gps;
 -    bGPDspoint *pt;
 -    int i;
 +    /* First Pass: Find stroke point which gets hit */
 +    GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
 +      bGPDstroke *gps_active = (gps->runtime.gps_orig) ? gps->runtime.gps_orig : gps;
 +      bGPDspoint *pt;
 +      int i;
  
-       /* Check boundbox to speedup. */
-       float fmval[2];
-       copy_v2fl_v2i(fmval, mval);
-       if (!ED_gpencil_stroke_check_collision(
-               &gsc, gps_active, fmval, radius, gpstroke_iter.diff_mat)) {
-         continue;
-       }
- 
-       /* firstly, check for hit-point */
-       for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
-         int xy[2];
+     /* firstly, check for hit-point */
+     for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+       int xy[2];
  
 -      bGPDspoint pt2;
 -      gp_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
 -      gp_point_to_xy(&gsc, gps, &pt2, &xy[0], &xy[1]);
 -
 -      /* do boundbox check first */
 -      if (!ELEM(V2D_IS_CLIPPED, xy[0], xy[1])) {
 -        const int pt_distance = len_manhattan_v2v2_int(mval, xy);
 -
 -        /* check if point is inside */
 -        if (pt_distance <= radius_squared) {
 -          /* only use this point if it is a better match than the current hit - T44685 */
 -          if (pt_distance < hit_distance) {
 -            hit_layer = gpl;
 -            hit_stroke = gps_active;
 -            hit_point = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
 -            hit_distance = pt_distance;
 +        bGPDspoint pt2;
 +        gp_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
 +        gp_point_to_xy(&gsc, gps, &pt2, &xy[0], &xy[1]);
 +
 +        /* do boundbox check first */
 +        if (!ELEM(V2D_IS_CLIPPED, xy[0], xy[1])) {
 +          const int pt_distance = len_manhattan_v2v2_int(mval, xy);
 +
 +          /* check if point is inside */
 +          if (pt_distance <= radius_squared) {
 +            /* only use this point if it is a better match than the current hit - T44685 */
 +            if (pt_distance < hit_distance) {
 +              hit_layer = gpl;
 +              hit_stroke = gps_active;
 +              hit_point = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
 +              hit_distance = pt_distance;
 +            }
            }
          }
        }
diff --cc source/blender/editors/gpencil/gpencil_utils.c
index cba05ee4afb,4bb598fa530..4ece4553955
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@@ -2612,81 -2621,10 +2622,84 @@@ void ED_gpencil_select_toggle_all(bCont
    }
  }
  
 +void ED_gpencil_select_curve_toggle_all(bContext *C, int action, float error_threshold)
 +{
 +  /* if toggle, check if we need to select or deselect */
 +  if (action == SEL_TOGGLE) {
 +    action = SEL_SELECT;
 +    GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
 +    {
 +      if (gpc->flag & GP_CURVE_SELECT) {
 +        action = SEL_DESELECT;
 +      }
 +    }
 +    GP_EDITABLE_CURVES_END(gps_iter);
 +  }
 +
 +  if (action == SEL_DESELECT) {
 +    GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
 +    {
 +      for (int 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;
 +    }
 +    GP_EDITABLE_CURVES_END(gps_iter);
 +  }
 +  else {
 +    CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
 +      Object *ob = CTX_data_active_object(C);
 +      bGPdata *gpd = ob->data;
 +      bool selected = false;
 +
 +      /* Make sure stroke has a curve */
 +      if (gps->editcurve == NULL) {
 +        BKE_gpencil_stroke_editcurve_update(gps, error_threshold);
 +        gps->editcurve->resolution = gpd->editcurve_resolution;
 +        gps->editcurve->flag |= GP_CURVE_RECALC_GEOMETRY;
 +        BKE_gpencil_stroke_geometry_update(gps);
 +      }
 +
 +      bGPDcurve *gpc = gps->editcurve;
 +      for (int i = 0; i < gpc->tot_curve_points; i++) {
 +        bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
 +        BezTriple *bezt = &gpc_pt->bezt;
 +        switch (action) {
 +          case SEL_SELECT:
 +            gpc_pt->flag |= GP_CURVE_POINT_SELECT;
 +            BEZT_SEL_ALL(bezt);
 +            break;
 +          case SEL_INVERT:
 +            gpc_pt->flag ^= GP_CURVE_POINT_SELECT;
 +            BEZT_SEL_INVERT(bezt);
 +            break;
 +          default:
 +            break;
 +        }
 +
 +        if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
 +          selected = true;
 +        }
 +      }
 +
 +      if (selected) {
 +        gpc->flag |= GP_CURVE_SELECT;
 +      }
 +      else {
 +        gpc->flag &= ~GP_CURVE_SELECT;
 +      }
 +    }
 +    CTX_DATA_END;
 +  }
 +}
 +
- /* Ensure the SBuffer (while drawing stroke) size is enough to save all points of the stroke */
+ /**
+  * Ensure the #tGPspoint buffer (while drawing stroke)
+  * size is enough to save all points of the stroke.
+  */
  tGPspoint *ED_gpencil_sbuffer_ensure(tGPspoint *buffer_array,
                                       int *buffer_size,
                                       int *buffer_used,



More information about the Bf-blender-cvs mailing list