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:
authorHans Goudey <h.goudey@me.com>2022-01-22 01:14:00 +0300
committerHans Goudey <h.goudey@me.com>2022-01-22 01:14:00 +0300
commitd590e223daf6e20d462f2b197d32606d69873051 (patch)
treeef46b85d1745a8d62dcdb30b637bf0ab36fd44d5
parent68aa35ae74226fbed936b1879302fc155d9acfac (diff)
Fix T94974: Invalid normals in edit mode
Normal layers currently aren't stored in the undo step mesh storage, since they are not stored in files at all. However, the edit mesh expects normals to be fully calculated, and does not keep track of a dirty state. This patch updates the normals in the BMesh created by loading an undo step. Another option would be calculating the normals on the undo mesh first, which might be better if Mesh normal calculation is faster than BMesh calculation, but the preferred method to access vertex normals fails in this case, because the mesh runtime mutexes are not initialized for undo-state meshes. Differential Revision: https://developer.blender.org/D13859
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index 46a056f865b..5d573271ea3 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -687,11 +687,15 @@ static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em, Key *
.active_shapekey = um->shapenr,
}));
+ /* Normals should not be stored in the undo mesh, so recalculate them. The edit
+ * mesh is expected to have valid normals and there is no tracked dirty state. */
+ BLI_assert(BKE_mesh_vertex_normals_are_dirty(&um->me));
+ BM_mesh_normals_update(bm);
+
em_tmp = BKE_editmesh_create(bm);
*em = *em_tmp;
- /* Calculate face normals and tessellation at once since it's multi-threaded.
- * The vertex normals are stored in the undo-mesh, so this doesn't need to be updated. */
+ /* Calculate face normals and tessellation at once since it's multi-threaded. */
BKE_editmesh_looptri_calc_ex(em,
&(const struct BMeshCalcTessellation_Params){
.face_normals = true,