[Bf-blender-cvs] [1ffb011d677] blender-v3.3-release: Fix T100171: GPencil toggle caps operator does not support multiframe

Antonio Vazquez noreply at git.blender.org
Thu Aug 4 15:12:42 CEST 2022


Commit: 1ffb011d677647f6e049e9ca76d1ba31d156308a
Author: Antonio Vazquez
Date:   Wed Aug 3 15:45:08 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB1ffb011d677647f6e049e9ca76d1ba31d156308a

Fix T100171: GPencil toggle caps operator does not support multiframe

This was a missing feature.

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

M	source/blender/editors/gpencil/gpencil_edit.c

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

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 69a74c36aee..c05ab8c6b28 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -3395,6 +3395,7 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op)
   bGPdata *gpd = ED_gpencil_data_get_active(C);
   Object *ob = CTX_data_active_object(C);
   const int type = RNA_enum_get(op->ptr, "type");
+  const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
 
   /* sanity checks */
   if (ELEM(NULL, gpd)) {
@@ -3404,46 +3405,57 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op)
   bool changed = false;
   /* loop all selected strokes */
   CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
-    if (gpl->actframe == NULL) {
-      continue;
-    }
+    bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
 
-    for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
-      MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
+    for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
+      if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
+        if (gpf == NULL) {
+          continue;
+        }
 
-      /* skip strokes that are not selected or invalid for current view */
-      if (((gps->flag & GP_STROKE_SELECT) == 0) || (ED_gpencil_stroke_can_use(C, gps) == false)) {
-        continue;
-      }
-      /* skip hidden or locked colors */
-      if (!gp_style || (gp_style->flag & GP_MATERIAL_HIDE) ||
-          (gp_style->flag & GP_MATERIAL_LOCKED)) {
-        continue;
-      }
+        for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+          MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
 
-      short prev_first = gps->caps[0];
-      short prev_last = gps->caps[1];
+          /* skip strokes that are not selected or invalid for current view */
+          if (((gps->flag & GP_STROKE_SELECT) == 0) ||
+              (ED_gpencil_stroke_can_use(C, gps) == false)) {
+            continue;
+          }
+          /* skip hidden or locked colors */
+          if (!gp_style || (gp_style->flag & GP_MATERIAL_HIDE) ||
+              (gp_style->flag & GP_MATERIAL_LOCKED)) {
+            continue;
+          }
+
+          short prev_first = gps->caps[0];
+          short prev_last = gps->caps[1];
+
+          if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_START)) {
+            ++gps->caps[0];
+            if (gps->caps[0] >= GP_STROKE_CAP_MAX) {
+              gps->caps[0] = GP_STROKE_CAP_ROUND;
+            }
+          }
+          if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_END)) {
+            ++gps->caps[1];
+            if (gps->caps[1] >= GP_STROKE_CAP_MAX) {
+              gps->caps[1] = GP_STROKE_CAP_ROUND;
+            }
+          }
+          if (type == GP_STROKE_CAPS_TOGGLE_DEFAULT) {
+            gps->caps[0] = GP_STROKE_CAP_ROUND;
+            gps->caps[1] = GP_STROKE_CAP_ROUND;
+          }
 
-      if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_START)) {
-        ++gps->caps[0];
-        if (gps->caps[0] >= GP_STROKE_CAP_MAX) {
-          gps->caps[0] = GP_STROKE_CAP_ROUND;
+          if (prev_first != gps->caps[0] || prev_last != gps->caps[1]) {
+            changed = true;
+          }
         }
-      }
-      if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_END)) {
-        ++gps->caps[1];
-        if (gps->caps[1] >= GP_STROKE_CAP_MAX) {
-          gps->caps[1] = GP_STROKE_CAP_ROUND;
+        /* If not multi-edit, exit loop. */
+        if (!is_multiedit) {
+          break;
         }
       }
-      if (type == GP_STROKE_CAPS_TOGGLE_DEFAULT) {
-        gps->caps[0] = GP_STROKE_CAP_ROUND;
-        gps->caps[1] = GP_STROKE_CAP_ROUND;
-      }
-
-      if (prev_first != gps->caps[0] || prev_last != gps->caps[1]) {
-        changed = true;
-      }
     }
   }
   CTX_DATA_END;
@@ -3550,9 +3562,9 @@ static int gpencil_stroke_join_exec(bContext *C, wmOperator *op)
   bGPdata *gpd = ED_gpencil_data_get_active(C);
   bGPDlayer *activegpl = BKE_gpencil_layer_active_get(gpd);
   Object *ob = CTX_data_active_object(C);
-  /* Limit the number of strokes to join. It makes no sense to allow an very high number of strokes
-   * for CPU time and because to have a stroke with thousands of points is unpractical, so limit
-   * this number avoid to joining a full frame scene in one single stroke. */
+  /* Limit the number of strokes to join. It makes no sense to allow an very high number of
+   * strokes for CPU time and because to have a stroke with thousands of points is unpractical,
+   * so limit this number avoid to joining a full frame scene in one single stroke. */
   const int max_join_strokes = 128;
 
   const int type = RNA_enum_get(op->ptr, "type");



More information about the Bf-blender-cvs mailing list