From 8a1860bd9aecddf611b64e3e842bdc8c76f15cc6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Jun 2021 22:56:03 +1000 Subject: BMesh: support face-normal calculation in normal & looptri functions Support calculating face normals when tessellating. When this is done before updating vertex normals it gives ~20% performance improvement. Now vertex normal calculation only needs to perform a single pass on the mesh vertices when called after tessellation. Extended versions of normal & looptri update functions have been added: - BM_mesh_calc_tessellation_ex - BM_mesh_normals_update_ex Most callers don't need to be aware of this detail by using: - BKE_editmesh_looptri_and_normals_calc - BKE_editmesh_looptri_and_normals_calc_with_partial - EDBM_update also takes advantage of this, where calling EDBM_update with calc_looptri & calc_normals enabled uses the faster normal updating logic. --- source/blender/editors/transform/transform_convert_mesh.c | 6 ++---- source/blender/editors/transform/transform_convert_mesh_skin.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/transform') diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 422370cb13b..4c674136b6a 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -1842,13 +1842,11 @@ void recalcData_mesh(TransInfo *t) * It's impractical to calculate this ahead of time. * Further, the down side of using partial updates when their not needed is negligible. */ if (em->bm->totvert == em->bm->totvertsel) { - EDBM_mesh_normals_update(em); - BKE_editmesh_looptri_calc(em); + BKE_editmesh_looptri_and_normals_calc(em); } else { BMPartialUpdate *partial_update_cache = tc_mesh_ensure_partial_update(t, tc); - BM_mesh_normals_update_with_partial(em->bm, partial_update_cache); - BKE_editmesh_looptri_calc_with_partial(em, partial_update_cache); + BKE_editmesh_looptri_and_normals_calc_with_partial(em, partial_update_cache); } } } diff --git a/source/blender/editors/transform/transform_convert_mesh_skin.c b/source/blender/editors/transform/transform_convert_mesh_skin.c index 7c61da31f72..69b44998980 100644 --- a/source/blender/editors/transform/transform_convert_mesh_skin.c +++ b/source/blender/editors/transform/transform_convert_mesh_skin.c @@ -300,8 +300,7 @@ void recalcData_mesh_skin(TransInfo *t) FOREACH_TRANS_DATA_CONTAINER (t, tc) { DEG_id_tag_update(tc->obedit->data, ID_RECALC_GEOMETRY); BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); - EDBM_mesh_normals_update(em); - BKE_editmesh_looptri_calc(em); + BKE_editmesh_looptri_and_normals_calc(em); } } /** \} */ -- cgit v1.2.3