[Bf-blender-cvs] [a478d502dd2] master: GPencil: Fix unreported crash when apply Lattice modifier

Antonio Vazquez noreply at git.blender.org
Wed Mar 24 16:01:55 CET 2021


Commit: a478d502dd2512a63657818e19ee2b74c1848bec
Author: Antonio Vazquez
Date:   Wed Mar 24 16:01:44 2021 +0100
Branches: master
https://developer.blender.org/rBa478d502dd2512a63657818e19ee2b74c1848bec

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.

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

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

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

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



More information about the Bf-blender-cvs mailing list