diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-01 18:36:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-01 18:36:23 +0400 |
commit | 85e0609c54f52068ac53435e80dda6d04b1a1373 (patch) | |
tree | 436d0d2949a5d222ed9d22b09d7f29864b7337ca | |
parent | a1e95e2e1818ffc88aa5079916b1ee51c1e585f0 (diff) |
use char for BMHeader type and flag (saves 2 bytes per edge/loop/vertex/face)
also found mouse_mesh_shortest_path was casting edit selecton to the wrong type.
33 files changed, 380 insertions, 418 deletions
diff --git a/source/blender/blenkernel/intern/editderivedbmesh.c b/source/blender/blenkernel/intern/editderivedbmesh.c index affc34ad150..05d55d25093 100644 --- a/source/blender/blenkernel/intern/editderivedbmesh.c +++ b/source/blender/blenkernel/intern/editderivedbmesh.c @@ -629,7 +629,7 @@ static void bmDM_drawMappedFaces(DerivedMesh *dm, int drawSmooth; efa = l[0]->f; - drawSmooth = (efa->head.flag & BM_SMOOTH); + drawSmooth= BM_TestHFlag(efa, BM_SMOOTH); draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, BM_GetIndex(efa), &drawSmooth); if(draw) { @@ -697,7 +697,7 @@ static void bmDM_drawMappedFaces(DerivedMesh *dm, int drawSmooth; efa = l[0]->f; - drawSmooth = (efa->head.flag & BM_SMOOTH); + drawSmooth= BM_TestHFlag(efa, BM_SMOOTH); draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, BM_GetIndex(efa), &drawSmooth); if(draw) { diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index df650695c5c..45c642fc0f3 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -148,7 +148,7 @@ BMEditMesh *CDDM_To_BMesh(Object *ob, DerivedMesh *dm, BMEditMesh *existing) for (i=0; i<totvert; i++, mv++) { v = BM_Make_Vert(bm, mv->co, NULL); normal_short_to_float_v3(v->no, mv->no); - v->head.flag = MEFlags_To_BMFlags(mv->flag, BM_VERT); + v->head.hflag = MEFlags_To_BMFlags(mv->flag, BM_VERT); CustomData_to_bmesh_block(&dm->vertData, &bm->vdata, i, &v->head.data); vtable[i] = v; @@ -160,7 +160,7 @@ BMEditMesh *CDDM_To_BMesh(Object *ob, DerivedMesh *dm, BMEditMesh *existing) for (i=0; i<totedge; i++, me++) { e = BM_Make_Edge(bm, vtable[me->v1], vtable[me->v2], NULL, 0); - e->head.flag = MEFlags_To_BMFlags(me->flag, BM_EDGE); + e->head.hflag = MEFlags_To_BMFlags(me->flag, BM_EDGE); CustomData_to_bmesh_block(&dm->edgeData, &bm->edata, i, &e->head.data); etable[i] = e; @@ -190,7 +190,7 @@ BMEditMesh *CDDM_To_BMesh(Object *ob, DerivedMesh *dm, BMEditMesh *existing) if (!f) continue; - f->head.flag = MEFlags_To_BMFlags(mp->flag, BM_FACE); + f->head.hflag = MEFlags_To_BMFlags(mp->flag, BM_FACE); f->mat_nr = mp->mat_nr; l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index a5fd107872b..ade68f6dfbb 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -143,16 +143,16 @@ defining edges[0], and define the winding of the new face.*/ struct BMFace *BM_Make_Ngon ( struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMEdge **edges, int len, int nodouble ); /*stuff for dealing with header flags*/ -BM_INLINE int BM_TestHFlag(const void *element, const int flag); +BM_INLINE char BM_TestHFlag(const void *element, const char hflag); /*stuff for dealing with header flags*/ -BM_INLINE void BM_SetHFlag(void *element, const int flag); +BM_INLINE void BM_SetHFlag(void *element, const char hflag); /*stuff for dealing with header flags*/ -BM_INLINE void BM_ClearHFlag(void *element, const int flag); +BM_INLINE void BM_ClearHFlag(void *element, const char hflag); /*stuff for dealing BM_ToggleHFlag header flags*/ -BM_INLINE void BM_ToggleHFlag(void *element, const int flag); +BM_INLINE void BM_ToggleHFlag(void *element, const char hflag); BM_INLINE void BM_MergeHFlag(void *element_a, void *element_b); BM_INLINE void BM_SetIndex(void *element, const int index); BM_INLINE int BM_GetIndex(const void *element); @@ -275,14 +275,14 @@ BMesh *init_editmesh_to_bmesh ( struct EditMesh *em, struct BMOperator *op ); struct EditMesh *bmesh_to_editmesh ( BMesh *bm ); /*convert between bmesh and Mesh flags*/ -int BMFlags_To_MEFlags ( void *element ); +short BMFlags_To_MEFlags(void *element); /*convert between Mesh and bmesh flags type must be BM_VERT/BM_EDGE/BM_FACE, and represents the type of the element parameter (the three defines map to MVert, MEdge, and MPoly, respectively).*/ -int MEFlags_To_BMFlags ( int flag, int type ); +char MEFlags_To_BMFlags(const char hflag, const char htype); /*convert MLoop*** in a bmface to mtface and mcol in an MFace*/ diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index af3c66cff2d..2ad25ba216a 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -57,9 +57,10 @@ struct Object; typedef struct BMHeader { void *data; /*customdata layers*/ struct BMFlagLayer *flags; - short type; /*element geometric type (verts/edges/loops/faces)*/ - short flag; /*this would be a CD layer, see below*/ int index; /*note: use BM_GetIndex/SetIndex macros for index*/ + + char htype; /*element geometric type (verts/edges/loops/faces)*/ + char hflag; /*this would be a CD layer, see below*/ } BMHeader; /*note: need some way to specify custom locations for custom data layers. so we can diff --git a/source/blender/bmesh/bmesh_iterators.h b/source/blender/bmesh/bmesh_iterators.h index 49920a77074..f90ca2f72d5 100644 --- a/source/blender/bmesh/bmesh_iterators.h +++ b/source/blender/bmesh/bmesh_iterators.h @@ -71,12 +71,12 @@ typedef struct BMIter { int i; long l; float f; - }filter; - int type, count; + } filter; + int htype, count; }BMIter; -void *BMIter_New(struct BMIter *iter, struct BMesh *bm, int type, void *data); +void *BMIter_New(struct BMIter *iter, struct BMesh *bm, const char htype, void *data); void *BMIter_Step(struct BMIter *iter); -void *BMIter_AtIndex(struct BMesh *bm, int type, void *data, int index); +void *BMIter_AtIndex(struct BMesh *bm, const char htype, void *data, int index); #endif diff --git a/source/blender/bmesh/bmesh_marking.h b/source/blender/bmesh/bmesh_marking.h index c8e161a37fd..22c1887d794 100644 --- a/source/blender/bmesh/bmesh_marking.h +++ b/source/blender/bmesh/bmesh_marking.h @@ -4,8 +4,8 @@ typedef struct BMEditSelection { struct BMEditSelection *next, *prev; - short type; void *data; + char htype; } BMEditSelection; /* pinning code */ @@ -27,7 +27,7 @@ void BM_Select(struct BMesh *bm, void *element, int select); chuck it.*/ int BM_Selected(BMesh *bm, const void *element); -void BM_clear_flag_all(BMesh *bm, int flag); +void BM_clear_flag_all(BMesh *bm, const char hflag); /*individual element select functions, BM_Select is a shortcut for these that automatically detects which one to use*/ @@ -38,7 +38,7 @@ void BM_Select_Face(struct BMesh *bm, struct BMFace *f, int select); void BM_Selectmode_Set(struct BMesh *bm, int selectmode); /*counts number of elements with flag set*/ -int BM_CountFlag(struct BMesh *bm, int type, int flag, int respecthide); +int BM_CountFlag(struct BMesh *bm, const char htype, const char hflag, int respecthide); /*edit selection stuff*/ void BM_set_actFace(BMesh *em, BMFace *f); diff --git a/source/blender/bmesh/bmesh_operator_api.h b/source/blender/bmesh/bmesh_operator_api.h index c463f6fb5ae..0d15383f901 100644 --- a/source/blender/bmesh/bmesh_operator_api.h +++ b/source/blender/bmesh/bmesh_operator_api.h @@ -164,7 +164,7 @@ int BMO_TestFlag(struct BMesh *bm, void *element, int flag);*/ /*count the number of elements with a specific flag. type can be a bitmask of BM_FACE, BM_EDGE, or BM_FACE.*/ -int BMO_CountFlag(struct BMesh *bm, int flag, int type); +int BMO_CountFlag(struct BMesh *bm, int flag, const char htype); /*---------formatted operator initialization/execution-----------*/ /* @@ -259,26 +259,26 @@ void BMO_Set_Mat(struct BMOperator *op, const char *slotname, float *mat, int si void BMO_Get_Mat4(struct BMOperator *op, const char *slotname, float mat[4][4]); void BMO_Get_Mat3(struct BMOperator *op, const char *slotname, float mat[3][3]); -void BMO_Clear_Flag_All(BMesh *bm, BMOperator *op, int type, int flag); +void BMO_Clear_Flag_All(BMesh *bm, BMOperator *op, const char htype, int flag); /*puts every element of type type (which is a bitmask) with tool flag flag, into a slot.*/ -void BMO_Flag_To_Slot(struct BMesh *bm, struct BMOperator *op, const char *slotname, int flag, int type); +void BMO_Flag_To_Slot(struct BMesh *bm, struct BMOperator *op, const char *slotname, const int flag, const char htype); /*tool-flags all elements inside an element slot array with flag flag.*/ -void BMO_Flag_Buffer(struct BMesh *bm, struct BMOperator *op, const char *slotname, int flag, int type); +void BMO_Flag_Buffer(struct BMesh *bm, struct BMOperator *op, const char *slotname, const int hflag, const char htype); /*clears tool-flag flag from all elements inside a slot array.*/ -void BMO_Unflag_Buffer(struct BMesh *bm, struct BMOperator *op, const char *slotname, int flag, int type); +void BMO_Unflag_Buffer(struct BMesh *bm, struct BMOperator *op, const char *slotname, const int flag, const char htype); /*tool-flags all elements inside an element slot array with flag flag.*/ -void BMO_HeaderFlag_Buffer(struct BMesh *bm, struct BMOperator *op, const char *slotname, int flag, int type); +void BMO_HeaderFlag_Buffer(struct BMesh *bm, struct BMOperator *op, const char *slotname, const char hflag, const char htype); /*clears tool-flag flag from all elements inside a slot array.*/ -void BMO_UnHeaderFlag_Buffer(struct BMesh *bm, struct BMOperator *op, const char *slotname, int flag, int type); +void BMO_UnHeaderFlag_Buffer(struct BMesh *bm, struct BMOperator *op, const char *slotname, const char hflag, const char htype); /*puts every element of type type (which is a bitmask) with header flag flag, into a slot. note: ignores hidden elements (e.g. elements with header flag BM_HIDDEN set).*/ -void BMO_HeaderFlag_To_Slot(struct BMesh *bm, struct BMOperator *op, const char *slotname, int flag, int type); +void BMO_HeaderFlag_To_Slot(struct BMesh *bm, struct BMOperator *op, const char *slotname, const char hflag, const char htype); /*counts number of elements inside a slot array.*/ int BMO_CountSlotBuf(struct BMesh *bm, struct BMOperator *op, const char *slotname); @@ -359,7 +359,7 @@ typedef struct BMOIter { int cur; //for arrays struct GHashIterator giter; void *val; - int restrictmask; + char restrictmask; /* bitwise '&' with BMHeader.htype */ } BMOIter; void *BMO_FirstElem(BMOperator *op, const char *slotname); @@ -368,7 +368,7 @@ void *BMO_FirstElem(BMOperator *op, const char *slotname); (e.g. combination of BM_VERT, BM_EDGE, BM_FACE), if iterating over an element buffer (not a mapping).*/ void *BMO_IterNew(BMOIter *iter, BMesh *bm, BMOperator *op, - const char *slotname, int restrictmask); + const char *slotname, const char restrictmask); void *BMO_IterStep(BMOIter *iter); /*returns a pointer to the key value when iterating over mappings. diff --git a/source/blender/bmesh/bmesh_operators.h b/source/blender/bmesh/bmesh_operators.h index c27cb72ecc7..6b63ac38620 100644 --- a/source/blender/bmesh/bmesh_operators.h +++ b/source/blender/bmesh/bmesh_operators.h @@ -80,7 +80,7 @@ extern int bmesh_total_ops; struct Object; struct EditMesh; -void BMOP_DupeFromFlag(struct BMesh *bm, int etypeflag, int flag); +void BMOP_DupeFromFlag(struct BMesh *bm, int etypeflag, const char hflag); void BM_esubdivideflag(struct Object *obedit, BMesh *bm, int flag, float smooth, float fractal, int beauty, int numcuts, int seltype, int cornertype, int singleedge, int gridfill, int seed); diff --git a/source/blender/bmesh/bmesh_queries.h b/source/blender/bmesh/bmesh_queries.h index 9528a9e987b..548fbdf36e1 100644 --- a/source/blender/bmesh/bmesh_queries.h +++ b/source/blender/bmesh/bmesh_queries.h @@ -8,7 +8,7 @@ float BM_face_area(BMFace *f); /*counts number of elements of type type are in the mesh.*/ -int BM_Count_Element(struct BMesh *bm, int type); +int BM_Count_Element(struct BMesh *bm, const char htype); /*returns true if v is in f*/ int BM_Vert_In_Face(struct BMFace *f, struct BMVert *v); diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 50d4a1610ca..4fb4298434b 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -464,23 +464,23 @@ void BM_Copy_Attributes(BMesh *source_mesh, BMesh *target_mesh, const void *sour const BMHeader *sheader = source; BMHeader *theader = target; - if(sheader->type != theader->type) + if(sheader->htype != theader->htype) return; /*First we copy select*/ if(BM_Selected(source_mesh, source)) BM_Select(target_mesh, target, 1); /*Now we copy flags*/ - theader->flag = sheader->flag; + theader->hflag = sheader->hflag; /*Copy specific attributes*/ - if(theader->type == BM_VERT) + if(theader->htype == BM_VERT) bm_copy_vert_attributes(source_mesh, target_mesh, (const BMVert*)source, (BMVert*)target); - else if(theader->type == BM_EDGE) + else if(theader->htype == BM_EDGE) bm_copy_edge_attributes(source_mesh, target_mesh, (const BMEdge*)source, (BMEdge*)target); - else if(theader->type == BM_LOOP) + else if(theader->htype == BM_LOOP) bm_copy_loop_attributes(source_mesh, target_mesh, (const BMLoop*)source, (BMLoop*)target); - else if(theader->type == BM_FACE) + else if(theader->htype == BM_FACE) bm_copy_face_attributes(source_mesh, target_mesh, (const BMFace*)source, (BMFace*)target); } @@ -587,12 +587,12 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) for (ese=bmold->selected.first; ese; ese=ese->next) { void *ele = NULL; - if (ese->type == BM_VERT) - ele = vtable[BM_GetIndex(ese->data)]; - else if (ese->type == BM_EDGE) - ele = etable[BM_GetIndex(ese->data)]; - else if (ese->type == BM_FACE) { - ele = ftable[BM_GetIndex(ese->data)]; + if (ese->htype == BM_VERT) + ele= vtable[BM_GetIndex(ese->data)]; + else if (ese->htype == BM_EDGE) + ele= etable[BM_GetIndex(ese->data)]; + else if (ese->htype == BM_FACE) { + ele= ftable[BM_GetIndex(ese->data)]; } else { BLI_assert(0); @@ -620,25 +620,26 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) or BMFace, converted to mesh flags. */ -int BMFlags_To_MEFlags(void *element) { - const short src_type= ((BMHeader *)element)->type; - const short src_flag= ((BMHeader *)element)->flag; +short BMFlags_To_MEFlags(void *element) +{ + const char src_htype= ((BMHeader *)element)->htype; + const char src_hflag= ((BMHeader *)element)->hflag; - int dst_flag = 0; + short dst_flag= 0; - if (src_flag & BM_HIDDEN) dst_flag |= ME_HIDE; + if (src_hflag & BM_HIDDEN) dst_flag |= ME_HIDE; - if (src_type == BM_FACE) { - if (src_flag & BM_SELECT) dst_flag |= ME_FACE_SEL; - if (src_flag & BM_SMOOTH) dst_flag |= ME_SMOOTH; - } else if (src_type == BM_EDGE) { - if (src_flag & BM_SELECT) dst_flag |= SELECT; - if (src_flag & BM_SEAM) dst_flag |= ME_SEAM; - if (src_flag & BM_SHARP) dst_flag |= ME_SHARP; - if (BM_Wire_Edge(NULL, element)) dst_flag |= ME_LOOSEEDGE; + if (src_htype == BM_FACE) { + if (src_hflag & BM_SELECT) dst_flag |= ME_FACE_SEL; + if (src_hflag & BM_SMOOTH) dst_flag |= ME_SMOOTH; + } else if (src_htype == BM_EDGE) { + if (src_hflag & BM_SELECT) dst_flag |= SELECT; + if (src_hflag & BM_SEAM) dst_flag |= ME_SEAM; + if (src_hflag & BM_SHARP) dst_flag |= ME_SHARP; + if (BM_Wire_Edge(NULL, element)) dst_flag |= ME_LOOSEEDGE; dst_flag |= ME_EDGEDRAW | ME_EDGERENDER; - } else if (src_type == BM_VERT) { - if (src_flag & BM_SELECT) dst_flag |= SELECT; + } else if (src_htype == BM_VERT) { + if (src_hflag & BM_SELECT) dst_flag |= SELECT; } return dst_flag; @@ -653,21 +654,22 @@ int BMFlags_To_MEFlags(void *element) { type must be either BM_VERT, BM_EDGE, or BM_FACE. */ -int MEFlags_To_BMFlags(int flag, int type) { - int f = 0; - - if (type == BM_FACE) { - if (flag & ME_FACE_SEL) f |= BM_SELECT; - if (flag & ME_SMOOTH) f |= BM_SMOOTH; - if (flag & ME_HIDE) f |= BM_HIDDEN; - } else if (type == BM_EDGE) { - if (flag & SELECT) f |= BM_SELECT; - if (flag & ME_SEAM) f |= BM_SEAM; - if (flag & ME_SHARP) f |= BM_SHARP; - if (flag & ME_HIDE) f |= BM_HIDDEN; - } else if (type == BM_VERT) { - if (flag & SELECT) f |= BM_SELECT; - if (flag & ME_HIDE) f |= BM_HIDDEN; +char MEFlags_To_BMFlags(const char hflag, const char htype) +{ + char f= 0; + + if (htype == BM_FACE) { + if (hflag & ME_FACE_SEL) f |= BM_SELECT; + if (hflag & ME_SMOOTH) f |= BM_SMOOTH; + if (hflag & ME_HIDE) f |= BM_HIDDEN; + } else if (htype == BM_EDGE) { + if (hflag & SELECT) f |= BM_SELECT; + if (hflag & ME_SEAM) f |= BM_SEAM; + if (hflag & ME_SHARP) f |= BM_SHARP; + if (hflag & ME_HIDE) f |= BM_HIDDEN; + } else if (htype == BM_VERT) { + if (hflag & SELECT) f |= BM_SELECT; + if (hflag & ME_HIDE) f |= BM_HIDDEN; } return f; diff --git a/source/blender/bmesh/intern/bmesh_inline.c b/source/blender/bmesh/intern/bmesh_inline.c index 4a549248710..88f9800950d 100644 --- a/source/blender/bmesh/intern/bmesh_inline.c +++ b/source/blender/bmesh/intern/bmesh_inline.c @@ -3,31 +3,31 @@ #include "bmesh.h" -BM_INLINE int BM_TestHFlag(const void *element, const int flag) +BM_INLINE char BM_TestHFlag(const void *element, const char hflag) { - return ((const BMHeader *)element)->flag & flag; + return ((const BMHeader *)element)->hflag & hflag; } -BM_INLINE void BM_SetHFlag(void *element, const int flag) +BM_INLINE void BM_SetHFlag(void *element, const char hflag) { - ((BMHeader *)element)->flag |= flag; + ((BMHeader *)element)->hflag |= hflag; } -BM_INLINE void BM_ClearHFlag(void *element, const int flag) +BM_INLINE void BM_ClearHFlag(void *element, const char hflag) { - ((BMHeader *)element)->flag &= ~flag; + ((BMHeader *)element)->hflag &= ~hflag; } -BM_INLINE void BM_ToggleHFlag(void *element, const int flag) +BM_INLINE void BM_ToggleHFlag(void *element, const char hflag) { - ((BMHeader *)element)->flag ^= flag; + ((BMHeader *)element)->hflag ^= hflag; } BM_INLINE void BM_MergeHFlag(void *element_a, void *element_b) { - ((BMHeader *)element_a)->flag = - ((BMHeader *)element_b)->flag = (((BMHeader *)element_a)->flag | - ((BMHeader *)element_b)->flag); + ((BMHeader *)element_a)->hflag = + ((BMHeader *)element_b)->hflag = (((BMHeader *)element_a)->hflag | + ((BMHeader *)element_b)->hflag); } BM_INLINE void BM_SetIndex(void *element, const int index) diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index e2b9f6eab10..9a7064c136a 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -4,7 +4,7 @@ #include "bmesh_private.h" -void *BMIter_AtIndex(struct BMesh *bm, int type, void *data, int index) +void *BMIter_AtIndex(struct BMesh *bm, const char htype, void *data, int index) { BMIter iter; void *val; @@ -13,7 +13,7 @@ void *BMIter_AtIndex(struct BMesh *bm, int type, void *data, int index) /*sanity check*/ if (index < 0) return NULL; - val=BMIter_New(&iter, bm, type, data); + val=BMIter_New(&iter, bm, htype, data); i = 0; while (i < index) { @@ -364,13 +364,13 @@ static void *loop_of_face_step(BMIter *iter) * to return the first element of the iterator. * */ -void *BMIter_New(BMIter *iter, BMesh *bm, int type, void *data) +void *BMIter_New(BMIter *iter, BMesh *bm, const char htype, void *data) { /* int argtype; */ - iter->type = type; + iter->htype = htype; iter->bm = bm; - switch(type){ + switch(htype){ case BM_VERTS_OF_MESH: iter->begin = vert_of_mesh_begin; iter->step = vert_of_mesh_step; diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 2c08f2b9866..b62d1f68e88 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -321,28 +321,28 @@ void BM_Selectmode_Set(BMesh *bm, int selectmode) } -int BM_CountFlag(struct BMesh *bm, int type, int flag, int respecthide) +int BM_CountFlag(struct BMesh *bm, const char htype, const char hflag, int respecthide) { BMHeader *head; BMIter iter; int tot = 0; - if (type & BM_VERT) { + if (htype & BM_VERT) { for (head = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); head; head=BMIter_Step(&iter)) { if (respecthide && BM_TestHFlag(head, BM_HIDDEN)) continue; - if (head->flag & flag) tot++; + if (BM_TestHFlag(head, hflag)) tot++; } } - if (type & BM_EDGE) { + if (htype & BM_EDGE) { for (head = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL); head; head=BMIter_Step(&iter)) { if (respecthide && BM_TestHFlag(head, BM_HIDDEN)) continue; - if (head->flag & flag) tot++; + if (BM_TestHFlag(head, hflag)) tot++; } } - if (type & BM_FACE) { + if (htype & BM_FACE) { for (head = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); head; head=BMIter_Step(&iter)) { if (respecthide && BM_TestHFlag(head, BM_HIDDEN)) continue; - if (head->flag & flag) tot++; + if (BM_TestHFlag(head, hflag)) tot++; } } @@ -354,9 +354,9 @@ void BM_Select(struct BMesh *bm, void *element, int select) { BMHeader *head = element; - if(head->type == BM_VERT) BM_Select_Vert(bm, (BMVert*)element, select); - else if(head->type == BM_EDGE) BM_Select_Edge(bm, (BMEdge*)element, select); - else if(head->type == BM_FACE) BM_Select_Face(bm, (BMFace*)element, select); + if (head->htype == BM_VERT) BM_Select_Vert(bm, (BMVert*)element, select); + else if(head->htype == BM_EDGE) BM_Select_Edge(bm, (BMEdge*)element, select); + else if(head->htype == BM_FACE) BM_Select_Face(bm, (BMFace*)element, select); } int BM_Selected(BMesh *UNUSED(bm), const void *element) @@ -385,8 +385,8 @@ BMFace *BM_get_actFace(BMesh *bm, int sloppy) /* Find the latest non-hidden face from the BMEditSelection */ ese = bm->selected.last; for (; ese; ese=ese->prev){ - if(ese->type == BM_FACE) { - f = (BMFace *)ese->data; + if(ese->htype == BM_FACE) { + f= (BMFace *)ese->data; if (BM_TestHFlag(f, BM_HIDDEN)) { f= NULL; @@ -418,14 +418,16 @@ EM_editselection_plane */ void BM_editselection_center(BMesh *bm, float *center, BMEditSelection *ese) { - if (ese->type==BM_VERT) { + if (ese->htype == BM_VERT) { BMVert *eve= ese->data; copy_v3_v3(center, eve->co); - } else if (ese->type==BM_EDGE) { + } + else if (ese->htype == BM_EDGE) { BMEdge *eed= ese->data; add_v3_v3v3(center, eed->v1->co, eed->v2->co); mul_v3_fl(center, 0.5); - } else if (ese->type==BM_FACE) { + } + else if (ese->htype == BM_FACE) { BMFace *efa= ese->data; BM_Compute_Face_Center(bm, efa, center); } @@ -433,10 +435,11 @@ void BM_editselection_center(BMesh *bm, float *center, BMEditSelection *ese) void BM_editselection_normal(float *normal, BMEditSelection *ese) { - if (ese->type==BM_VERT) { + if (ese->htype == BM_VERT) { BMVert *eve= ese->data; copy_v3_v3(normal, eve->no); - } else if (ese->type==BM_EDGE) { + } + else if (ese->htype == BM_EDGE) { BMEdge *eed= ese->data; float plane[3]; /* need a plane to correct the normal */ float vec[3]; /* temp vec storage */ @@ -452,7 +455,8 @@ void BM_editselection_normal(float *normal, BMEditSelection *ese) cross_v3_v3v3(normal, plane, vec); normalize_v3(normal); - } else if (ese->type==BM_FACE) { + } + else if (ese->htype == BM_FACE) { BMFace *efa= ese->data; copy_v3_v3(normal, efa->no); } @@ -463,7 +467,7 @@ also make the plane run along an axis that is related to the geometry, because this is used for the manipulators Y axis.*/ void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese) { - if (ese->type==BM_VERT) { + if (ese->htype == BM_VERT) { BMVert *eve= ese->data; float vec[3]={0,0,0}; @@ -480,7 +484,8 @@ void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese) else vec[2]= 1.0f; cross_v3_v3v3(plane, eve->no, vec); } - } else if (ese->type==BM_EDGE) { + } + else if (ese->htype == BM_EDGE) { BMEdge *eed= ese->data; /* the plane is simple, it runs along the edge @@ -493,7 +498,8 @@ void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese) else sub_v3_v3v3(plane, eed->v1->co, eed->v2->co); - } else if (ese->type==BM_FACE) { + } + else if (ese->htype == BM_FACE) { BMFace *efa= ese->data; float vec[3] = {0.0f, 0.0f, 0.0f}; @@ -573,7 +579,7 @@ void BM_store_selection(BMesh *bm, void *data) BMEditSelection *ese; if(!BM_check_selection(bm, data)){ ese = (BMEditSelection*) MEM_callocN( sizeof(BMEditSelection), "BMEdit Selection"); - ese->type = ((BMHeader*)data)->type; + ese->htype = ((BMHeader*)data)->htype; ese->data = data; BLI_addtail(&(bm->selected),ese); } @@ -594,32 +600,21 @@ void BM_validate_selections(BMesh *bm) } } -void BM_clear_flag_all(BMesh *bm, int flag) +void BM_clear_flag_all(BMesh *bm, const char hflag) { + int types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH}; BMIter iter; BMHeader *ele; - int i, type; + int i; - if (flag & BM_SELECT) + if (hflag & BM_SELECT) BM_clear_selection_history(bm); - for (i=0; i<3; i++) { - switch (i) { - case 0: - type = BM_VERTS_OF_MESH; - break; - case 1: - type = BM_EDGES_OF_MESH; - break; - case 2: - type = BM_FACES_OF_MESH; - break; - } - - ele = BMIter_New(&iter, bm, type, NULL); + for (i=0; i<3; i++) { + ele = BMIter_New(&iter, bm, types[i], NULL); for ( ; ele; ele=BMIter_Step(&iter)) { - if (flag & BM_SELECT) BM_Select(bm, ele, 0); - BM_ClearHFlag(ele, flag); + if (hflag & BM_SELECT) BM_Select(bm, ele, 0); + BM_ClearHFlag(ele, hflag); } } } @@ -715,7 +710,7 @@ void BM_Hide(BMesh *bm, void *element, int hide) if (hide) BM_Select(bm, element, 0); - switch (h->type) { + switch (h->htype) { case BM_VERT: BM_Hide_Vert(bm, element, hide); break; diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 2b7ae8e3761..38f00119a5e 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -552,7 +552,7 @@ BMVert *BM_Split_Edge(BMesh *bm, BMVert *v, BMEdge *e, BMEdge **ne, float percen VECADDFAC(nv->co,v->co,nv->co,percent); if (ne) { - (*ne)->head.flag = e->head.flag; + (*ne)->head.hflag = e->head.hflag; BM_Copy_Attributes(bm, bm, e, *ne); } diff --git a/source/blender/bmesh/intern/bmesh_newcore.c b/source/blender/bmesh/intern/bmesh_newcore.c index c49d2faa395..59c6ddc16ad 100644 --- a/source/blender/bmesh/intern/bmesh_newcore.c +++ b/source/blender/bmesh/intern/bmesh_newcore.c @@ -24,7 +24,7 @@ BMVert *BM_Make_Vert(BMesh *bm, float co[3], const struct BMVert *example) { bm->totvert += 1; - v->head.type = BM_VERT; + v->head.htype = BM_VERT; /* 'v->no' is handled by BM_Copy_Attributes */ if (co) copy_v3_v3(v->co, co); @@ -38,7 +38,7 @@ BMVert *BM_Make_Vert(BMesh *bm, float co[3], const struct BMVert *example) { BM_Copy_Attributes(bm, bm, (BMVert*)example, (BMVert*)v); } - CHECK_ELEMENT(bm, v); + BM_CHECK_ELEMENT(bm, v); return (BMVert*) v; } @@ -75,7 +75,7 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, i e = BLI_mempool_calloc(bm->epool); bm->totedge += 1; - e->head.type = BM_EDGE; + e->head.htype = BM_EDGE; /*allocate flags*/ e->head.flags = BLI_mempool_calloc(bm->toolflagpool); @@ -92,7 +92,7 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, i if (example) BM_Copy_Attributes(bm, bm, (BMEdge*)example, (BMEdge*)e); - CHECK_ELEMENT(bm, e); + BM_CHECK_ELEMENT(bm, e); return (BMEdge*) e; } @@ -107,7 +107,7 @@ static BMLoop *bmesh_create_loop(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f, con l->f = f; l->radial_next = l->radial_prev = NULL; l->head.data = NULL; - l->head.type = BM_LOOP; + l->head.htype = BM_LOOP; bm->totloop++; @@ -217,7 +217,7 @@ BMFace *BM_Make_Face(BMesh *bm, BMVert **verts, BMEdge **edges, int len, int nod f = BLI_mempool_calloc(bm->fpool); bm->totface += 1; - f->head.type = BM_FACE; + f->head.htype = BM_FACE; startl = lastl = BM_Add_FaceBoundary(bm, (BMFace*)f, verts[0], edges[0]); @@ -245,34 +245,35 @@ BMFace *BM_Make_Face(BMesh *bm, BMVert **verts, BMEdge **edges, int len, int nod f->len = len; f->totbounds = 0; - CHECK_ELEMENT(bm, f); + BM_CHECK_ELEMENT(bm, f); return (BMFace*) f; } -int bmesh_check_element(BMesh *UNUSED(bm), void *element, int type) { +int bmesh_check_element(BMesh *UNUSED(bm), void *element, const char htype) +{ BMHeader *head = element; int err = 0; if (!element) return 1; - if (head->type != type) + if (head->htype != htype) return 2; - switch (type) { + switch (htype) { case BM_VERT: { BMVert *v = element; - if (v->e && v->e->head.type != BM_EDGE) { + if (v->e && v->e->head.htype != BM_EDGE) { err |= 4; } break; } case BM_EDGE: { BMEdge *e = element; - if (e->l && e->l->head.type != BM_LOOP) + if (e->l && e->l->head.htype != BM_LOOP) err |= 8; - if (e->l && e->l->f->head.type != BM_FACE) + if (e->l && e->l->f->head.htype != BM_FACE) err |= 16; if (e->dlink1.prev == NULL || e->dlink2.prev == NULL || e->dlink1.next == NULL || e->dlink2.next == NULL) err |= 32; @@ -286,11 +287,11 @@ int bmesh_check_element(BMesh *UNUSED(bm), void *element, int type) { BMLoop *l = element, *l2; int i; - if (l->f->head.type != BM_FACE) + if (l->f->head.htype != BM_FACE) err |= 256; - if (l->e->head.type != BM_EDGE) + if (l->e->head.htype != BM_EDGE) err |= 512; - if (l->v->head.type != BM_VERT) + if (l->v->head.htype != BM_VERT) err |= 1024; if (!BM_Vert_In_Edge(l->e, l->v)) { fprintf(stderr, "%s: fatal bmesh error (vert not in edge)! (bmesh internal error)\n", __func__); @@ -417,7 +418,7 @@ void BM_Kill_Face_Verts(BMesh *bm, BMFace *f) { void BM_Kill_Face(BMesh *bm, BMFace *f) { BMLoopList *ls, *lsnext; - CHECK_ELEMENT(bm, f); + BM_CHECK_ELEMENT(bm, f); for (ls=f->loops.first; ls; ls=lsnext) { BMLoop *l, *lnext; @@ -597,15 +598,15 @@ static int bmesh_loop_reverse_loop(BMesh *bm, BMFace *f, BMLoopList *lst){ /*validate radial*/ for(i=0, curloop = l; i < len; i++, curloop = curloop->next) { - CHECK_ELEMENT(bm, curloop); - CHECK_ELEMENT(bm, curloop->e); - CHECK_ELEMENT(bm, curloop->v); - CHECK_ELEMENT(bm, curloop->f); + BM_CHECK_ELEMENT(bm, curloop); + BM_CHECK_ELEMENT(bm, curloop->e); + BM_CHECK_ELEMENT(bm, curloop->v); + BM_CHECK_ELEMENT(bm, curloop->f); } BLI_array_free(edar); - CHECK_ELEMENT(bm, f); + BM_CHECK_ELEMENT(bm, f); return 1; } @@ -872,7 +873,7 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) BLI_array_free(deledges); BLI_array_free(delverts); - CHECK_ELEMENT(bm, newf); + BM_CHECK_ELEMENT(bm, newf); return newf; error: bmesh_clear_systag_elements(bm, faces, totface, _FLAG_JF); @@ -893,7 +894,7 @@ static BMFace *bmesh_addpolylist(BMesh *bm, BMFace *UNUSED(example)) { f = BLI_mempool_calloc(bm->fpool); lst = BLI_mempool_calloc(bm->looplistpool); - f->head.type = BM_FACE; + f->head.htype = BM_FACE; BLI_addtail(&f->loops, lst); bm->totface++; @@ -1028,9 +1029,9 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, } } - CHECK_ELEMENT(bm, e); - CHECK_ELEMENT(bm, f); - CHECK_ELEMENT(bm, f2); + BM_CHECK_ELEMENT(bm, e); + BM_CHECK_ELEMENT(bm, f); + BM_CHECK_ELEMENT(bm, f2); return f2; } @@ -1173,10 +1174,10 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re){ if(l->e == l->next->e) bmesh_error(); /*verify loop cycle for kloop->f*/ - CHECK_ELEMENT(bm, l); - CHECK_ELEMENT(bm, l->v); - CHECK_ELEMENT(bm, l->e); - CHECK_ELEMENT(bm, l->f); + BM_CHECK_ELEMENT(bm, l); + BM_CHECK_ELEMENT(bm, l->v); + BM_CHECK_ELEMENT(bm, l->e); + BM_CHECK_ELEMENT(bm, l->f); } /*verify loop->v and loop->next->v pointers for ne*/ for(i=0,l=ne->l; i < radlen; i++, l = l->radial_next){ @@ -1188,18 +1189,18 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re){ if(l->v == l->next->v) bmesh_error(); if(l->e == l->next->e) bmesh_error(); - CHECK_ELEMENT(bm, l); - CHECK_ELEMENT(bm, l->v); - CHECK_ELEMENT(bm, l->e); - CHECK_ELEMENT(bm, l->f); + BM_CHECK_ELEMENT(bm, l); + BM_CHECK_ELEMENT(bm, l->v); + BM_CHECK_ELEMENT(bm, l->e); + BM_CHECK_ELEMENT(bm, l->f); } } - CHECK_ELEMENT(bm, ne); - CHECK_ELEMENT(bm, nv); - CHECK_ELEMENT(bm, ov); - CHECK_ELEMENT(bm, e); - CHECK_ELEMENT(bm, tv); + BM_CHECK_ELEMENT(bm, ne); + BM_CHECK_ELEMENT(bm, nv); + BM_CHECK_ELEMENT(bm, ov); + BM_CHECK_ELEMENT(bm, e); + BM_CHECK_ELEMENT(bm, tv); if(re) *re = ne; return nv; @@ -1330,15 +1331,15 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) edok = bmesh_loop_validate(l->f); if(!edok) bmesh_error(); - CHECK_ELEMENT(bm, l); - CHECK_ELEMENT(bm, l->v); - CHECK_ELEMENT(bm, l->e); - CHECK_ELEMENT(bm, l->f); + BM_CHECK_ELEMENT(bm, l); + BM_CHECK_ELEMENT(bm, l->v); + BM_CHECK_ELEMENT(bm, l->e); + BM_CHECK_ELEMENT(bm, l->f); } - CHECK_ELEMENT(bm, ov); - CHECK_ELEMENT(bm, tv); - CHECK_ELEMENT(bm, oe); + BM_CHECK_ELEMENT(bm, ov); + BM_CHECK_ELEMENT(bm, tv); + BM_CHECK_ELEMENT(bm, oe); return 1; } @@ -1482,7 +1483,7 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) BLI_mempool_free(bm->fpool, f2); bm->totface--; - CHECK_ELEMENT(bm, f1); + BM_CHECK_ELEMENT(bm, f1); /*validate the new loop cycle*/ edok = bmesh_loop_validate(f1); @@ -1521,8 +1522,8 @@ static int bmesh_splicevert(BMesh *bm, BMVert *v, BMVert *vtarget) e = v->e; } - CHECK_ELEMENT(bm, v); - CHECK_ELEMENT(bm, vtarget); + BM_CHECK_ELEMENT(bm, v); + BM_CHECK_ELEMENT(bm, vtarget); /* v is unused now, and can be killed */ BM_Kill_Vert(bm, v); @@ -1617,7 +1618,7 @@ static int bmesh_cutvert(BMesh *bm, BMVert *v, BMVert ***vout, int *len) BLI_array_free(stack); for (i = 0; i < maxindex; i++) { - CHECK_ELEMENT(bm, verts[i]); + BM_CHECK_ELEMENT(bm, verts[i]); } if (len != NULL) { @@ -1659,8 +1660,8 @@ static int bmesh_spliceedge(BMesh *bm, BMEdge *e, BMEdge *etarget) BLI_assert(bmesh_radial_length(e->l) == 0); - CHECK_ELEMENT(bm, e); - CHECK_ELEMENT(bm, etarget); + BM_CHECK_ELEMENT(bm, e); + BM_CHECK_ELEMENT(bm, etarget); BM_Kill_Edge(bm, e); @@ -1702,8 +1703,8 @@ static int bmesh_cutedge(BMesh *bm, BMEdge *e, BMLoop *cutl) BLI_assert(bmesh_radial_length(e->l) == radlen - 1); BLI_assert(bmesh_radial_length(ne->l) == 1); - CHECK_ELEMENT(bm, ne); - CHECK_ELEMENT(bm, e); + BM_CHECK_ELEMENT(bm, ne); + BM_CHECK_ELEMENT(bm, e); return 1; } diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index a093edbd04c..2b967e95634 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -68,9 +68,7 @@ void BMO_Clear_OpFlag(BMesh *UNUSED(bm), BMOperator *op, int flag) * Pushes the opstack down one level * and allocates a new flag layer if * appropriate. - * -*/ - + */ void BMO_push(BMesh *bm, BMOperator *UNUSED(op)) { bm->stackdepth++; @@ -89,8 +87,7 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op)) * and frees a flag layer if appropriate * BMESH_TODO: investigate NOT freeing flag * layers. - * -*/ + */ void BMO_pop(BMesh *bm) { if(bm->stackdepth > 1) @@ -104,9 +101,7 @@ void BMO_pop(BMesh *bm) * * Initializes an operator structure * to a certain type - * -*/ - + */ void BMO_Init_Op(BMOperator *op, const char *opname) { int i, opcode = bmesh_opname_to_opcode(opname); @@ -130,16 +125,14 @@ void BMO_Init_Op(BMOperator *op, const char *opname) } /* - * BMESH OPSTACK EXEC OP + * BMESH OPSTACK EXEC OP * - * Executes a passed in operator. This handles - * the allocation and freeing of temporary flag - * layers and starting/stopping the modelling - * loop. Can be called from other operators - * exec callbacks as well. - * -*/ - + * Executes a passed in operator. This handles + * the allocation and freeing of temporary flag + * layers and starting/stopping the modelling + * loop. Can be called from other operators + * exec callbacks as well. + */ void BMO_Exec_Op(BMesh *bm, BMOperator *op) { @@ -156,13 +149,11 @@ void BMO_Exec_Op(BMesh *bm, BMOperator *op) } /* - * BMESH OPSTACK FINISH OP + * BMESH OPSTACK FINISH OP * - * Does housekeeping chores related to finishing - * up an operator. - * -*/ - + * Does housekeeping chores related to finishing + * up an operator. + */ void BMO_Finish_Op(BMesh *UNUSED(bm), BMOperator *op) { BMOpSlot *slot; @@ -184,9 +175,7 @@ void BMO_Finish_Op(BMesh *UNUSED(bm), BMOperator *op) * * Returns 1 if the named slot exists on the given operator, * otherwise returns 0. - * -*/ - + */ int BMO_HasSlot(BMOperator *op, const char *slotname) { int slotcode = bmesh_name_to_slotcode(opdefines[op->type], slotname); @@ -198,9 +187,7 @@ int BMO_HasSlot(BMOperator *op, const char *slotname) * * Returns a pointer to the slot of * type 'slotcode' - * -*/ - + */ BMOpSlot *BMO_GetSlot(BMOperator *op, const char *slotname) { int slotcode = bmesh_name_to_slotcode_check(opdefines[op->type], slotname); @@ -215,10 +202,8 @@ BMOpSlot *BMO_GetSlot(BMOperator *op, const char *slotname) /* * BMESH OPSTACK COPY SLOT * - * Copies data from one slot to another - * -*/ - + * Copies data from one slot to another + */ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, const char *dst) { BMOpSlot *source_slot = BMO_GetSlot(source_op, src); @@ -402,25 +387,25 @@ void BMO_Get_Vec(BMOperator *op, const char *slotname, float *vec_out) * */ -int BMO_CountFlag(BMesh *bm, int flag, int type) +int BMO_CountFlag(BMesh *bm, int flag, const char htype) { BMIter elements; BMHeader *e; int count = 0; - if(type & BM_VERT){ + if(htype & BM_VERT){ for(e = BMIter_New(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BMIter_Step(&elements)){ if(BMO_TestFlag(bm, e, flag)) count++; } } - if(type & BM_EDGE){ + if(htype & BM_EDGE){ for(e = BMIter_New(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&elements)){ if(BMO_TestFlag(bm, e, flag)) count++; } } - if(type & BM_FACE){ + if(htype & BM_FACE){ for(e = BMIter_New(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BMIter_Step(&elements)){ if(BMO_TestFlag(bm, e, flag)) count++; @@ -430,17 +415,17 @@ int BMO_CountFlag(BMesh *bm, int flag, int type) return count; } -void BMO_Clear_Flag_All(BMesh *bm, BMOperator *UNUSED(op), int type, int flag) { +void BMO_Clear_Flag_All(BMesh *bm, BMOperator *UNUSED(op), const char htype, int flag) { BMIter iter; BMHeader *ele; int i=0, types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH}; for (i=0; i<3; i++) { - if (i==0 && !(type & BM_VERT)) + if (i==0 && !(htype & BM_VERT)) continue; - if (i==1 && !(type & BM_EDGE)) + if (i==1 && !(htype & BM_EDGE)) continue; - if (i==2 && !(type & BM_FACE)) + if (i==2 && !(htype & BM_FACE)) continue; BM_ITER(ele, &iter, bm, types[i], NULL) { @@ -543,35 +528,35 @@ static void *alloc_slot_buffer(BMOperator *op, const char *slotname, int len){ * */ -static void BMO_All_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, int type) +static void BMO_All_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, const char htype) { BMIter elements; BMHeader *e; BMOpSlot *output = BMO_GetSlot(op, slotname); int totelement=0, i=0; - if (type & BM_VERT) totelement += bm->totvert; - if (type & BM_EDGE) totelement += bm->totedge; - if (type & BM_FACE) totelement += bm->totface; + if (htype & BM_VERT) totelement += bm->totvert; + if (htype & BM_EDGE) totelement += bm->totedge; + if (htype & BM_FACE) totelement += bm->totface; if(totelement){ alloc_slot_buffer(op, slotname, totelement); - if (type & BM_VERT) { + if (htype & BM_VERT) { for (e = BMIter_New(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BMIter_Step(&elements)) { ((BMHeader**)output->data.p)[i] = e; i++; } } - if (type & BM_EDGE) { + if (htype & BM_EDGE) { for (e = BMIter_New(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { ((BMHeader**)output->data.p)[i] = e; i++; } } - if (type & BM_FACE) { + if (htype & BM_FACE) { for (e = BMIter_New(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { ((BMHeader**)output->data.p)[i] = e; i++; @@ -589,39 +574,40 @@ static void BMO_All_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, int * */ -void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, int flag, int type) +void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, + const char hflag, const char htype) { BMIter elements; BMHeader *e; BMOpSlot *output = BMO_GetSlot(op, slotname); int totelement=0, i=0; - totelement = BM_CountFlag(bm, type, flag, 1); + totelement = BM_CountFlag(bm, htype, hflag, 1); if(totelement){ alloc_slot_buffer(op, slotname, totelement); - if (type & BM_VERT) { + if (htype & BM_VERT) { for (e = BMIter_New(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, flag)) { + if(!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, hflag)) { ((BMHeader**)output->data.p)[i] = e; i++; } } } - if (type & BM_EDGE) { + if (htype & BM_EDGE) { for (e = BMIter_New(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, flag)) { + if(!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, hflag)) { ((BMHeader**)output->data.p)[i] = e; i++; } } } - if (type & BM_FACE) { + if (htype & BM_FACE) { for (e = BMIter_New(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, flag)) { + if(!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, hflag)) { ((BMHeader**)output->data.p)[i] = e; i++; } @@ -638,19 +624,19 @@ void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, int * * Copies elements of a certain type, which have a certain flag set * into an output slot for an operator. - * -*/ -void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, int flag, int type) + */ +void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, + int flag, const char htype) { BMIter elements; BMHeader *e; BMOpSlot *output = BMO_GetSlot(op, slotname); - int totelement = BMO_CountFlag(bm, flag, type), i=0; + int totelement = BMO_CountFlag(bm, flag, htype), i=0; if(totelement){ alloc_slot_buffer(op, slotname, totelement); - if (type & BM_VERT) { + if (htype & BM_VERT) { for (e = BMIter_New(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BMIter_Step(&elements)) { if(BMO_TestFlag(bm, e, flag)){ ((BMHeader**)output->data.p)[i] = e; @@ -659,7 +645,7 @@ void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, int flag, } } - if (type & BM_EDGE) { + if (htype & BM_EDGE) { for (e = BMIter_New(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { if(BMO_TestFlag(bm, e, flag)){ ((BMHeader**)output->data.p)[i] = e; @@ -668,7 +654,7 @@ void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, int flag, } } - if (type & BM_FACE) { + if (htype & BM_FACE) { for (e = BMIter_New(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { if(BMO_TestFlag(bm, e, flag)){ ((BMHeader**)output->data.p)[i] = e; @@ -687,23 +673,22 @@ void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, int flag, * * Header Flags elements in a slots buffer, automatically * using the selection API where appropriate. - * -*/ - -void BMO_HeaderFlag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, int flag, int type) + */ +void BMO_HeaderFlag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, + const char hflag, const char htype) { BMOpSlot *slot = BMO_GetSlot(op, slotname); BMHeader **data = slot->data.p; int i; for(i = 0; i < slot->len; i++) { - if (!(type & data[i]->type)) + if (!(htype & data[i]->htype)) continue; - if (flag & BM_SELECT) { + if (hflag & BM_SELECT) { BM_Select(bm, data[i], 1); } - BM_SetHFlag(data[i], flag); + BM_SetHFlag(data[i], hflag); } } @@ -713,25 +698,23 @@ void BMO_HeaderFlag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, int * * Removes flags from elements in a slots buffer, automatically * using the selection API where appropriate. - * -*/ - -void BMO_UnHeaderFlag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, int flag, int type) + */ +void BMO_UnHeaderFlag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, + const char hflag, const char htype) { BMOpSlot *slot = BMO_GetSlot(op, slotname); BMHeader **data = slot->data.p; int i; for(i = 0; i < slot->len; i++) { - if (!(type & data[i]->type)) + if (!(htype & data[i]->htype)) continue; - if (flag & BM_SELECT) + if (hflag & BM_SELECT) BM_Select(bm, data[i], 0); - BM_ClearHFlag(data[i], flag); + BM_ClearHFlag(data[i], hflag); } } - int BMO_Vert_CountEdgeFlags(BMesh *bm, BMVert *v, int toolflag) { int count= 0; @@ -756,20 +739,19 @@ int BMO_Vert_CountEdgeFlags(BMesh *bm, BMVert *v, int toolflag) * BMO_FLAG_BUFFER * * Flags elements in a slots buffer - * -*/ - -void BMO_Flag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, int flag, int type) + */ +void BMO_Flag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, + const int hflag, const char htype) { BMOpSlot *slot = BMO_GetSlot(op, slotname); BMHeader **data = slot->data.p; int i; for(i = 0; i < slot->len; i++) { - if (!(type & data[i]->type)) + if (!(htype & data[i]->htype)) continue; - BMO_SetFlag(bm, data[i], flag); + BMO_SetFlag(bm, data[i], hflag); } } @@ -778,17 +760,16 @@ void BMO_Flag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, int flag, * BMO_FLAG_BUFFER * * Removes flags from elements in a slots buffer - * -*/ - -void BMO_Unflag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, int flag, int type) + */ +void BMO_Unflag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, + const int flag, const char htype) { BMOpSlot *slot = BMO_GetSlot(op, slotname); BMHeader **data = slot->data.p; int i; for(i = 0; i < slot->len; i++) { - if (!(type & data[i]->type)) + if (!(htype & data[i]->htype)) continue; BMO_ClearFlag(bm, data[i], flag); @@ -809,9 +790,7 @@ void BMO_Unflag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, int flag * Investigate not freeing flag layers until * all operators have been executed. This would * save a lot of realloc potentially. - * -*/ - + */ static void alloc_flag_layer(BMesh *bm) { BMVert *v; @@ -919,7 +898,7 @@ void *BMO_FirstElem(BMOperator *op, const char *slotname) } void *BMO_IterNew(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, - const char *slotname, int restrictmask) + const char *slotname, const char restrictmask) { BMOpSlot *slot = BMO_GetSlot(op, slotname); @@ -946,7 +925,7 @@ void *BMO_IterStep(BMOIter *iter) if (iter->cur >= iter->slot->len) return NULL; h = ((void**)iter->slot->data.buf)[iter->cur++]; - while (!(iter->restrictmask & h->type)) { + while (!(iter->restrictmask & h->htype)) { if (iter->cur >= iter->slot->len) return NULL; h = ((void**)iter->slot->data.buf)[iter->cur++]; } @@ -1322,8 +1301,7 @@ int BMO_CallOpf(BMesh *bm, const char *fmt, ...) { * BMO_TOGGLEFLAG * * Toggles a flag for a certain element - * -*/ + */ #ifdef BMO_ToggleFlag #undef BMO_ToggleFlag #endif @@ -1337,14 +1315,13 @@ static void BMO_ToggleFlag(BMesh *bm, void *element, int flag) * BMO_SETFLAG * * Sets a flag for a certain element - * -*/ + */ #ifdef BMO_SetFlag #undef BMO_SetFlag #endif -static void BMO_SetFlag(BMesh *bm, void *element, int flag) +static void BMO_SetFlag(BMesh *bm, void *element, const int flag) { - BMHeader *head = element; + BMHeader *head= element; head->flags[bm->stackdepth-1].f |= flag; } @@ -1352,15 +1329,13 @@ static void BMO_SetFlag(BMesh *bm, void *element, int flag) * BMO_CLEARFLAG * * Clears a specific flag from a given element - * -*/ - + */ #ifdef BMO_ClearFlag #undef BMO_ClearFlag #endif -static void BMO_ClearFlag(BMesh *bm, void *element, int flag) +static void BMO_ClearFlag(BMesh *bm, void *element, const int flag) { - BMHeader *head = element; + BMHeader *head= element; head->flags[bm->stackdepth-1].f &= ~flag; } @@ -1369,9 +1344,7 @@ static void BMO_ClearFlag(BMesh *bm, void *element, int flag) * * Tests whether or not a flag is set for a specific element * - * -*/ - + */ #ifdef BMO_TestFlag #undef BMO_TestFlag #endif diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h index fb94aa1d9b2..6907c810807 100644 --- a/source/blender/bmesh/intern/bmesh_private.h +++ b/source/blender/bmesh/intern/bmesh_private.h @@ -39,14 +39,22 @@ struct Link; struct BMLoop; -/*returns positive nonzero on error*/ -int bmesh_check_element(BMesh *bm, void *element, int type); +/* returns positive nonzero on error */ +int bmesh_check_element(BMesh *bm, void *element, const char htype); -#define CHECK_ELEMENT(bm, el) \ -if (bmesh_check_element(bm, el, ((BMHeader*)el)->type))\ - printf("check_element failure, with code %i on line %i in file\n \"%s\"\n\n", bmesh_check_element(bm, el, ((BMHeader*)el)->type), __LINE__, __FILE__); +#define BM_CHECK_ELEMENT(bm, el) \ + if (bmesh_check_element(bm, el, ((BMHeader*)el)->htype)) { \ + printf("check_element failure, with code %i on line %i in file\n" \ + " \"%s\"\n\n", \ + bmesh_check_element(bm, el, ((BMHeader*)el)->htype), \ + __LINE__, __FILE__); \ + } -#define bm_get_edge_link(e, v) (((v) == ((BMEdge*)(e))->v1) ? (Link*)&(((BMEdge*)(e))->dlink1) : (Link*)&(((BMEdge*)(e))->dlink2)) +#define bm_get_edge_link(e, v) ( \ + ((v) == ((BMEdge*)(e))->v1) ? \ + (Link *)&(((BMEdge*)(e))->dlink1) : \ + (Link *)&(((BMEdge*)(e))->dlink2) \ + ) int bmesh_radial_length(struct BMLoop *l); int bmesh_disk_count(BMVert *v); diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 2d2c25c779d..2f2a5318d0f 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -32,11 +32,11 @@ * */ -int BM_Count_Element(BMesh *bm, int type) +int BM_Count_Element(BMesh *bm, const char htype) { - if(type == BM_VERT) return bm->totvert; - else if(type == BM_EDGE) return bm->totedge; - else if(type == BM_FACE) return bm->totface; + if(htype == BM_VERT) return bm->totvert; + else if(htype == BM_EDGE) return bm->totedge; + else if(htype == BM_FACE) return bm->totface; return 0; } diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index f85a9ea47f5..97b923660af 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -80,7 +80,7 @@ static void shellWalker_begin(BMWalker *walker, void *data){ return; } - switch (h->type) { + switch (h->htype) { case BM_VERT: { /* starting the walk at a vert, add all the edges diff --git a/source/blender/bmesh/operators/bmesh_dupeops.c b/source/blender/bmesh/operators/bmesh_dupeops.c index 04d93b2ea1b..4990bd90c89 100644 --- a/source/blender/bmesh/operators/bmesh_dupeops.c +++ b/source/blender/bmesh/operators/bmesh_dupeops.c @@ -318,12 +318,12 @@ void dupeop_exec(BMesh *bm, BMOperator *op) type flag etypeflag and header flag flag to it. note, to get more useful information (such as the mapping from original to new elements) you should run the dupe op manually.*/ -void BMOP_DupeFromFlag(BMesh *bm, int etypeflag, int flag) +void BMOP_DupeFromFlag(BMesh *bm, int etypeflag, const char hflag) { BMOperator dupeop; BMO_Init_Op(&dupeop, "dupe"); - BMO_HeaderFlag_To_Slot(bm, &dupeop, "geom", flag, etypeflag); + BMO_HeaderFlag_To_Slot(bm, &dupeop, "geom", hflag, etypeflag); BMO_Exec_Op(bm, &dupeop); BMO_Finish_Op(bm, &dupeop); @@ -483,7 +483,8 @@ static void delete_edges(BMesh *bm){ /*Break this into smaller functions*/ -static void delete_context(BMesh *bm, int type){ +static void delete_context(BMesh *bm, int type) +{ BMVert *v; BMEdge *e; BMFace *f; diff --git a/source/blender/bmesh/operators/createops.c b/source/blender/bmesh/operators/createops.c index bddbe8c477f..f27aac28359 100644 --- a/source/blender/bmesh/operators/createops.c +++ b/source/blender/bmesh/operators/createops.c @@ -1165,7 +1165,7 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) /*count number of each element type we were passed*/ BMO_ITER(h, &oiter, bm, op, "geom", BM_VERT|BM_EDGE|BM_FACE) { - switch (h->type) { + switch (h->htype) { case BM_VERT: totv++; break; case BM_EDGE: tote++; break; case BM_FACE: totf++; break; diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c index 1dfde8d07a5..66c494f2a40 100644 --- a/source/blender/bmesh/operators/mesh_conv.c +++ b/source/blender/bmesh/operators/mesh_conv.c @@ -133,10 +133,10 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { BM_SetIndex(v, i); /*transfer flags*/ - v->head.flag = MEFlags_To_BMFlags(mvert->flag, BM_VERT); + v->head.hflag = MEFlags_To_BMFlags(mvert->flag, BM_VERT); /*this is necassary for selection counts to work properly*/ - if(v->head.flag & BM_SELECT) BM_Select_Vert(bm, v, 1); + if (BM_TestHFlag(v, BM_SELECT)) BM_Select_Vert(bm, v, 1); BM_SetCDf(&bm->vdata, v, CD_BWEIGHT, (float)mvert->bweight / 255.0f); @@ -179,10 +179,10 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { BM_SetCDf(&bm->edata, e, CD_BWEIGHT, (float)medge->bweight / 255.0f); /*transfer flags*/ - e->head.flag = MEFlags_To_BMFlags(medge->flag, BM_EDGE); + e->head.hflag = MEFlags_To_BMFlags(medge->flag, BM_EDGE); /*this is necassary for selection counts to work properly*/ - if (e->head.flag & BM_SELECT) BM_Select(bm, e, 1); + if (BM_TestHFlag(e, BM_SELECT)) BM_Select(bm, e, 1); } if (!me->totpoly) { @@ -230,10 +230,10 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { } /*transfer flags*/ - f->head.flag = MEFlags_To_BMFlags(mpoly->flag, BM_FACE); + f->head.hflag = MEFlags_To_BMFlags(mpoly->flag, BM_FACE); /*this is necassary for selection counts to work properly*/ - if (f->head.flag & BM_SELECT) BM_Select(bm, f, 1); + if (BM_TestHFlag(f, BM_SELECT)) BM_Select(bm, f, 1); f->mat_nr = mpoly->mat_nr; if (i == me->act_face) bm->act_face = f; @@ -508,7 +508,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { i++; mvert++; - CHECK_ELEMENT(bm, v); + BM_CHECK_ELEMENT(bm, v); } i = 0; @@ -530,7 +530,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { i++; medge++; - CHECK_ELEMENT(bm, e); + BM_CHECK_ELEMENT(bm, e); } /*new scanfill tesselation code*/ @@ -653,9 +653,9 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { /*copy over customdata*/ CustomData_from_bmesh_block(&bm->ldata, &me->ldata, l->head.data, j); - CHECK_ELEMENT(bm, l); - CHECK_ELEMENT(bm, l->e); - CHECK_ELEMENT(bm, l->v); + BM_CHECK_ELEMENT(bm, l); + BM_CHECK_ELEMENT(bm, l->e); + BM_CHECK_ELEMENT(bm, l->v); } if (f == bm->act_face) me->act_face = i; @@ -665,7 +665,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { i++; mpoly++; - CHECK_ELEMENT(bm, f); + BM_CHECK_ELEMENT(bm, f); } /* patch hook indices and vertex parents */ @@ -737,13 +737,13 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { for(i = 0, selected = bm->selected.first; selected; i++, selected = selected->next){ - if(selected->type == BM_VERT){ + if(selected->htype == BM_VERT){ me->mselect[i].type = ME_VSEL; - }else if(selected->type == BM_EDGE){ + }else if(selected->htype == BM_EDGE){ me->mselect[i].type = ME_ESEL; - }else if(selected->type == BM_FACE){ + }else if(selected->htype == BM_FACE){ me->mselect[i].type = ME_FSEL; } diff --git a/source/blender/bmesh/operators/subdivideop.c b/source/blender/bmesh/operators/subdivideop.c index 762a5e3f867..6a694961eea 100644 --- a/source/blender/bmesh/operators/subdivideop.c +++ b/source/blender/bmesh/operators/subdivideop.c @@ -322,9 +322,9 @@ static void bm_subdivide_multicut(BMesh *bm, BMEdge *edge, const subdparams *par BMO_SetFlag(bm, eed, ELE_SPLIT); BMO_SetFlag(bm, newe, SUBD_SPLIT); - CHECK_ELEMENT(bm, v); - if (v->e) CHECK_ELEMENT(bm, v->e); - if (v->e && v->e->l) CHECK_ELEMENT(bm, v->e->l->f); + BM_CHECK_ELEMENT(bm, v); + if (v->e) BM_CHECK_ELEMENT(bm, v->e); + if (v->e && v->e->l) BM_CHECK_ELEMENT(bm, v->e->l->f); } alter_co(bm, v1, &temp, params, 0, &ov1, &ov2); @@ -1064,7 +1064,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) j += 1; } - CHECK_ELEMENT(bmesh, face); + BM_CHECK_ELEMENT(bmesh, face); pat->connectexec(bmesh, face, verts, ¶ms); } @@ -1128,7 +1128,7 @@ void BM_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth for (; ele; ele=BMO_IterStep(&iter)) { BM_Select(bm, ele, 1); - if (ele->type == BM_VERT) { + if (ele->htype == BM_VERT) { BMEdge *e; BMIter eiter; diff --git a/source/blender/bmesh/tools/BME_extrude.c b/source/blender/bmesh/tools/BME_extrude.c index 70baff2adf6..14efd731561 100644 --- a/source/blender/bmesh/tools/BME_extrude.c +++ b/source/blender/bmesh/tools/BME_extrude.c @@ -152,8 +152,8 @@ void BME_cap_skirt(BME_Mesh *bm, GHash *vhash, GHash *ehash){ } /*unified extrude code*/ -void BME_extrude_mesh(BME_Mesh *bm, int type){ - +void BME_extrude_mesh(BME_Mesh *bm, int type) +{ BMVert *v; BMEdge *e; BMFace *f; diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 69c3ef41ee7..6aa41112491 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -191,8 +191,8 @@ void EM_add_data_layer(struct BMEditMesh *em, struct CustomData *data, int type void EM_free_data_layer(struct BMEditMesh *em, struct CustomData *data, int type); void EDBM_toggle_select_all(struct BMEditMesh *em); -void EDBM_set_flag_all(struct BMEditMesh *em, int flag); -void EDBM_clear_flag_all(struct BMEditMesh *em, int flag); +void EDBM_set_flag_all(struct BMEditMesh *em, const char hflag); +void EDBM_clear_flag_all(struct BMEditMesh *em, const char hflag); void EDBM_automerge(struct Scene *scene, struct Object *ob, int update); /* editmesh_mods.c */ diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index 0122fe2b230..05eeea846f6 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -1368,11 +1368,11 @@ static void mouse_mesh_shortest_path(bContext *C, int mval[2]) int path = 0; if (em->bm->selected.last) { - EditSelection *ese = em->bm->selected.last; + BMEditSelection *ese= em->bm->selected.last; - if(ese && ese->type == BM_EDGE) { + if(ese && ese->htype == BM_EDGE) { BMEdge *e_act; - e_act = (BMEdge*)ese->data; + e_act = (BMEdge *)ese->data; if (e_act != e) { if (edgetag_shortest_path(vc.scene, em, e_act, e)) { EDBM_remove_selection(em, e_act); @@ -1523,7 +1523,7 @@ static void EDBM_strip_selections(BMEditMesh *em) ese = em->bm->selected.first; while(ese){ nextese = ese->next; - if(ese->type == BM_VERT) BLI_freelinkN(&(em->bm->selected),ese); + if(ese->htype == BM_VERT) BLI_freelinkN(&(em->bm->selected),ese); ese = nextese; } } @@ -1531,7 +1531,7 @@ static void EDBM_strip_selections(BMEditMesh *em) ese=em->bm->selected.first; while(ese){ nextese = ese->next; - if(ese->type == BM_EDGE) BLI_freelinkN(&(em->bm->selected), ese); + if(ese->htype == BM_EDGE) BLI_freelinkN(&(em->bm->selected), ese); ese = nextese; } } @@ -1539,7 +1539,7 @@ static void EDBM_strip_selections(BMEditMesh *em) ese=em->bm->selected.first; while(ese){ nextese = ese->next; - if(ese->type == BM_FACE) BLI_freelinkN(&(em->bm->selected), ese); + if(ese->htype == BM_FACE) BLI_freelinkN(&(em->bm->selected), ese); ese = nextese; } } @@ -1953,7 +1953,7 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h /* Determine which type of iter, walker, and select flush to use based on type of the elements being deselected */ - switch (h_act->type) { + switch (h_act->htype) { case BM_VERT: itertype = BM_VERTS_OF_MESH; walktype = BMW_CONNECTED_VERTEX; @@ -2013,7 +2013,7 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **v_p, BMEdge **e_p, BMFa ese= (BMEditSelection*)em->bm->selected.last; if(ese) { - switch(ese->type) { + switch(ese->htype) { case BM_VERT: *v_p= (BMVert *)ese->data; return; diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 4522cae5353..74484659b12 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -198,7 +198,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMes /* individual face extrude */ /* will use vertex normals for extrusion directions, so *nor is unaffected */ -static short EDBM_Extrude_face_indiv(BMEditMesh *em, wmOperator *op, short flag, float *UNUSED(nor)) +static short EDBM_Extrude_face_indiv(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor)) { BMOIter siter; BMIter liter; @@ -206,7 +206,7 @@ static short EDBM_Extrude_face_indiv(BMEditMesh *em, wmOperator *op, short flag, BMLoop *l; BMOperator bmop; - EDBM_InitOpf(em, &bmop, op, "extrude_face_indiv faces=%hf", flag); + EDBM_InitOpf(em, &bmop, op, "extrude_face_indiv faces=%hf", hflag); /*deselect original verts*/ EDBM_clear_flag_all(em, BM_SELECT); @@ -228,11 +228,11 @@ static short EDBM_Extrude_face_indiv(BMEditMesh *em, wmOperator *op, short flag, } /* extrudes individual edges */ -static short EDBM_Extrude_edges_indiv(BMEditMesh *em, wmOperator *op, short flag, float *UNUSED(nor)) +static short EDBM_Extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor)) { BMOperator bmop; - EDBM_InitOpf(em, &bmop, op, "extrude_edge_only edges=%he", flag); + EDBM_InitOpf(em, &bmop, op, "extrude_edge_only edges=%he", hflag); /*deselect original verts*/ EDBM_clear_flag_all(em, BM_SELECT); @@ -246,11 +246,11 @@ static short EDBM_Extrude_edges_indiv(BMEditMesh *em, wmOperator *op, short flag } /* extrudes individual vertices */ -static short EDBM_Extrude_verts_indiv(BMEditMesh *em, wmOperator *op, short flag, float *UNUSED(nor)) +static short EDBM_Extrude_verts_indiv(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor)) { BMOperator bmop; - EDBM_InitOpf(em, &bmop, op, "extrude_vert_indiv verts=%hv", flag); + EDBM_InitOpf(em, &bmop, op, "extrude_vert_indiv verts=%hv", hflag); /*deselect original verts*/ BMO_UnHeaderFlag_Buffer(em->bm, &bmop, "verts", BM_SELECT, BM_VERT); @@ -263,7 +263,7 @@ static short EDBM_Extrude_verts_indiv(BMEditMesh *em, wmOperator *op, short flag return 'g'; // g is grab } -static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, int flag, float *nor) +static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, float *nor) { BMesh *bm = em->bm; BMIter iter; @@ -276,7 +276,7 @@ static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, int flag, float * BMO_Init_Op(&extop, "extrudefaceregion"); BMO_HeaderFlag_To_Slot(bm, &extop, "edgefacein", - flag, BM_VERT|BM_EDGE|BM_FACE); + hflag, BM_VERT|BM_EDGE|BM_FACE); /* If a mirror modifier with clipping is on, we need to adjust some * of the cases above to handle edges on the line of symmetry. @@ -297,7 +297,7 @@ static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, int flag, float * for (edge=BMIter_New(&iter,bm,BM_EDGES_OF_MESH,NULL); edge; edge=BMIter_Step(&iter)) { - if(edge->head.flag & flag) { + if (BM_TestHFlag(edge, hflag)) { float co1[3], co2[3]; copy_v3_v3(co1, edge->v1->co); @@ -337,7 +337,7 @@ static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, int flag, float * BMO_ITER(el, &siter, bm, &extop, "geomout", BM_ALL) { BM_Select(bm, el, 1); - if (el->type == BM_FACE) { + if (el->htype == BM_FACE) { f = (BMFace*)el; add_normal_aligned(nor, f->no); }; @@ -351,7 +351,7 @@ static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, int flag, float * return 'n'; // normal constraint } -static short EDBM_Extrude_vert(Object *obedit, BMEditMesh *em, short flag, float *nor) +static short EDBM_Extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, float *nor) { BMIter iter; BMEdge *eed; @@ -359,26 +359,26 @@ static short EDBM_Extrude_vert(Object *obedit, BMEditMesh *em, short flag, float /*ensure vert flags are consistent for edge selections*/ eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); for ( ; eed; eed=BMIter_Step(&iter)) { - if (BM_TestHFlag(eed, flag)) { - if (flag & BM_SELECT) { + if (BM_TestHFlag(eed, hflag)) { + if (hflag & BM_SELECT) { BM_Select(em->bm, eed->v1, 1); BM_Select(em->bm, eed->v2, 1); } - BM_SetHFlag(eed->v1, flag & ~BM_SELECT); - BM_SetHFlag(eed->v2, flag & ~BM_SELECT); + BM_SetHFlag(eed->v1, hflag & ~BM_SELECT); + BM_SetHFlag(eed->v2, hflag & ~BM_SELECT); } else { - if (BM_TestHFlag(eed->v1, flag) && BM_TestHFlag(eed->v2, flag)) { - if (flag & BM_SELECT) { + if (BM_TestHFlag(eed->v1, hflag) && BM_TestHFlag(eed->v2, hflag)) { + if (hflag & BM_SELECT) { BM_Select(em->bm, eed, 1); } - BM_SetHFlag(eed, flag & ~BM_SELECT); + BM_SetHFlag(eed, hflag & ~BM_SELECT); } } } - return EDBM_Extrude_edge(obedit, em, flag, nor); + return EDBM_Extrude_edge(obedit, em, hflag, nor); } static int extrude_repeat_mesh(bContext *C, wmOperator *op) @@ -2156,13 +2156,13 @@ static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), if(em->selectmode & SCE_SELECT_VERTEX) { if(em->bm->selected.first && em->bm->selected.last && - ((BMEditSelection*)em->bm->selected.first)->type == BM_VERT && ((BMEditSelection*)em->bm->selected.last)->type == BM_VERT) { + ((BMEditSelection*)em->bm->selected.first)->htype == BM_VERT && ((BMEditSelection*)em->bm->selected.last)->htype == BM_VERT) { RNA_enum_items_add_value(&item, &totitem, merge_type_items, 6); RNA_enum_items_add_value(&item, &totitem, merge_type_items, 1); } - else if(em->bm->selected.first && ((BMEditSelection*)em->bm->selected.first)->type == BM_VERT) + else if(em->bm->selected.first && ((BMEditSelection*)em->bm->selected.first)->htype == BM_VERT) RNA_enum_items_add_value(&item, &totitem, merge_type_items, 1); - else if(em->bm->selected.last && ((BMEditSelection*)em->bm->selected.last)->type == BM_VERT) + else if(em->bm->selected.last && ((BMEditSelection*)em->bm->selected.last)->htype == BM_VERT) RNA_enum_items_add_value(&item, &totitem, merge_type_items, 6); } @@ -2287,7 +2287,7 @@ static int select_vertex_path_exec(bContext *C, wmOperator *op) if( ev == NULL ) return OPERATOR_CANCELLED; - if( sv->type != BM_VERT || ev->type != BM_VERT ) + if((sv->htype != BM_VERT) || (ev->htype != BM_VERT)) return OPERATOR_CANCELLED; /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ @@ -2763,7 +2763,7 @@ static int select_axis_exec(bContext *C, wmOperator *op) if(ese==NULL) return OPERATOR_CANCELLED; - if(ese->type==BM_VERT) { + if (ese->htype==BM_VERT) { BMVert *ev, *act_vert= (BMVert*)ese->data; BMIter iter; float value= act_vert->co[axis]; diff --git a/source/blender/editors/mesh/bmeshutils.c b/source/blender/editors/mesh/bmeshutils.c index 72091db7abb..969e4e8cb04 100644 --- a/source/blender/editors/mesh/bmeshutils.c +++ b/source/blender/editors/mesh/bmeshutils.c @@ -441,82 +441,63 @@ int EDBM_get_actSelection(BMEditMesh *em, BMEditSelection *ese) ese->next = ese->prev = NULL; if (ese_last) { - if (ese_last->type == BM_FACE) { /* if there is an active face, use it over the last selected face */ + if (ese_last->htype == BM_FACE) { /* if there is an active face, use it over the last selected face */ if (efa) { ese->data = (void *)efa; } else { ese->data = ese_last->data; } - ese->type = BM_FACE; - } else { + ese->htype = BM_FACE; + } + else { ese->data = ese_last->data; - ese->type = ese_last->type; + ese->htype = ese_last->htype; } - } else if (efa) { /* no */ - ese->data = (void *)efa; - ese->type = BM_FACE; - } else { + } + else if (efa) { /* no */ + ese->data= (void *)efa; + ese->htype= BM_FACE; + } + else { ese->data = NULL; return 0; } return 1; } -void EDBM_clear_flag_all(BMEditMesh *em, int flag) +void EDBM_clear_flag_all(BMEditMesh *em, const char hflag) { + int types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH}; BMIter iter; BMHeader *ele; - int i, type; + int i; - if (flag & BM_SELECT) + if (hflag & BM_SELECT) BM_clear_selection_history(em->bm); for (i=0; i<3; i++) { - switch (i) { - case 0: - type = BM_VERTS_OF_MESH; - break; - case 1: - type = BM_EDGES_OF_MESH; - break; - case 2: - type = BM_FACES_OF_MESH; - break; - } - - BM_ITER(ele, &iter, em->bm, type, NULL) { - if (flag & BM_SELECT) BM_Select(em->bm, ele, 0); - BM_ClearHFlag(ele, flag); + BM_ITER(ele, &iter, em->bm, types[i], NULL) { + if (hflag & BM_SELECT) BM_Select(em->bm, ele, 0); + BM_ClearHFlag(ele, hflag); } } } -void EDBM_set_flag_all(BMEditMesh *em, int flag) +void EDBM_set_flag_all(BMEditMesh *em, const char hflag) { + int types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH}; BMIter iter; BMHeader *ele; - int i, type; + int i; for (i=0; i<3; i++) { - switch (i) { - case 0: - type = BM_VERTS_OF_MESH; - break; - case 1: - type = BM_EDGES_OF_MESH; - break; - case 2: - type = BM_FACES_OF_MESH; - break; - } - - ele = BMIter_New(&iter, em->bm, type, NULL); + ele= BMIter_New(&iter, em->bm, types[i], NULL); for ( ; ele; ele=BMIter_Step(&iter)) { - if (flag & BM_SELECT) { + if (hflag & BM_SELECT) { BM_Select(em->bm, ele, 1); } else { - BM_SetHFlag(ele, flag); + BM_SetHFlag(ele, hflag); } } } diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 85133349af5..207ef32c50e 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -87,7 +87,7 @@ int EDBM_InitOpf(struct BMEditMesh *em, struct BMOperator *bmop, int EDBM_FinishOp(struct BMEditMesh *em, struct BMOperator *bmop, struct wmOperator *op, int report); -void EDBM_clear_flag_all(struct BMEditMesh *em, int flag); +void EDBM_clear_flag_all(struct BMEditMesh *em, const char hflag); void EDBM_store_selection(struct BMEditMesh *em, void *data); void EDBM_validate_selections(struct BMEditMesh *em); void EDBM_remove_selection(struct BMEditMesh *em, void *data); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 13c89de374e..a4dc1a8b012 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2570,13 +2570,13 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object BMVert *eve_act = NULL; if (em->bm->selected.last) { - BMEditSelection *ese = em->bm->selected.last; + BMEditSelection *ese= em->bm->selected.last; /* face is handeled above */ /*if (ese->type == BM_FACE ) { efa_act = (BMFace *)ese->data; - } else */ if ( ese->type == BM_EDGE ) { + } else */ if ( ese->htype == BM_EDGE ) { eed_act = (BMEdge *)ese->data; - } else if ( ese->type == BM_VERT ) { + } else if ( ese->htype == BM_VERT ) { eve_act = (BMVert *)ese->data; } } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 5c31067c284..e6aa560182b 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -598,9 +598,9 @@ static void act_vert_def(Object *ob, BMVert **eve, MDeformVert **dvert) if(ob && ob->mode & OB_MODE_EDIT && ob->type==OB_MESH && ob->defbase.first) { Mesh *me= ob->data; BMEditMesh *em = me->edit_btmesh; - BMEditSelection *ese = ((BMEditSelection*)em->bm->selected.last); + BMEditSelection *ese= (BMEditSelection*)em->bm->selected.last; - if(ese && ese->type == BM_VERT) { + if(ese && ese->htype == BM_VERT) { *eve= (BMVert*)ese->data; *dvert= CustomData_bmesh_get(&em->bm->vdata, (*eve)->head.data, CD_MDEFORMVERT); return; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index a3115156e6f..5b8b1ada1dd 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2153,7 +2153,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) /* check active */ if (em->bm->selected.last) { BMEditSelection *ese = em->bm->selected.last; - if ( ese->type == BM_VERT ) { + if (ese->htype == BM_VERT) { eve_act = (BMVert *)ese->data; } } diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 440d40ef0c3..d532d7d350b 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -584,7 +584,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], EDBM_editselection_normal(normal, &ese); EDBM_editselection_plane(em, plane, &ese); - switch (ese.type) + switch (ese.htype) { case BM_VERT: result = ORIENTATION_VERT; |