[Bf-blender-cvs] [c8be3d3b27d] master: Fix T99654: Applying Mirror modifier breaks the erase tool

Antonio Vazquez noreply at git.blender.org
Wed Jul 13 12:56:26 CEST 2022


Commit: c8be3d3b27d49a86772b1bc970fb5f5f79b891b4
Author: Antonio Vazquez
Date:   Wed Jul 13 12:56:48 2022 +0200
Branches: master
https://developer.blender.org/rBc8be3d3b27d49a86772b1bc970fb5f5f79b891b4

Fix T99654: Applying Mirror modifier breaks the erase tool

The problem was the new generated strokes were copied from original and the location was offset to mirror, but the internal geometry data was not updated and the collision check done by brushes was not working.

Now, the internal geometry data is recalculated when the modifier is applied.

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

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

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

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
index 1d62e930caa..1a8d1e75746 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
@@ -23,6 +23,7 @@
 
 #include "BKE_context.h"
 #include "BKE_gpencil.h"
+#include "BKE_gpencil_geom.h"
 #include "BKE_gpencil_modifier.h"
 #include "BKE_lib_query.h"
 #include "BKE_main.h"
@@ -100,9 +101,11 @@ static void update_position(Object *ob, MirrorGpencilModifierData *mmd, bGPDstro
   }
 }
 
-static void generate_geometry(GpencilModifierData *md, Object *ob, bGPDlayer *gpl, bGPDframe *gpf)
+static void generate_geometry(
+    GpencilModifierData *md, Object *ob, bGPDlayer *gpl, bGPDframe *gpf, const bool update)
 {
   MirrorGpencilModifierData *mmd = (MirrorGpencilModifierData *)md;
+  bGPdata *gpd = ob->data;
   bGPDstroke *gps, *gps_new = NULL;
   int tot_strokes;
   int i;
@@ -129,6 +132,9 @@ static void generate_geometry(GpencilModifierData *md, Object *ob, bGPDlayer *gp
                                            mmd->flag & GP_MIRROR_INVERT_MATERIAL)) {
           gps_new = BKE_gpencil_stroke_duplicate(gps, true, true);
           update_position(ob, mmd, gps_new, xi);
+          if (update) {
+            BKE_gpencil_stroke_geometry_update(gpd, gps_new);
+          }
           BLI_addtail(&gpf->strokes, gps_new);
         }
       }
@@ -147,7 +153,7 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec
     if (gpf == NULL) {
       continue;
     }
-    generate_geometry(md, ob, gpl, gpf);
+    generate_geometry(md, ob, gpl, gpf, false);
   }
 }
 
@@ -167,7 +173,7 @@ static void bakeModifier(Main *UNUSED(bmain),
       BKE_scene_graph_update_for_newframe(depsgraph);
 
       /* compute mirror effects on this frame */
-      generate_geometry(md, ob, gpl, gpf);
+      generate_geometry(md, ob, gpl, gpf, true);
     }
   }



More information about the Bf-blender-cvs mailing list