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.
This commit is contained in:
Antonio Vazquez 2022-07-13 12:56:48 +02:00
parent 74888cdbfd
commit c8be3d3b27
Notes: blender-bot 2023-06-21 19:23:24 +02:00
Referenced by issue #99654, GPencil: Applying Mirror modifier breaks the erase tool
1 changed files with 9 additions and 3 deletions

View File

@ -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);
}
}