From c8be3d3b27d49a86772b1bc970fb5f5f79b891b4 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Wed, 13 Jul 2022 12:56:48 +0200 Subject: 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. --- source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender/gpencil_modifiers') 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); } } -- cgit v1.2.3