diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2022-07-13 13:56:48 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2022-07-13 13:56:48 +0300 |
commit | c8be3d3b27d49a86772b1bc970fb5f5f79b891b4 (patch) | |
tree | f5e880a266d0422d260968c2c27194111ce2828c | |
parent | 74888cdbfd523d70ea0573e4452bf65c25b3a888 (diff) |
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.
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c | 12 |
1 files changed, 9 insertions, 3 deletions
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); } } |