[Bf-blender-cvs] [c7ec464036b] temp-gpencil-bezier-stroke-type: Merge branch 'master' into temp-gpencil-bezier-stroke-type

Falk David noreply at git.blender.org
Thu Jul 1 23:32:21 CEST 2021


Commit: c7ec464036bad6d8f40dbcd10c422290efd275b6
Author: Falk David
Date:   Thu Jul 1 23:31:55 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rBc7ec464036bad6d8f40dbcd10c422290efd275b6

Merge branch 'master' into temp-gpencil-bezier-stroke-type

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



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

diff --cc source/blender/blenkernel/intern/gpencil.c
index ea86af848fa,459fc5e4c68..4df804209b0
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@@ -250,24 -249,19 +250,24 @@@ void BKE_gpencil_blend_read_data(BlendD
        BLO_read_list(reader, &gpf->strokes);
  
        LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
-         /* relink stroke points array */
+         /* Relink stroke points array. */
          BLO_read_data_address(reader, &gps->points);
-         /* Relink geometry*/
+         /* Relink geometry. */
          BLO_read_data_address(reader, &gps->triangles);
  
-         /* relink stroke edit curve. */
+         /* Relink stroke edit curve. */
          BLO_read_data_address(reader, &gps->editcurve);
          if (gps->editcurve != NULL) {
-           /* relink curve point array */
+           /* Relink curve point array. */
            BLO_read_data_address(reader, &gps->editcurve->curve_points);
 +          if (gps->editcurve->dvert != NULL) {
 +            BLO_read_data_address(reader, &gps->editcurve->dvert);
 +            BKE_defvert_blend_read(
 +                reader, gps->editcurve->tot_curve_points, gps->editcurve->dvert);
 +          }
          }
  
-         /* relink weight data */
+         /* Relink weight data. */
          if (gps->dvert) {
            BLO_read_data_address(reader, &gps->dvert);
            BKE_defvert_blend_read(reader, gps->totpoints, gps->dvert);
diff --cc source/blender/blenloader/intern/versioning_300.c
index 5cea824f880,ecee14d3d58..97878f15c6e
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@@ -26,9 -25,10 +26,11 @@@
  #include "BLI_string.h"
  #include "BLI_utildefines.h"
  
+ #include "DNA_anim_types.h"
+ #include "DNA_armature_types.h"
  #include "DNA_brush_types.h"
  #include "DNA_genfile.h"
 +#include "DNA_gpencil_types.h"
  #include "DNA_listBase.h"
  #include "DNA_modifier_types.h"
  #include "DNA_text_types.h"
diff --cc source/blender/editors/gpencil/gpencil_data.c
index 214c7568964,e272f46d13d..685cd54fc1b
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@@ -1754,29 -1755,24 +1754,29 @@@ static int gpencil_stroke_change_color_
  
          LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
            /* only if selected */
 -          if (gps->flag & GP_STROKE_SELECT) {
 -            /* skip strokes that are invalid for current view */
 -            if (ED_gpencil_stroke_can_use(C, gps) == false) {
 -              continue;
 -            }
 -            /* check if the color is editable */
 -            if (ED_gpencil_stroke_material_editable(ob, gpl, gps) == false) {
 -              continue;
 -            }
 -
 -            /* assign new color */
 -            gps->mat_nr = idx;
 +          bool is_stroke_selected = GPENCIL_STROKE_TYPE_BEZIER(gps) ?
 +                                        (bool)(gps->editcurve->flag & GP_CURVE_SELECT) :
 +                                        (bool)(gps->flag & GP_STROKE_SELECT);
 +          if (!is_stroke_selected) {
 +            continue;
 +          }
  
 -            changed = true;
 +          /* skip strokes that are invalid for current view */
 +          if (ED_gpencil_stroke_can_use(C, gps) == false) {
 +            continue;
            }
 +          /* check if the color is editable */
 +          if (ED_gpencil_stroke_material_editable(ob, gpl, gps) == false) {
 +            continue;
 +          }
 +
 +          /* assign new color */
 +          gps->mat_nr = idx;
 +
 +          changed = true;
          }
        }
-       /* if not multiedit, exit loop*/
+       /* If not multi-edit, exit loop. */
        if (!is_multiedit) {
          break;
        }
diff --cc source/blender/editors/gpencil/gpencil_edit.c
index 4d79bc0946c,8d1f841da6c..b57b2fb3ace
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@@ -830,99 -846,24 +830,99 @@@ static void gpencil_duplicate_points(bG
                                       ListBase *new_strokes,
                                       const char *layername)
  {
 -  bGPDspoint *pt;
 -  int i;
 -
    int start_idx = -1;
  
 -  /* Step through the original stroke's points:
 -   * - We accumulate selected points (from start_idx to current index)
 -   *   and then convert that to a new stroke
 -   */
 -  for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
 -    /* searching for start, are waiting for end? */
 -    if (start_idx == -1) {
 -      /* is this the first selected point for a new island? */
 -      if (pt->flag & GP_SPOINT_SELECT) {
 -        start_idx = i;
 +  if (GPENCIL_STROKE_TYPE_BEZIER(gps)) {
 +    bGPDcurve *gpc = gps->editcurve;
 +    for (int i = 0; i < gpc->tot_curve_points; i++) {
 +      bGPDcurve_point *cpt = &gpc->curve_points[i];
 +      if (start_idx == -1) {
 +        if (cpt->flag & GP_CURVE_POINT_SELECT) {
 +          start_idx = i;
 +        }
 +        continue;
 +      }
 +
 +      size_t len = 0;
 +
 +      if ((cpt->flag & GP_CURVE_POINT_SELECT) == 0) {
 +        len = i - start_idx;
 +      }
 +      else if (i == gpc->tot_curve_points - 1) {
 +        len = i - start_idx + 1;
 +      }
 +
 +      if (len < 1) {
 +        continue;
 +      }
 +
 +      /* make a stupid copy first of the entire stroke (to get the flags too) */
 +      bGPDstroke *gpsd = BKE_gpencil_stroke_duplicate((bGPDstroke *)gps, false, false);
 +
 +      /* saves original layer name */
 +      BLI_strncpy(gpsd->runtime.tmp_layerinfo, layername, sizeof(gpsd->runtime.tmp_layerinfo));
 +
 +      /* To avoid a curve update, we just copy the points. */
 +      int start_idx_stroke = gpc->curve_points[start_idx].point_index;
 +      int len_stroke = (gpc->curve_points[start_idx + len - 1].point_index - start_idx_stroke) + 1;
 +
 +      gpsd->points = MEM_mallocN(sizeof(bGPDspoint) * len_stroke, "gps stroke points copy");
 +      memcpy(gpsd->points, gps->points + start_idx_stroke, sizeof(bGPDspoint) * len_stroke);
 +      gpsd->totpoints = len_stroke;
 +
 +      gpsd->editcurve = BKE_gpencil_stroke_editcurve_new(len);
 +      bGPDcurve *gpcd = gpsd->editcurve;
 +      memcpy(gpcd->curve_points, gpc->curve_points + start_idx, sizeof(bGPDcurve_point) * len);
 +
 +      if (gps->dvert != NULL) {
 +        gpsd->dvert = MEM_mallocN(sizeof(MDeformVert) * len, "gps stroke weights copy");
 +        memcpy(gpsd->dvert, gps->dvert + start_idx, sizeof(MDeformVert) * len);
 +
 +        /* Copy weights */
 +        int e = start_idx;
 +        for (int j = 0; j < gpsd->totpoints; j++) {
 +          MDeformVert *dvert_dst = &gps->dvert[e];
 +          MDeformVert *dvert_src = &gps->dvert[j];
 +          dvert_dst->dw = MEM_dupallocN(dvert_src->dw);
 +          e++;
 +        }
 +      }
 +
 +      /* TODO: Copy vertex weights*/
 +      for (uint32_t j = 0; j < gpcd->tot_curve_points; j++) {
 +        bGPDcurve_point *gpcd_pt = &gpcd->curve_points[j];
 +        BezTriple *bezt = &gpcd_pt->bezt;
 +        gpcd_pt->flag |= GP_CURVE_POINT_SELECT;
 +        BEZT_SEL_ALL(bezt);
        }
 +      gpcd->flag |= GP_CURVE_SELECT;
 +
 +      BKE_gpencil_stroke_geometry_update(gpd, gpsd, GP_GEO_UPDATE_DEFAULT);
 +
 +      /* add to temp buffer */
 +      gpsd->next = gpsd->prev = NULL;
 +
 +      BLI_addtail(new_strokes, gpsd);
 +
 +      start_idx = -1;
      }
 -    if ((start_idx != -1) || (start_idx == gps->totpoints - 1)) {
 +  }
 +  else {
 +    /* Step through the original stroke's points:
 +     * - We accumulate selected points (from start_idx to current index)
 +     *   and then convert that to a new stroke
 +     */
 +    for (int i = 0; i < gps->totpoints; i++) {
 +      bGPDspoint *pt = &gps->points[i];
 +      /* searching for start, are waiting for end? */
-       if (start_idx == -1) {
++      if ((start_idx != -1) || (start_idx == gps->totpoints - 1)) {
 +        /* is this the first selected point for a new island? */
 +        if (pt->flag & GP_SPOINT_SELECT) {
 +          start_idx = i;
 +        }
 +        continue;
 +      }
 +
        size_t len = 0;
  
        /* is this the end of current island yet?
@@@ -4774,206 -4613,70 +4774,202 @@@ static int gpencil_stroke_separate_exec
              if (ED_gpencil_stroke_material_editable(ob, gpl, gps) == false) {
                continue;
              }
 +
              /* Separate selected strokes. */
- 
-             /* add layer if not created before */
 -            if (gps->flag & GP_STROKE_SELECT) {
 -              /* add layer if not created before */
 -              if (gpl_dst == NULL) {
 -                gpl_dst = BKE_gpencil_layer_addnew(gpd_dst, gpl->info, false, false);
 -                BKE_gpencil_layer_copy_settings(gpl, gpl_dst);
 -                /* Copy masks. */
 -                BKE_gpencil_layer_mask_copy(gpl, gpl_dst);
 -              }
 +            if (gpl_dst == NULL) {
 +              gpl_dst = BKE_gpencil_layer_addnew(gpd_dst, gpl->info, false, false);
-               gpl_dst->line_change = gpl->line_change;
-               copy_v4_v4(gpl_dst->tintcolor, gpl->tintcolor);
-               gpl_dst->opacity = gpl->opacity;
-               gpl_dst->blend_mode = gpl->blend_mode;
-               gpl_dst->vertex_paint_opacity = gpl->vertex_paint_opacity;
++              BKE_gpencil_layer_copy_settings(gpl, gpl_dst);
++              /* Copy masks. */
++              BKE_gpencil_layer_mask_copy(gpl, gpl_dst);
 +            }
  
 -              /* add frame if not created before */
 -              if (gpf_dst == NULL) {
 -                gpf_dst = BKE_gpencil_layer_frame_get(gpl_dst, gpf->framenum, GP_GETFRAME_ADD_NEW);
 -              }
 +            /* add frame if not created before */
 +            if (gpf_dst == NULL) {
 +              gpf_dst = BKE_gpencil_layer_frame_get(gpl_dst, gpf->framenum, GP_GETFRAME_ADD_NEW);
 +            }
 +
 +            /* add duplicate materials */
 +
 +            /* XXX same material can be in multiple slots. */
 +            ma = BKE_gpencil_material(ob, gps->mat_nr + 1);
 +
 +            idx = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma);


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list