BMesh: skip partial updates when there is nothing to do

This commit is contained in:
Campbell Barton
2021-06-26 16:55:14 +10:00
parent 3826fcf035
commit a287c8d3c1
2 changed files with 8 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);