diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-10-03 11:06:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-10-03 11:06:56 +0400 |
commit | 5b5bc633960727279ebeaad2d1a48093f71c3984 (patch) | |
tree | 872f25987963d38ecbcf509b55ed662bb6503844 /source/blender/bmesh/intern/bmesh_iterators.c | |
parent | 4cb4dc8432922413e40e0b8b93dc06e5710693de (diff) |
fix [#36923] Merge / Delete vertices crashes for some meshes
add BM_ITER_MESH_MUTABLE which steps before entering the for() loop body and prevents the assert from complaining about removing mesh data while iterating as well as the crash.
this was done in quite a few areas, more may turn up.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_iterators.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index cc5e4933d39..6449a6e6d35 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -54,6 +54,31 @@ const char bm_iter_itype_htype_map[BM_ITYPE_MAX] = { }; /** + * Utility function. + */ +int BM_iter_mesh_count(BMesh *bm, const char itype) +{ + int count; + + switch (itype) { + case BM_VERTS_OF_MESH: + count = bm->totvert; + break; + case BM_EDGES_OF_MESH: + count = bm->totedge; + break; + case BM_FACES_OF_MESH: + count = bm->totface; + break; + default: + count = 0; + BLI_assert(0); + } + + return count; +} + +/** * \note Use #BM_vert_at_index / #BM_edge_at_index / #BM_face_at_index for mesh arrays. */ void *BM_iter_at_index(BMesh *bm, const char itype, void *data, int index) |