diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/crazyspace.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_merge.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_validate.c | 11 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 16 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_meshdata_types.h | 1 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_screw.c | 29 |
6 files changed, 49 insertions, 34 deletions
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c index 573595b6f90..0bf83ed5036 100644 --- a/source/blender/blenkernel/intern/crazyspace.c +++ b/source/blender/blenkernel/intern/crazyspace.c @@ -194,13 +194,10 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me, float (*mappedcos)[3], float (*quats)[4]) { - MVert *mvert = me->mvert; - for (int i = 0; i < me->totvert; i++, mvert++) { - mvert->flag &= ~ME_VERT_TMP_TAG; - } + BLI_bitmap *vert_tag = BLI_BITMAP_NEW(me->totvert, __func__); /* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */ - mvert = me->mvert; + MVert *mvert = me->mvert; MPoly *mp = me->mpoly; MLoop *mloop = me->mloop; @@ -210,7 +207,7 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me, MLoop *ml_prev = &ml_next[mp->totloop - 2]; for (int j = 0; j < mp->totloop; j++) { - if ((mvert[ml_curr->v].flag & ME_VERT_TMP_TAG) == 0) { + if (!BLI_BITMAP_TEST(vert_tag, ml_curr->v)) { const float *co_prev, *co_curr, *co_next; /* orig */ const float *vd_prev, *vd_curr, *vd_next; /* deform */ @@ -233,7 +230,7 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me, set_crazy_vertex_quat( quats[ml_curr->v], co_curr, co_next, co_prev, vd_curr, vd_next, vd_prev); - mvert[ml_curr->v].flag |= ME_VERT_TMP_TAG; + BLI_BITMAP_ENABLE(vert_tag, ml_curr->v); } ml_prev = ml_curr; @@ -241,6 +238,8 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me, ml_next++; } } + + MEM_freeN(vert_tag); } int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgraph, diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c index 134a1344f83..3c01d5a4a50 100644 --- a/source/blender/blenkernel/intern/mesh_merge.c +++ b/source/blender/blenkernel/intern/mesh_merge.c @@ -27,6 +27,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "BLI_bitmap.h" #include "BLI_edgehash.h" #include "BLI_ghash.h" #include "BLI_utildefines.h" @@ -351,6 +352,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, &poly_map, &poly_map_mem, mesh->mpoly, mesh->mloop, totvert, totpoly, totloop); } /* done preparing for fast poly compare */ + BLI_bitmap *vert_tag = BLI_BITMAP_NEW(mesh->totvert, __func__); + mp = mesh->mpoly; mv = mesh->mvert; for (i = 0; i < totpoly; i++, mp++) { @@ -365,11 +368,11 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, if (vtargetmap[ml->v] == -1) { all_vertices_merged = false; /* This will be used to check for poly using several time the same vert. */ - mv[ml->v].flag &= ~ME_VERT_TMP_TAG; + BLI_BITMAP_DISABLE(vert_tag, ml->v); } else { /* This will be used to check for poly using several time the same vert. */ - mv[vtargetmap[ml->v]].flag &= ~ME_VERT_TMP_TAG; + BLI_BITMAP_DISABLE(vert_tag, vtargetmap[ml->v]); } } @@ -457,8 +460,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, #endif /* A loop is only valid if its matching edge is, * and it's not reusing a vertex already used by this poly. */ - if (LIKELY((newe[ml->e] != -1) && ((mv[mlv].flag & ME_VERT_TMP_TAG) == 0))) { - mv[mlv].flag |= ME_VERT_TMP_TAG; + if (LIKELY((newe[ml->e] != -1) && !BLI_BITMAP_TEST(vert_tag, mlv))) { + BLI_BITMAP_ENABLE(vert_tag, mlv); if (UNLIKELY(last_valid_ml != NULL && need_edge_from_last_valid_ml)) { /* We need to create a new edge between last valid loop and this one! */ @@ -644,6 +647,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, MEM_freeN(oldl); MEM_freeN(oldp); + MEM_freeN(vert_tag); + BLI_edgehash_free(ehash, NULL); if (poly_map != NULL) { diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 005c916b4e0..a5ba2767301 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -28,6 +28,7 @@ #include "CLG_log.h" +#include "BLI_bitmap.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" @@ -560,6 +561,8 @@ bool BKE_mesh_validate_arrays(Mesh *mesh, * so be sure to leave at most one poly per loop! */ { + BLI_bitmap *vert_tag = BLI_BITMAP_NEW(mesh->totvert, __func__); + SortPoly *sort_polys = MEM_callocN(sizeof(SortPoly) * totpoly, "mesh validate's sort_polys"); SortPoly *prev_sp, *sp = sort_polys; int prev_end; @@ -608,7 +611,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh, * so we have to ensure here all verts of current poly are cleared. */ for (j = 0, ml = &mloops[sp->loopstart]; j < mp->totloop; j++, ml++) { if (ml->v < totvert) { - mverts[ml->v].flag &= ~ME_VERT_TMP_TAG; + BLI_BITMAP_DISABLE(vert_tag, ml->v); } } @@ -619,12 +622,12 @@ bool BKE_mesh_validate_arrays(Mesh *mesh, PRINT_ERR("\tLoop %u has invalid vert reference (%u)", sp->loopstart + j, ml->v); sp->invalid = true; } - else if (mverts[ml->v].flag & ME_VERT_TMP_TAG) { + else if (BLI_BITMAP_TEST(vert_tag, ml->v)) { PRINT_ERR("\tPoly %u has duplicated vert reference at corner (%u)", i, j); sp->invalid = true; } else { - mverts[ml->v].flag |= ME_VERT_TMP_TAG; + BLI_BITMAP_ENABLE(vert_tag, ml->v); } *v = ml->v; } @@ -698,6 +701,8 @@ bool BKE_mesh_validate_arrays(Mesh *mesh, } } + MEM_freeN(vert_tag); + /* Second check pass, testing polys using the same verts. */ qsort(sort_polys, totpoly, sizeof(SortPoly), search_poly_cmp); sp = prev_sp = sort_polys; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 3e74aaeeb10..e21e815b56f 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -39,6 +39,7 @@ #include "BLI_alloca.h" #include "BLI_array.h" +#include "BLI_bitmap.h" #include "BLI_blenlib.h" #include "BLI_listbase.h" #include "BLI_math.h" @@ -2464,17 +2465,14 @@ void ED_vgroup_mirror(Object *ob, sel = sel_mirr = true; } - /* tag verts we have used */ - for (vidx = 0, mv = me->mvert; vidx < me->totvert; vidx++, mv++) { - mv->flag &= ~ME_VERT_TMP_TAG; - } + BLI_bitmap *vert_tag = BLI_BITMAP_NEW(me->totvert, __func__); for (vidx = 0, mv = me->mvert; vidx < me->totvert; vidx++, mv++) { - if ((mv->flag & ME_VERT_TMP_TAG) == 0) { + if (!BLI_BITMAP_TEST(vert_tag, vidx)) { if ((vidx_mirr = mesh_get_x_mirror_vert(ob, NULL, vidx, use_topology)) != -1) { if (vidx != vidx_mirr) { mv_mirr = &me->mvert[vidx_mirr]; - if ((mv_mirr->flag & ME_VERT_TMP_TAG) == 0) { + if (!BLI_BITMAP_TEST(vert_tag, vidx_mirr)) { if (use_vert_sel) { sel = mv->flag & SELECT; @@ -2489,8 +2487,8 @@ void ED_vgroup_mirror(Object *ob, totmirr++; } - mv->flag |= ME_VERT_TMP_TAG; - mv_mirr->flag |= ME_VERT_TMP_TAG; + BLI_BITMAP_ENABLE(vert_tag, vidx); + BLI_BITMAP_ENABLE(vert_tag, vidx_mirr); } } } @@ -2499,6 +2497,8 @@ void ED_vgroup_mirror(Object *ob, } } } + + MEM_freeN(vert_tag); } } else if (ob->type == OB_LATTICE) { diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 22c523901c0..b0276d010a4 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -48,7 +48,6 @@ typedef struct MVert { /** #MVert.flag */ enum { /* SELECT = (1 << 0), */ - ME_VERT_TMP_TAG = (1 << 2), ME_HIDE = (1 << 4), ME_VERT_FACEDOT = (1 << 5), /* ME_VERT_MERGED = (1 << 6), */ diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index f5db3bced7a..682dccd268d 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -27,6 +27,7 @@ #include "BLI_utildefines.h" #include "BLI_alloca.h" +#include "BLI_bitmap.h" #include "BLI_math.h" #include "BLT_translation.h" @@ -134,6 +135,8 @@ static Mesh *mesh_remove_doubles_on_axis(Mesh *result, const float axis_offset[3], const float merge_threshold) { + BLI_bitmap *vert_tag = BLI_BITMAP_NEW(totvert, __func__); + const float merge_threshold_sq = square_f(merge_threshold); const bool use_offset = axis_offset != NULL; uint tot_doubles = 0; @@ -150,13 +153,10 @@ static Mesh *mesh_remove_doubles_on_axis(Mesh *result, } const float dist_sq = len_squared_v3v3(axis_co, mvert_new[i].co); if (dist_sq <= merge_threshold_sq) { - mvert_new[i].flag |= ME_VERT_TMP_TAG; + BLI_BITMAP_ENABLE(vert_tag, i); tot_doubles += 1; copy_v3_v3(mvert_new[i].co, axis_co); } - else { - mvert_new[i].flag &= ~ME_VERT_TMP_TAG & 0xFF; - } } if (tot_doubles != 0) { @@ -166,7 +166,7 @@ static Mesh *mesh_remove_doubles_on_axis(Mesh *result, uint tot_doubles_left = tot_doubles; for (uint i = 0; i < totvert; i += 1) { - if (mvert_new[i].flag & ME_VERT_TMP_TAG) { + if (BLI_BITMAP_TEST(vert_tag, i)) { int *doubles_map = &full_doubles_map[totvert + i]; for (uint step = 1; step < step_tot; step += 1) { *doubles_map = (int)i; @@ -184,6 +184,9 @@ static Mesh *mesh_remove_doubles_on_axis(Mesh *result, MESH_MERGE_VERTS_DUMP_IF_MAPPED); MEM_freeN(full_doubles_map); } + + MEM_freeN(vert_tag); + return result; } @@ -439,6 +442,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * mv_new = mvert_new; mv_orig = mvert_orig; + BLI_bitmap *vert_tag = BLI_BITMAP_NEW(totvert, __func__); + /* Copy the first set of edges */ med_orig = medge_orig; med_new = medge_new; @@ -447,10 +452,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * med_new->v2 = med_orig->v2; med_new->crease = med_orig->crease; med_new->flag = med_orig->flag & ~ME_LOOSEEDGE; - /* Tag mvert as not loose. - * NOTE: ME_VERT_TMP_TAG is given to be cleared by BKE_mesh_new_nomain_from_template. */ - mvert_new[med_orig->v1].flag |= ME_VERT_TMP_TAG; - mvert_new[med_orig->v2].flag |= ME_VERT_TMP_TAG; + + /* Tag mvert as not loose. */ + BLI_BITMAP_ENABLE(vert_tag, med_orig->v1); + BLI_BITMAP_ENABLE(vert_tag, med_orig->v1); } /* build polygon -> edge map */ @@ -910,7 +915,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * med_new->v1 = varray_stride + j; med_new->v2 = med_new->v1 - totvert; med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; - if ((mv_new_base->flag & ME_VERT_TMP_TAG) == 0) { + if (!BLI_BITMAP_TEST(vert_tag, j)) { med_new->flag |= ME_LOOSEEDGE; } med_new++; @@ -931,7 +936,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * med_new->v1 = i; med_new->v2 = varray_stride + i; med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; - if ((mvert_new[i].flag & ME_VERT_TMP_TAG) == 0) { + if (!BLI_BITMAP_TEST(vert_tag, i)) { med_new->flag |= ME_LOOSEEDGE; } med_new++; @@ -1119,6 +1124,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * } #endif + MEM_freeN(vert_tag); + if (edge_poly_map) { MEM_freeN(edge_poly_map); } |