[Bf-blender-cvs] [b6e3430417d] blender2.8: Modifiers on Lattices now work

Sybren A. Stüvel noreply at git.blender.org
Tue May 15 17:18:10 CEST 2018


Commit: b6e3430417d69d20ebca107fa23f058f65de6092
Author: Sybren A. Stüvel
Date:   Tue May 15 17:16:20 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBb6e3430417d69d20ebca107fa23f058f65de6092

Modifiers on Lattices now work

Tested with Hook and Armature modifiers. Requires CoW to be enabled.

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

M	source/blender/blenkernel/intern/lattice.c
M	source/blender/draw/intern/draw_cache_impl_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;
diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c
index 1cb55039b16..6b0a35c3341 100644
--- a/source/blender/draw/intern/draw_cache_impl_lattice.c
+++ b/source/blender/draw/intern/draw_cache_impl_lattice.c
@@ -315,8 +315,8 @@ static bool lattice_batch_cache_valid(Lattice *lt)
 		return false;
 	}
 
-	if (cache->is_dirty == false) {
-		return true;
+	if (cache->is_dirty) {
+		return false;
 	}
 	else {
 		if (cache->is_editmode) {



More information about the Bf-blender-cvs mailing list