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:
authorBastien Montagne <montagne29@wanadoo.fr>2019-03-18 17:37:46 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-03-18 17:50:12 +0300
commitc5fe6ed96bd1e6a20253bbeb2a20e4944781787a (patch)
tree519296a911ce6df330671fc46ede25853657c20b
parentb7255d33dacabf93e0ed79425a5b54ad835d7ff5 (diff)
Fix T62633: Model normals not updating in a modifier stack after a deform modifier.
A deform-only modifier that needs access to normals need a copy of evaluated mesh with those normals updated, when it is not the first one in the stack. That issue had been partially fixed in Object mode a long time ago (see T23673), but it was still broken for deform-only stacks cases. And it was also completely missing from the Edit mode code (`editbmesh_calc_modifiers()` function).
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index cdcb64fb094..86ec491b43e 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1221,6 +1221,10 @@ static void mesh_calc_modifiers(
}
*r_final = NULL;
+ /* We need mesh even for deform-only part of the stack, in cases where some modifier needs
+ * e.g. access to updated normals. See T62633 for an example. */
+ Mesh *me = NULL;
+
if (useDeform) {
if (inputVertexCos)
deformedVerts = inputVertexCos;
@@ -1238,10 +1242,21 @@ static void mesh_calc_modifiers(
}
if (mti->type == eModifierTypeType_OnlyDeform && !sculpt_dyntopo) {
- if (!deformedVerts)
+ if (!deformedVerts) {
deformedVerts = BKE_mesh_vertexCos_get(ob->data, &numVerts);
+ }
+
+ if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
+ if (me == NULL) {
+ me = BKE_mesh_copy_for_eval(ob->data, true);
+ ASSERT_IS_VALID_MESH(me);
+ }
+ BKE_mesh_apply_vert_coords(me, deformedVerts);
+ }
+
+ modwrap_deformVerts(md, &mectx_deform, me, deformedVerts, numVerts);
- modwrap_deformVerts(md, &mectx_deform, NULL, deformedVerts, numVerts);
+ isPrevDeform = true;
}
else {
break;
@@ -1282,7 +1297,6 @@ static void mesh_calc_modifiers(
/* Now apply all remaining modifiers. If useDeform is off then skip
* OnlyDeform ones.
*/
- Mesh *me = NULL;
Mesh *me_orco = NULL;
Mesh *me_orco_cloth = NULL;
@@ -1715,6 +1729,7 @@ static void editbmesh_calc_modifiers(
const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
const bool do_init_statvis = false; /* FIXME: use V3D_OVERLAY_EDIT_STATVIS. */
VirtualModifierData virtualModifierData;
+ bool isPrevDeform = false;
/* TODO(sybren): do we really need multiple objects, or shall we change the flags where needed? */
const ModifierEvalContext mectx = {depsgraph, ob, 0};
@@ -1779,6 +1794,16 @@ static void editbmesh_calc_modifiers(
}
}
+ if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
+ if (me == NULL) {
+ me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
+ ASSERT_IS_VALID_MESH(me);
+ mesh_copy_autosmooth(me, ob->data);
+ }
+ BLI_assert(deformedVerts != NULL);
+ BKE_mesh_apply_vert_coords(me, deformedVerts);
+ }
+
if (mti->deformVertsEM)
modwrap_deformVertsEM(md, &mectx, em, me, deformedVerts, numVerts);
else
@@ -1895,6 +1920,8 @@ static void editbmesh_calc_modifiers(
mesh_copy_autosmooth(*r_cage, ob->data);
}
}
+
+ isPrevDeform = (mti->type == eModifierTypeType_OnlyDeform);
}
BLI_linklist_free((LinkNode *)datamasks, NULL);