diff options
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index 4555de7b13d..cc5e4933d39 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -304,36 +304,66 @@ int BM_iter_mesh_count_flag(const char itype, BMesh *bm, const char hflag, const * VERT OF MESH CALLBACKS */ +/* see bug [#36923] for why we need this, + * allow adding but not removing, this isnt _totally_ safe since + * you could add/remove within the same loop, but catches common cases + */ +#ifdef DEBUG +# define USE_IMMUTABLE_ASSERT +#endif + void bmiter__vert_of_mesh_begin(struct BMIter__vert_of_mesh *iter) { +#ifdef USE_IMMUTABLE_ASSERT + ((BMIter *)iter)->count = iter->bm->totvert; +#endif BLI_mempool_iternew(iter->bm->vpool, &iter->pooliter); } void *bmiter__vert_of_mesh_step(struct BMIter__vert_of_mesh *iter) { +#ifdef USE_IMMUTABLE_ASSERT + BLI_assert(((BMIter *)iter)->count <= iter->bm->totvert); +#endif return BLI_mempool_iterstep(&iter->pooliter); } void bmiter__edge_of_mesh_begin(struct BMIter__edge_of_mesh *iter) { +#ifdef USE_IMMUTABLE_ASSERT + ((BMIter *)iter)->count = iter->bm->totedge; +#endif BLI_mempool_iternew(iter->bm->epool, &iter->pooliter); } void *bmiter__edge_of_mesh_step(struct BMIter__edge_of_mesh *iter) { +#ifdef USE_IMMUTABLE_ASSERT + BLI_assert(((BMIter *)iter)->count <= iter->bm->totedge); +#endif return BLI_mempool_iterstep(&iter->pooliter); } void bmiter__face_of_mesh_begin(struct BMIter__face_of_mesh *iter) { +#ifdef USE_IMMUTABLE_ASSERT + ((BMIter *)iter)->count = iter->bm->totface; +#endif BLI_mempool_iternew(iter->bm->fpool, &iter->pooliter); } void *bmiter__face_of_mesh_step(struct BMIter__face_of_mesh *iter) { +#ifdef USE_IMMUTABLE_ASSERT + BLI_assert(((BMIter *)iter)->count <= iter->bm->totface); +#endif return BLI_mempool_iterstep(&iter->pooliter); } +#ifdef USE_IMMUTABLE_ASSERT +# undef USE_IMMUTABLE_ASSERT +#endif + /* * EDGE OF VERT CALLBACKS */ |