[Bf-blender-cvs] [746af98b002] blender-v3.3-release: Fix T102992: GPencil Array doesn't respect restriction in Offset

frogstomp noreply at git.blender.org
Thu Jan 12 15:31:55 CET 2023


Commit: 746af98b0022894ae352b2d9b3e8c356f80d92aa
Author: frogstomp
Date:   Fri Dec 9 16:27:52 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB746af98b0022894ae352b2d9b3e8c356f80d92aa

Fix T102992: GPencil Array doesn't respect restriction in Offset

The problem was the bounding box was calculated using
all strokes, but if a filter is added, the bounding box must
include only selected strokes.

Fix by @frogstomp

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

M	source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c

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

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
index 8bb61136cc2..6a25b301c6e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
@@ -113,7 +113,45 @@ static void BKE_gpencil_instance_modifier_instance_tfm(Object *ob,
     zero_v3(r_mat[3]);
   }
 }
+static bool gpencil_data_selected_minmax(ArrayGpencilModifierData *mmd,
+                                         Object *ob,
+                                         float r_min[3],
+                                         float r_max[3])
+{
+  bGPdata *gpd = (bGPdata *)ob->data;
+  bool changed = false;
+
+  INIT_MINMAX(r_min, r_max);
+
+  if (gpd == NULL) {
+    return changed;
+  }
+
+  LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+    bGPDframe *gpf = gpl->actframe;
+
+    if (gpf != NULL) {
+      LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+        if (is_stroke_affected_by_modifier(ob,
+                                           mmd->layername,
+                                           mmd->material,
+                                           mmd->pass_index,
+                                           mmd->layer_pass,
+                                           1,
+                                           gpl,
+                                           gps,
+                                           mmd->flag & GP_ARRAY_INVERT_LAYER,
+                                           mmd->flag & GP_ARRAY_INVERT_PASS,
+                                           mmd->flag & GP_ARRAY_INVERT_LAYERPASS,
+                                           mmd->flag & GP_ARRAY_INVERT_MATERIAL)) {
+          changed |= BKE_gpencil_stroke_minmax(gps, false, r_min, r_max);
+        }
+      }
+    }
+  }
 
+  return changed;
+}
 /* array modifier - generate geometry callback (for viewport/rendering) */
 static void generate_geometry(GpencilModifierData *md,
                               Depsgraph *depsgraph,
@@ -131,7 +169,7 @@ static void generate_geometry(GpencilModifierData *md,
   if (mmd->flag & GP_ARRAY_USE_RELATIVE) {
     float min[3];
     float max[3];
-    if (BKE_gpencil_data_minmax(gpd, min, max)) {
+    if (gpencil_data_selected_minmax(mmd, ob, min, max)) {
       sub_v3_v3v3(size, max, min);
       /* Need a minimum size (for flat drawings). */
       CLAMP3_MIN(size, 0.01f);



More information about the Bf-blender-cvs mailing list