diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-14 20:42:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-14 20:42:43 +0400 |
commit | b27854bd47104300a484e3b06185b2cb1fa0b774 (patch) | |
tree | 3be00fa743238e3a50283f56d595d978ed36667b /source/blender/bmesh/intern/bmesh_operators.c | |
parent | 6cdbd1b1aaae0f8b3018ecf2648699a0ea6d6be8 (diff) |
use booleans for bmesh api.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_operators.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.c | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index fbf51b7dfdf..3308a014d25 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -238,7 +238,7 @@ void BMO_op_finish(BMesh *bm, BMOperator *op) * * \return Success if the slot if found. */ -int BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) +bool BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) { int slot_code = bmo_name_to_slotcode(slot_args, identifier); return (slot_code >= 0); @@ -390,7 +390,7 @@ void BMO_slot_int_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam slot->data.i = i; } -void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i) +void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const bool i) { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); @@ -495,7 +495,7 @@ int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name return slot->data.i; } -int BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) +bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); @@ -549,7 +549,7 @@ void BMO_slot_vec_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam */ static int bmo_mesh_flag_count(BMesh *bm, const char htype, const short oflag, - const short test_for_enabled) + const bool test_for_enabled) { const char iter_types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, @@ -562,7 +562,7 @@ static int bmo_mesh_flag_count(BMesh *bm, const char htype, const short oflag, BMElemF *ele_f; int i; - BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); + BLI_assert(ELEM(true, false, test_for_enabled)); for (i = 0; i < 3; i++) { if (htype & flag_types[i]) { @@ -579,12 +579,12 @@ static int bmo_mesh_flag_count(BMesh *bm, const char htype, const short oflag, int BMO_mesh_enabled_flag_count(BMesh *bm, const char htype, const short oflag) { - return bmo_mesh_flag_count(bm, htype, oflag, TRUE); + return bmo_mesh_flag_count(bm, htype, oflag, true); } int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag) { - return bmo_mesh_flag_count(bm, htype, oflag, FALSE); + return bmo_mesh_flag_count(bm, htype, oflag, false); } void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char htype, const short oflag) @@ -795,14 +795,12 @@ void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_ */ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, - const short test_for_enabled) + const bool test_for_enabled) { BMOpSlot *output = BMO_slot_get(slot_args, slot_name); int totelement = 0, i = 0; const int respecthide = (op->flag & BMO_FLAG_RESPECT_HIDE) != 0; - BLI_assert(ELEM(test_for_enabled, TRUE, FALSE)); - if (test_for_enabled) totelement = BM_mesh_elem_hflag_count_enabled(bm, htype, hflag, respecthide); else @@ -858,14 +856,14 @@ void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, TRUE); + bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, true); } void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, FALSE); + bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, false); } void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele) @@ -934,13 +932,13 @@ void _bmo_slot_buffer_append(BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const cha static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag, - const short test_for_enabled) + const bool test_for_enabled) { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); int totelement, i = 0; BLI_assert(op->slots_in == slot_args || op->slots_out == slot_args); - BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); + BLI_assert(ELEM(true, false, test_for_enabled)); if (test_for_enabled) totelement = BMO_mesh_enabled_flag_count(bm, htype, oflag); @@ -997,14 +995,14 @@ void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, TRUE); + bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, true); } void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, FALSE); + bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, false); } /** @@ -1015,13 +1013,13 @@ void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, */ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, - const char htype, const char hflag, const char do_flush) + const char htype, const char hflag, const bool do_flush) { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BMElem **data = (BMElem **)slot->data.buf; int i; - const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); - const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); + const bool do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); + const bool do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype); @@ -1031,11 +1029,11 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, continue; if (do_flush_select) { - BM_elem_select_set(bm, *data, TRUE); + BM_elem_select_set(bm, *data, true); } if (do_flush_hide) { - BM_elem_hide_set(bm, *data, FALSE); + BM_elem_hide_set(bm, *data, false); } BM_elem_flag_enable(*data, hflag); @@ -1050,13 +1048,13 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, */ void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, - const char htype, const char hflag, const char do_flush) + const char htype, const char hflag, const bool do_flush) { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BMElem **data = (BMElem **)slot->data.buf; int i; - const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); - const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); + const bool do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); + const bool do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype); @@ -1066,11 +1064,11 @@ void BMO_slot_buffer_hflag_disable(BMesh *bm, continue; if (do_flush_select) { - BM_elem_select_set(bm, *data, FALSE); + BM_elem_select_set(bm, *data, false); } if (do_flush_hide) { - BM_elem_hide_set(bm, *data, FALSE); + BM_elem_hide_set(bm, *data, false); } BM_elem_flag_disable(*data, hflag); @@ -1482,7 +1480,7 @@ void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg) BLI_addhead(&bm->errorstack, err); } -int BMO_error_occurred(BMesh *bm) +bool BMO_error_occurred(BMesh *bm) { return bm->errorstack.first != NULL; } @@ -1616,7 +1614,7 @@ static int bmo_opname_to_opcode(const char *opname) * Order is not important so `Hfev` is also valid (all unflagged verts, edges and faces). */ -int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, va_list vlist) +bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, va_list vlist) { // BMOpDefine *def; char *opname, *ofmt, *fmt; @@ -1653,7 +1651,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v if (i == -1) { MEM_freeN(ofmt); - return FALSE; + return false; } BMO_op_init(bm, op, flag, opname); @@ -1816,7 +1814,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v } MEM_freeN(ofmt); - return TRUE; + return true; error: /* non urgent todo - explain exactly what is failing */ @@ -1841,14 +1839,14 @@ error: MEM_freeN(ofmt); BMO_op_finish(bm, op); - return FALSE; + return false; #undef GOTO_ERROR } -int BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, ...) +bool BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, ...) { va_list list; @@ -1856,14 +1854,14 @@ int BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, ... if (!BMO_op_vinitf(bm, op, flag, fmt, list)) { printf("%s: failed\n", __func__); va_end(list); - return FALSE; + return false; } va_end(list); - return TRUE; + return true; } -int BMO_op_callf(BMesh *bm, const int flag, const char *fmt, ...) +bool BMO_op_callf(BMesh *bm, const int flag, const char *fmt, ...) { va_list list; BMOperator op; @@ -1872,12 +1870,12 @@ int BMO_op_callf(BMesh *bm, const int flag, const char *fmt, ...) if (!BMO_op_vinitf(bm, &op, flag, fmt, list)) { printf("%s: failed, format is:\n \"%s\"\n", __func__, fmt); va_end(list); - return FALSE; + return false; } BMO_op_exec(bm, &op); BMO_op_finish(bm, &op); va_end(list); - return TRUE; + return true; } |