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:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-12-04 19:52:30 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-12-04 19:53:14 +0300
commit34b73cb11ce50f2afefabec32aadb9a853eec177 (patch)
tree7d72ac63c5cc36af232f8c983fc0fec29f33e03d /source/blender/blenkernel/intern/DerivedMesh.c
parent7e5f31be418d75fa0aa5116a2720a6b7e988f9e4 (diff)
Fix T57620: display custom normals in Edit Mode.
Since it seems that CD_ORIGINDEX is not available for loops, the only choice is to simply use the loop normals already computed by depsgraph after evaluating modifiers. This revealed a bug where the Auto Smooth settings would be lost from the mesh after complex modifiers, or after edit mesh to mesh conversion, so restoring them is needed to get correct results.
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.c')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index de2cd5603a6..abad99a4909 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1151,6 +1151,14 @@ static void add_shapekey_layers(Mesh *me_dst, Mesh *me_src, Object *UNUSED(ob))
}
}
+static void mesh_copy_autosmooth(Mesh *me, Mesh *me_orig)
+{
+ if (me_orig->flag & ME_AUTOSMOOTH) {
+ me->flag |= ME_AUTOSMOOTH;
+ me->smoothresh = me_orig->smoothresh;
+ }
+}
+
static void mesh_calc_modifiers(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
int useDeform,
@@ -1460,6 +1468,8 @@ static void mesh_calc_modifiers(
}
deformedVerts = NULL;
}
+
+ mesh_copy_autosmooth(me, ob->data);
}
/* create an orco mesh in parallel */
@@ -1693,6 +1703,7 @@ static void editbmesh_calc_modifiers(
if (r_cage && cageIndex == -1) {
*r_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, dataMask, NULL);
+ mesh_copy_autosmooth(*r_cage, ob->data);
}
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -1769,6 +1780,8 @@ static void editbmesh_calc_modifiers(
me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
ASSERT_IS_VALID_MESH(me);
+ mesh_copy_autosmooth(me, ob->data);
+
if (deformedVerts) {
BKE_mesh_apply_vert_coords(me, deformedVerts);
}
@@ -1822,6 +1835,8 @@ static void editbmesh_calc_modifiers(
MEM_freeN(deformedVerts);
deformedVerts = NULL;
}
+
+ mesh_copy_autosmooth(me, ob->data);
}
me->runtime.deformed_only = false;
}
@@ -1843,6 +1858,7 @@ static void editbmesh_calc_modifiers(
*r_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(
em, mask,
deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
+ mesh_copy_autosmooth(*r_cage, ob->data);
}
}
}
@@ -1878,6 +1894,8 @@ static void editbmesh_calc_modifiers(
*r_final = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, dataMask, deformedVerts);
deformedVerts = NULL;
+ mesh_copy_autosmooth(*r_final, ob->data);
+
/* In this case, we should never have weight-modifying modifiers in stack... */
if (do_init_statvis) {
editmesh_update_statvis_color(scene, ob);
@@ -1916,6 +1934,10 @@ static void editbmesh_calc_modifiers(
if (!do_loop_normals) {
BKE_mesh_ensure_normals_for_display(*r_final);
+ if (r_cage && *r_cage && (*r_cage != *r_final)) {
+ BKE_mesh_ensure_normals_for_display(*r_cage);
+ }
+
/* Some modifiers, like datatransfer, may generate those data, we do not want to keep them,
* as they are used by display code when available (i.e. even if autosmooth is disabled). */
if (CustomData_has_layer(&(*r_final)->ldata, CD_NORMAL)) {