Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2021-03-24 18:01:44 +0300
committerAntonio Vazquez <blendergit@gmail.com>2021-03-24 18:01:44 +0300
commita478d502dd2512a63657818e19ee2b74c1848bec (patch)
tree69035df40f6de05302f05bf1b0f59059eebb3037
parenta8a92cd15a5251377474fbfdcf9ff0298a8457a9 (diff)
GPencil: Fix unreported crash when apply Lattice modifier
This error was produced because now it is possible to have several Lattice modifiers and the Bake was removing the lattice data of all modifiers. Now the data is only recalculated and removed for the current modifier. Also some cleanup of comments.
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
index 4efc1d9eaae..2934b89c747 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
@@ -136,36 +136,39 @@ static void bakeModifier(Main *UNUSED(bmain),
bGPdata *gpd = ob->data;
int oldframe = (int)DEG_get_ctime(depsgraph);
- if (mmd->object == NULL) {
+ if ((mmd->object == NULL) || (mmd->object->type != OB_LATTICE)) {
return;
}
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
- /* apply lattice effects on this frame
- * NOTE: this assumes that we don't want lattice animation on non-keyframed frames
+ /* Apply lattice effects on this frame
+ * NOTE: this assumes that we don't want lattice animation on non-keyframed frames.
*/
CFRA = gpf->framenum;
BKE_scene_graph_update_for_newframe(depsgraph);
- /* recalculate lattice data */
- BKE_gpencil_lattice_init(ob);
+ /* Recalculate lattice data. */
+ if (mmd->cache_data) {
+ BKE_lattice_deform_data_destroy(mmd->cache_data);
+ }
+ mmd->cache_data = BKE_lattice_deform_data_create(mmd->object, ob);
- /* compute lattice effects on this frame */
+ /* Compute lattice effects on this frame. */
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
deformStroke(md, depsgraph, ob, gpl, gpf, gps);
}
}
}
- /* free lingering data */
+ /* Free lingering data. */
ldata = (struct LatticeDeformData *)mmd->cache_data;
if (ldata) {
BKE_lattice_deform_data_destroy(ldata);
mmd->cache_data = NULL;
}
- /* return frame state and DB to original state */
+ /* Return frame state and DB to original state. */
CFRA = oldframe;
BKE_scene_graph_update_for_newframe(depsgraph);
}