use htype flags as arguments to EDBM_index_arrays_init(), no functional changes.

This commit is contained in:
Campbell Barton
2012-12-12 05:27:52 +00:00
parent 3d69dbd44a
commit cf723e5e7c
13 changed files with 80 additions and 78 deletions

View File

@@ -83,9 +83,9 @@ typedef struct BMEditMesh {
int mirr_free_arrays;
} BMEditMesh;
void BMEdit_RecalcTessellation(BMEditMesh *tm);
void BMEdit_RecalcTessellation(BMEditMesh *em);
BMEditMesh *BMEdit_Create(BMesh *bm, int do_tessellate);
BMEditMesh *BMEdit_Copy(BMEditMesh *tm);
BMEditMesh *BMEdit_Copy(BMEditMesh *em);
BMEditMesh *BMEdit_FromObject(struct Object *ob);
void BMEdit_Free(BMEditMesh *em);
void BMEdit_UpdateLinkedCustomData(BMEditMesh *em);

View File

@@ -71,24 +71,24 @@ extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
BMEditMesh *BMEdit_Create(BMesh *bm, int do_tessellate)
{
BMEditMesh *tm = MEM_callocN(sizeof(BMEditMesh), __func__);
BMEditMesh *em = MEM_callocN(sizeof(BMEditMesh), __func__);
tm->bm = bm;
em->bm = bm;
if (do_tessellate) {
BMEdit_RecalcTessellation(tm);
BMEdit_RecalcTessellation(em);
}
return tm;
return em;
}
BMEditMesh *BMEdit_Copy(BMEditMesh *tm)
BMEditMesh *BMEdit_Copy(BMEditMesh *em)
{
BMEditMesh *tm2 = MEM_callocN(sizeof(BMEditMesh), __func__);
*tm2 = *tm;
BMEditMesh *em_copy = MEM_callocN(sizeof(BMEditMesh), __func__);
*em_copy = *em;
tm2->derivedCage = tm2->derivedFinal = NULL;
em_copy->derivedCage = em_copy->derivedFinal = NULL;
tm2->bm = BM_mesh_copy(tm->bm);
em_copy->bm = BM_mesh_copy(em->bm);
/* The tessellation is NOT calculated on the copy here,
* because currently all the callers of this function use
@@ -97,22 +97,22 @@ BMEditMesh *BMEdit_Copy(BMEditMesh *tm)
* reasons, in that case it makes more sense to do the
* tessellation only when/if that copy ends up getting
* used.*/
tm2->looptris = NULL;
em_copy->looptris = NULL;
tm2->vert_index = NULL;
tm2->edge_index = NULL;
tm2->face_index = NULL;
em_copy->vert_index = NULL;
em_copy->edge_index = NULL;
em_copy->face_index = NULL;
return tm2;
return em_copy;
}
static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
static void BMEdit_RecalcTessellation_intern(BMEditMesh *em)
{
/* use this to avoid locking pthread for _every_ polygon
* and calling the fill function */
#define USE_TESSFACE_SPEEDUP
BMesh *bm = tm->bm;
BMesh *bm = em->bm;
BMLoop *(*looptris)[3] = NULL;
BLI_array_declare(looptris);
BMIter iter, liter;
@@ -125,26 +125,26 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
#if 0
/* note, we could be clever and re-use this array but would need to ensure
* its realloced at some point, for now just free it */
if (tm->looptris) MEM_freeN(tm->looptris);
if (em->looptris) MEM_freeN(em->looptris);
/* Use tm->tottri when set, this means no reallocs while transforming,
/* Use em->tottri when set, this means no reallocs while transforming,
* (unless scanfill fails), otherwise... */
/* allocate the length of totfaces, avoid many small reallocs,
* if all faces are tri's it will be correct, quads == 2x allocs */
BLI_array_reserve(looptris, (tm->tottri && tm->tottri < bm->totface * 3) ? tm->tottri : bm->totface);
BLI_array_reserve(looptris, (em->tottri && em->tottri < bm->totface * 3) ? em->tottri : bm->totface);
#else
/* this means no reallocs for quad dominant models, for */
if ( (tm->looptris != NULL) &&
(tm->tottri != 0) &&
if ( (em->looptris != NULL) &&
(em->tottri != 0) &&
/* (totrti <= bm->totface * 2) would be fine for all quads,
* but in case there are some ngons, still re-use the array */
(tm->tottri <= bm->totface * 3))
(em->tottri <= bm->totface * 3))
{
looptris = tm->looptris;
looptris = em->looptris;
}
else {
if (tm->looptris) MEM_freeN(tm->looptris);
if (em->looptris) MEM_freeN(em->looptris);
BLI_array_reserve(looptris, bm->totface);
}
@@ -237,8 +237,8 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
}
}
tm->tottri = i;
tm->looptris = looptris;
em->tottri = i;
em->looptris = looptris;
#undef USE_TESSFACE_SPEEDUP

View File

@@ -86,10 +86,10 @@ void EDBM_mesh_clear(struct BMEditMesh *em);
void EDBM_selectmode_to_scene(struct bContext *C);
void EDBM_mesh_make(struct ToolSettings *ts, struct Scene *scene, struct Object *ob);
void EDBM_mesh_free(struct BMEditMesh *tm);
void EDBM_mesh_free(struct BMEditMesh *em);
void EDBM_mesh_load(struct Object *ob);
void EDBM_index_arrays_init(struct BMEditMesh *em, int forvert, int foredge, int forface);
void EDBM_index_arrays_init(struct BMEditMesh *em, const char htype);
void EDBM_index_arrays_free(struct BMEditMesh *em);
struct BMVert *EDBM_vert_at_index(struct BMEditMesh *em, int index);
struct BMEdge *EDBM_edge_at_index(struct BMEditMesh *em, int index);

View File

@@ -852,7 +852,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to
if (em) {
if (skip_em_vert_array_init == FALSE) {
EDBM_index_arrays_init(em, 1, 0, 0);
EDBM_index_arrays_init(em, BM_VERT);
}
}

View File

@@ -391,74 +391,76 @@ void EDBM_mesh_free(BMEditMesh *em)
BMEdit_Free(em);
}
void EDBM_index_arrays_init(BMEditMesh *tm, int forvert, int foredge, int forface)
void EDBM_index_arrays_init(BMEditMesh *em, const char htype)
{
EDBM_index_arrays_free(tm);
BLI_assert((htype & ~BM_ALL_NOLOOP) == 0);
if (forvert) {
tm->vert_index = MEM_mallocN(sizeof(void **) * tm->bm->totvert, "tm->vert_index");
EDBM_index_arrays_free(em);
if (htype & BM_VERT) {
em->vert_index = MEM_mallocN(sizeof(void **) * em->bm->totvert, "em->vert_index");
}
if (foredge) {
tm->edge_index = MEM_mallocN(sizeof(void **) * tm->bm->totedge, "tm->edge_index");
if (htype & BM_EDGE) {
em->edge_index = MEM_mallocN(sizeof(void **) * em->bm->totedge, "em->edge_index");
}
if (forface) {
tm->face_index = MEM_mallocN(sizeof(void **) * tm->bm->totface, "tm->face_index");
if (htype & BM_FACE) {
em->face_index = MEM_mallocN(sizeof(void **) * em->bm->totface, "em->face_index");
}
#pragma omp parallel sections
{
#pragma omp section
{
if (forvert) {
BM_iter_as_array(tm->bm, BM_VERTS_OF_MESH, NULL, (void **)tm->vert_index, tm->bm->totvert);
if (htype & BM_VERT) {
BM_iter_as_array(em->bm, BM_VERTS_OF_MESH, NULL, (void **)em->vert_index, em->bm->totvert);
}
}
#pragma omp section
{
if (foredge) {
BM_iter_as_array(tm->bm, BM_EDGES_OF_MESH, NULL, (void **)tm->edge_index, tm->bm->totedge);
if (htype & BM_EDGE) {
BM_iter_as_array(em->bm, BM_EDGES_OF_MESH, NULL, (void **)em->edge_index, em->bm->totedge);
}
}
#pragma omp section
{
if (forface) {
BM_iter_as_array(tm->bm, BM_FACES_OF_MESH, NULL, (void **)tm->face_index, tm->bm->totface);
if (htype & BM_FACE) {
BM_iter_as_array(em->bm, BM_FACES_OF_MESH, NULL, (void **)em->face_index, em->bm->totface);
}
}
}
}
void EDBM_index_arrays_free(BMEditMesh *tm)
void EDBM_index_arrays_free(BMEditMesh *em)
{
if (tm->vert_index) {
MEM_freeN(tm->vert_index);
tm->vert_index = NULL;
if (em->vert_index) {
MEM_freeN(em->vert_index);
em->vert_index = NULL;
}
if (tm->edge_index) {
MEM_freeN(tm->edge_index);
tm->edge_index = NULL;
if (em->edge_index) {
MEM_freeN(em->edge_index);
em->edge_index = NULL;
}
if (tm->face_index) {
MEM_freeN(tm->face_index);
tm->face_index = NULL;
if (em->face_index) {
MEM_freeN(em->face_index);
em->face_index = NULL;
}
}
BMVert *EDBM_vert_at_index(BMEditMesh *tm, int index)
BMVert *EDBM_vert_at_index(BMEditMesh *em, int index)
{
return tm->vert_index && index < tm->bm->totvert ? tm->vert_index[index] : NULL;
return em->vert_index && index < em->bm->totvert ? em->vert_index[index] : NULL;
}
BMEdge *EDBM_edge_at_index(BMEditMesh *tm, int index)
BMEdge *EDBM_edge_at_index(BMEditMesh *em, int index)
{
return tm->edge_index && index < tm->bm->totedge ? tm->edge_index[index] : NULL;
return em->edge_index && index < em->bm->totedge ? em->edge_index[index] : NULL;
}
BMFace *EDBM_face_at_index(BMEditMesh *tm, int index)
BMFace *EDBM_face_at_index(BMEditMesh *em, int index)
{
return (tm->face_index && index < tm->bm->totface && index >= 0) ? tm->face_index[index] : NULL;
return (em->face_index && index < em->bm->totface && index >= 0) ? em->face_index[index] : NULL;
}
void EDBM_selectmode_flush_ex(BMEditMesh *em, const short selectmode)
@@ -647,7 +649,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, int do_face_idx
int totverts, i, totuv;
if (do_face_idx_array)
EDBM_index_arrays_init(em, 0, 0, 1);
EDBM_index_arrays_init(em, BM_FACE);
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
@@ -1104,7 +1106,7 @@ void EDBM_verts_mirror_cache_begin(BMEditMesh *em, const short use_select)
}
if (!em->vert_index) {
EDBM_index_arrays_init(em, 1, 0, 0);
EDBM_index_arrays_init(em, BM_VERT);
em->mirr_free_arrays = 1;
}

View File

@@ -375,7 +375,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
BM_vert_create(em->bm, co, NULL, 0);
}
EDBM_index_arrays_init(em, 1, 0, 0);
EDBM_index_arrays_init(em, BM_VERT);
/* create faces */
for (j = 0; j < trinum; j++) {

View File

@@ -2838,7 +2838,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
}
}
EDBM_index_arrays_init(em, 1, 1, 1);
EDBM_index_arrays_init(em, BM_VERT | BM_EDGE | BM_FACE);
if (dt > OB_WIRE) {
if (check_object_draw_texture(scene, v3d, dt)) {
@@ -7123,7 +7123,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
DerivedMesh *dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH);
EDBM_index_arrays_init(em, 1, 1, 1);
EDBM_index_arrays_init(em, BM_VERT | BM_EDGE | BM_FACE);
bbs_mesh_solid_EM(em, scene, v3d, ob, dm, ts->selectmode & SCE_SELECT_FACE);
if (ts->selectmode & SCE_SELECT_FACE)

View File

@@ -113,7 +113,7 @@ void mesh_foreachScreenVert(
ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
}
EDBM_index_arrays_init(vc->em, 1, 0, 0);
EDBM_index_arrays_init(vc->em, BM_VERT);
dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data);
EDBM_index_arrays_free(vc->em);
@@ -172,7 +172,7 @@ void mesh_foreachScreenEdge(
ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
}
EDBM_index_arrays_init(vc->em, 0, 1, 0);
EDBM_index_arrays_init(vc->em, BM_EDGE);
dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data);
EDBM_index_arrays_free(vc->em);
@@ -209,7 +209,7 @@ void mesh_foreachScreenFace(
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
EDBM_index_arrays_init(vc->em, 0, 0, 1);
EDBM_index_arrays_init(vc->em, BM_FACE);
dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data);
EDBM_index_arrays_free(vc->em);

View File

@@ -340,7 +340,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod
}
if (transvmain && em->derivedCage) {
EDBM_index_arrays_init(em, 1, 0, 0);
EDBM_index_arrays_init(em, BM_VERT);
em->derivedCage->foreachMappedVert(em->derivedCage, set_mapped_co, userdata);
EDBM_index_arrays_free(em);
}

View File

@@ -1417,7 +1417,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
if (em != NULL) {
index_array = dm->getVertDataArray(dm, CD_ORIGINDEX);
EDBM_index_arrays_init(em, 1, 0, 0);
EDBM_index_arrays_init(em, BM_VERT);
}
for (i = 0; i < totvert; i++) {
@@ -1468,7 +1468,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
if (em != NULL) {
index_array = dm->getEdgeDataArray(dm, CD_ORIGINDEX);
EDBM_index_arrays_init(em, 0, 1, 0);
EDBM_index_arrays_init(em, BM_EDGE);
}
for (i = 0; i < totedge; i++) {

View File

@@ -999,7 +999,7 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
int a, looking, nverts, starttotf, select;
/* setup */
EDBM_index_arrays_init(em, 0, 0, 1);
EDBM_index_arrays_init(em, BM_FACE);
vmap = EDBM_uv_vert_map_create(em, 0, 0, limit);
BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
@@ -1111,7 +1111,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, const float
unsigned int a;
char *flag;
EDBM_index_arrays_init(em, 0, 0, 1); /* we can use this too */
EDBM_index_arrays_init(em, BM_FACE); /* we can use this too */
vmap = EDBM_uv_vert_map_create(em, 1, 1, limit);
if (vmap == NULL)
@@ -2608,7 +2608,7 @@ static void uv_faces_do_sticky(SpaceImage *sima, Scene *scene, Object *obedit, s
uvedit_pixel_to_float(sima, limit, 0.05);
EDBM_index_arrays_init(em, 0, 0, 1);
EDBM_index_arrays_init(em, BM_FACE);
vmap = EDBM_uv_vert_map_create(em, 0, 0, limit);
/* verts are numbered above in make_uv_vert_map_EM, make sure this stays true! */
@@ -3795,7 +3795,7 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op)
}
/* This code sets editvert->tmp.l to the index. This will be useful later on. */
EDBM_index_arrays_init(em, 0, 0, 1);
EDBM_index_arrays_init(em, BM_FACE);
vmap = EDBM_uv_vert_map_create(em, 0, 0, limit);
BM_ITER_MESH (editedge, &iter, bm, BM_EDGES_OF_MESH) {

View File

@@ -1256,7 +1256,7 @@ static int stitch_init(bContext *C, wmOperator *op)
int faceIndex, elementIndex;
UvElement *element;
EDBM_index_arrays_init(em, 0, 0, 1);
EDBM_index_arrays_init(em, BM_FACE);
RNA_BEGIN (op->ptr, itemptr, "selection")
{

View File

@@ -434,7 +434,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B
faceMap = MEM_mallocN(numOfFaces * sizeof(BMFace *), "unwrap_edit_face_map");
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
EDBM_index_arrays_init(em, 0, 1, 1);
EDBM_index_arrays_init(em, BM_EDGE | BM_FACE);
/* map subsurfed faces to original editFaces */
for (i = 0; i < numOfFaces; i++)