diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-23 03:33:53 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-23 03:33:53 +0400 |
commit | 3e40717000c673a9205ac422d787a702800ee5f2 (patch) | |
tree | a6f95bd959c1d10bbc3e5032eafdca8e59f5b2d5 /source/blender/editors/util | |
parent | 04ea8c0ee87e7a110d323e92116faaff20070854 (diff) |
use BLI_bitmap for crazyspace vertex tagging.
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r-- | source/blender/editors/util/crazyspace.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index e9d71d37e42..bed8aaaddf2 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -40,6 +40,7 @@ #include "BLI_utildefines.h" #include "BLI_math.h" +#include "BLI_bitmap.h" #include "BKE_DerivedMesh.h" #include "BKE_modifier.h" @@ -51,7 +52,7 @@ typedef struct { float *vertexcos; - short *flags; + BLI_bitmap *vertex_visit; } MappedUserData; #define TAN_MAKE_VEC(a, b, c) a[0] = b[0] + 0.2f * (b[0] - c[0]); a[1] = b[1] + 0.2f * (b[1] - c[1]); a[2] = b[2] + 0.2f * (b[2] - c[2]) @@ -79,11 +80,11 @@ static void make_vertexcos__mapFunc(void *userData, int index, const float co[3] float *vec = mappedData->vertexcos; vec += 3 * index; - if (!mappedData->flags[index]) { + if (BLI_BITMAP_GET(mappedData->vertex_visit, index) == 0) { /* we need coord from prototype vertex, not it clones or images, * suppose they stored in the beginning of vertex array stored in DM */ copy_v3_v3(vec, co); - mappedData->flags[index] = 1; + BLI_BITMAP_SET(mappedData->vertex_visit, index); } } @@ -109,7 +110,7 @@ float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit) DerivedMesh *dm; float *vertexcos; int nverts = me->edit_btmesh->bm->totvert; - short *flags; + BLI_bitmap *vertex_visit; MappedUserData userData; /* disable subsurf temporal, get mapped cos, and enable it */ @@ -122,10 +123,10 @@ float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit) dm = editbmesh_get_derived_cage(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH); vertexcos = MEM_callocN(3 * sizeof(float) * nverts, "vertexcos map"); - flags = MEM_callocN(sizeof(short) * nverts, "vertexcos flags"); + vertex_visit = BLI_BITMAP_NEW(nverts, "vertexcos flags"); userData.vertexcos = vertexcos; - userData.flags = flags; + userData.vertex_visit = vertex_visit; dm->foreachMappedVert(dm, make_vertexcos__mapFunc, &userData, DM_FOREACH_NOP); dm->release(dm); @@ -133,7 +134,7 @@ float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit) /* set back the flag, no new cage needs to be built, transform does it */ modifiers_disable_subsurf_temporary(obedit); - MEM_freeN(flags); + MEM_freeN(vertex_visit); return vertexcos; } @@ -278,7 +279,7 @@ int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em if (!defmats) { dm = getEditDerivedBMesh(em, ob, NULL); deformedVerts = editbmesh_get_vertex_cos(em, &numVerts); - defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats"); + defmats = MEM_mallocN(sizeof(*defmats) * numVerts, "defmats"); for (a = 0; a < numVerts; a++) unit_m3(defmats[a]); |