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.
This commit is contained in:
parent
a8a92cd15a
commit
a478d502dd
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue