diff options
author | YimingWu <xp8110@outlook.com> | 2021-07-04 08:23:52 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2021-07-04 08:23:52 +0300 |
commit | 442f269a72e8f07393fd246f642e210171a1c9bc (patch) | |
tree | ecab515215209172245f7709a0c07c1b14dab96c /source/blender/bmesh/intern/bmesh_mesh_normals.c | |
parent | 87dae08dd3f2a80dd208576b130cabaca21c9912 (diff) | |
parent | 2d146b61d8583ec7169c5c04263d475a542b06ce (diff) |
Merge remote-tracking branch 'origin/master' into lineart-bvh
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_mesh_normals.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_normals.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.c b/source/blender/bmesh/intern/bmesh_mesh_normals.c index bddd3da98b7..6ab7b8a2057 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_normals.c +++ b/source/blender/bmesh/intern/bmesh_mesh_normals.c @@ -18,6 +18,8 @@ * \ingroup bmesh * * BM mesh normal calculation functions. + * + * \see mesh_normals.c for the equivalent #Mesh functionality. */ #include "MEM_guardedalloc.h" @@ -65,8 +67,8 @@ BLI_INLINE void bm_vert_calc_normals_accum_loop(const BMLoop *l_iter, float v_no[3]) { /* Calculate the dot product of the two edges that meet at the loop's vertex. */ - /* Edge vectors are calculated from e->v1 to e->v2, so adjust the dot product if one but not - * both loops actually runs from from e->v2 to e->v1. */ + /* Edge vectors are calculated from `e->v1` to `e->v2`, so adjust the dot product if one but not + * both loops actually runs from `e->v2` to `e->v1`. */ float dotprod = dot_v3v3(e1diff, e2diff); if ((l_iter->prev->e->v1 == l_iter->prev->v) ^ (l_iter->e->v1 == l_iter->v)) { dotprod = -dotprod; @@ -292,6 +294,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; @@ -1542,7 +1548,7 @@ static int bm_loop_normal_mark_indiv(BMesh *bm, BLI_bitmap *loops, const bool do /* Using face history allows to select a single loop from a single face... * Note that this is O(n^2) piece of code, * but it is not designed to be used with huge selection sets, - * rather with only a few items selected at most.*/ + * rather with only a few items selected at most. */ /* Goes from last selected to the first selected element. */ for (ese = bm->selected.last; ese; ese = ese->prev) { if (ese->htype == BM_FACE) { |