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

Falk David noreply at git.blender.org
Sat Apr 24 11:39:38 CEST 2021


Commit: 5f4a24e491acd1c3d3a4e3cc4c5f3dfa126ff468
Author: Falk David
Date:   Sat Apr 24 11:23:14 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rB5f4a24e491acd1c3d3a4e3cc4c5f3dfa126ff468

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

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



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

diff --cc source/blender/editors/gpencil/gpencil_edit.c
index 25be01423d8,d90f74fbf4f..0f402334a61
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@@ -1912,45 -1847,55 +1907,60 @@@ static int gpencil_move_to_layer_exec(b
      return OPERATOR_CANCELLED;
    }
  
-   /* Extract all strokes to move to this layer
-    * NOTE: We need to do this in a two-pass system to avoid conflicts with strokes
-    *       getting repeatedly moved
-    */
-   CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
-     bGPDframe *gpf = gpl->actframe;
- 
-     /* skip if no frame with strokes, or if this is the layer we're moving strokes to */
-     if ((gpl == target_layer) || (gpf == NULL)) {
+   /* Extract all strokes to move to this layer. */
+   CTX_DATA_BEGIN (C, bGPDlayer *, gpl_src, editable_gpencil_layers) {
+     /* Skip if this is the layer we're moving strokes to. */
+     if (gpl_src == target_layer) {
        continue;
      }
+     bGPDframe *init_gpf = (is_multiedit) ? gpl_src->frames.first : gpl_src->actframe;
+     for (bGPDframe *gpf_src = init_gpf; gpf_src; gpf_src = gpf_src->next) {
+       if ((gpf_src == gpl_src->actframe) ||
+           ((gpf_src->flag & GP_FRAME_SELECT) && (is_multiedit))) {
+         if (gpf_src == NULL) {
+           continue;
+         }
  
-     /* make copies of selected strokes, and deselect these once we're done */
-     LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, &gpf->strokes) {
- 
-       /* 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;
-       }
+         bGPDstroke *gpsn = NULL;
+         BLI_listbase_clear(&strokes);
+         for (bGPDstroke *gps = gpf_src->strokes.first; gps; gps = gpsn) {
+           gpsn = gps->next;
+           /* 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_src, gps) == false) {
+             continue;
+           }
  
-       bool is_stroke_selected = GPENCIL_STROKE_TYPE_BEZIER(gps) ?
 -          if (gps->flag & GP_STROKE_SELECT) {
++          bool is_stroke_selected = GPENCIL_STROKE_TYPE_BEZIER(gps) ?
 +                                    gps->editcurve->flag & GP_CURVE_SELECT :
 +                                    gps->flag & GP_STROKE_SELECT;
 +
-       /* TODO: Don't just move entire strokes - instead, only copy the selected portions... */
-       if (is_stroke_selected) {
-         BLI_remlink(&gpf->strokes, gps);
-         BLI_addtail(&strokes, gps);
++          /* TODO: Don't just move entire strokes - instead, only copy the selected portions... */
++          if (is_stroke_selected) {
+             BLI_remlink(&gpf_src->strokes, gps);
+             BLI_addtail(&strokes, gps);
+           }
+         }
+         /* Paste them all in one go. */
+         if (strokes.first) {
+           bGPDframe *gpf_dst = BKE_gpencil_layer_frame_get(
+               target_layer, gpf_src->framenum, GP_GETFRAME_ADD_NEW);
+ 
+           BLI_movelisttolist(&gpf_dst->strokes, &strokes);
+           BLI_assert((strokes.first == strokes.last) && (strokes.first == NULL));
+         }
+       }
+       /* If not multi-edit, exit loop. */
+       if (!is_multiedit) {
+         break;
        }
      }
- 
-     /* if new layer and autolock, lock old layer */
+     /* If new layer and autolock, lock old layer. */
      if ((layer_num == -1) && (use_autolock)) {
-       gpl->flag |= GP_LAYER_LOCKED;
+       gpl_src->flag |= GP_LAYER_LOCKED;
      }
    }
    CTX_DATA_END;
@@@ -4102,34 -3785,42 +4104,33 @@@ static int gpencil_strokes_reproject_ex
            continue;
          }
          for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
 -          /* skip strokes that are invalid for current view */
 -          if (ED_gpencil_stroke_can_use(C, gps) == false) {
 +          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;
            }
 -          bool curve_select = false;
 -          if (is_curve_edit && gps->editcurve != NULL) {
 -            curve_select = gps->editcurve->flag & GP_CURVE_SELECT;
 +          /* update frame to get the new location of objects */
 +          if ((mode == GP_REPROJECT_SURFACE) && (cfra_prv != gpf->framenum)) {
 +            cfra_prv = gpf->framenum;
 +            CFRA = gpf->framenum;
 +            BKE_scene_graph_update_for_newframe(depsgraph);
            }
  
 -          if (gps->flag & GP_STROKE_SELECT || curve_select) {
 -
 -            /* update frame to get the new location of objects */
 -            if ((mode == GP_REPROJECT_SURFACE) && (cfra_prv != gpf->framenum)) {
 -              cfra_prv = gpf->framenum;
 -              CFRA = gpf->framenum;
 -              BKE_scene_graph_update_for_newframe(depsgraph);
 -            }
 -
 -            ED_gpencil_stroke_reproject(depsgraph, &gsc, sctx, gpl, gpf, gps, mode, keep_original);
 +          ED_gpencil_stroke_reproject(depsgraph, &gsc, sctx, gpl, gpf, gps, mode, keep_original);
  
 -            if (is_curve_edit && gps->editcurve != NULL) {
 -              BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
 -              /* Update the selection from the stroke to the curve. */
 -              BKE_gpencil_editcurve_stroke_sync_selection(gpd, gps, gps->editcurve);
 +          /* TODO: Reproject curve data and regenerate stroke.
 +           * Right now we are using the projected points to regenerate the curve. This will most
 +           * likely change the handles which is usually not wanted.*/
-           BKE_gpencil_stroke_geometry_update(gpd, gps, GP_GEO_UPDATE_CURVE_REFIT_ALL);
++          BKE_gpencil_stroke_geometry_update(gpd, gps, GP_GEO_UPDATE_DEFAULT);
  
 -              gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
 -              BKE_gpencil_stroke_geometry_update(gpd, gps);
 -            }
 -
 -            changed = true;
 -          }
 +          changed = true;
          }
- 
-         /* If not multi-edit, exit loop. */
-         if (!is_multiedit) {
-           break;
-         }
+       }
+       /* If not multi-edit, exit loop. */
+       if (!is_multiedit) {
+         break;
        }
      }
    }



More information about the Bf-blender-cvs mailing list