diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-26 09:55:14 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-26 09:55:14 +0300 |
commit | a287c8d3c160ba448424905a201c75fd97f9182a (patch) | |
tree | 06b823a43b76dbdf59b4c37943c8886ecc7f797c /source/blender/bmesh | |
parent | 3826fcf035818009594435c7917ad3cd967298c1 (diff) |
BMesh: skip partial updates when there is nothing to do
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_normals.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_tessellate.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.c b/source/blender/bmesh/intern/bmesh_mesh_normals.c index bddd3da98b7..3e3fa2a2d9d 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_normals.c +++ b/source/blender/bmesh/intern/bmesh_mesh_normals.c @@ -292,6 +292,10 @@ void BM_mesh_normals_update_with_partial_ex(BMesh *UNUSED(bm), const struct BMeshNormalsUpdate_Params *params) { BLI_assert(bmpinfo->params.do_normals); + /* While harmless, exit early if there is nothing to do. */ + if (UNLIKELY((bmpinfo->verts_len == 0) && (bmpinfo->faces_len == 0))) { + return; + } BMVert **verts = bmpinfo->verts; BMFace **faces = bmpinfo->faces; diff --git a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c index c9b027474e1..9f477bc8a9c 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c @@ -406,6 +406,10 @@ void BM_mesh_calc_tessellation_with_partial_ex(BMesh *bm, const struct BMeshCalcTessellation_Params *params) { BLI_assert(bmpinfo->params.do_tessellate); + /* While harmless, exit early if there is nothing to do (avoids ensuring the index). */ + if (UNLIKELY(bmpinfo->faces_len == 0)) { + return; + } BM_mesh_elem_index_ensure(bm, BM_LOOP | BM_FACE); |