diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-07-13 09:51:06 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-07-13 10:10:30 +0300 |
commit | f9c9e000ca42c8cc169dec22c702904944ee2513 (patch) | |
tree | c70e60976aacb83926ca61dc842308073e63f0f3 /source/blender/editors/mesh | |
parent | 7a4fc9f59d8d1c0ff5f53c2ecba24d3ffa9022b9 (diff) |
Undo: optimize edit-mode undo
- Tag the object data instead of the object when decoding
(this avoids duplicating mesh object-data on each undo-step).
- Calculate face normals as part of multi-threaded tessellation.
This gives ~11% speedup with 1.5x million polygons.
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh_undo.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c index 613c58e87c8..7a89dbd831d 100644 --- a/source/blender/editors/mesh/editmesh_undo.c +++ b/source/blender/editors/mesh/editmesh_undo.c @@ -681,14 +681,20 @@ static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em, Key * BM_mesh_bm_from_me(bm, &um->me, (&(struct BMeshFromMeshParams){ - .calc_face_normal = true, + /* Handled with tessellation. */ + .calc_face_normal = false, .active_shapekey = um->shapenr, })); em_tmp = BKE_editmesh_create(bm); *em = *em_tmp; - BKE_editmesh_looptri_calc(em); + /* 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. */ + BKE_editmesh_looptri_calc_ex(em, + &(const struct BMeshCalcTessellation_Params){ + .face_normals = true, + }); em->selectmode = um->selectmode; bm->selectmode = um->selectmode; @@ -867,7 +873,7 @@ static void mesh_undosys_step_decode(struct bContext *C, BMEditMesh *em = me->edit_mesh; undomesh_to_editmesh(&elem->data, obedit, em, me->key); em->needs_flush_to_id = 1; - DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY); + DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY); } /* The first element is always active */ |