From b6e3430417d69d20ebca107fa23f058f65de6092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 15 May 2018 17:16:20 +0200 Subject: Modifiers on Lattices now work Tested with Hook and Armature modifiers. Requires CoW to be enabled. --- source/blender/blenkernel/intern/lattice.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern/lattice.c') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 7a821483fee..3257b20291d 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -65,6 +65,8 @@ #include "BKE_deform.h" +#include "DEG_depsgraph_query.h" + int BKE_lattice_index_from_uvw(Lattice *lt, const int u, const int v, const int w) { @@ -1022,6 +1024,8 @@ void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]) void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Object *ob) { Lattice *lt = ob->data; + /* Get vertex coordinates from the original copy; otherwise we get already-modified coordinates. */ + Object *orig_ob = DEG_get_original_object(ob); VirtualModifierData virtualModifierData; ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData); float (*vertexCos)[3] = NULL; @@ -1046,14 +1050,20 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec if (mti->isDisabled && mti->isDisabled(md, 0)) continue; if (mti->type != eModifierTypeType_OnlyDeform) continue; - if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts); + if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(orig_ob, &numVerts); modifier_deformVerts_DM_deprecated(md, &mectx, NULL, vertexCos, numVerts); } - /* always displist to make this work like derivedmesh */ - if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts); - - { + if (ob->id.tag & LIB_TAG_COPY_ON_WRITE) { + if (vertexCos) { + BKE_lattice_vertexcos_apply(ob, vertexCos); + MEM_freeN(vertexCos); + } + } + else { + /* Displist won't do anything; this is just for posterity's sake until we remove it. */ + if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(orig_ob, &numVerts); + DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl"); dl->type = DL_VERTS; dl->parts = 1; -- cgit v1.2.3