Changeset View
Changeset View
Standalone View
Standalone View
source/blender/bmesh/intern/bmesh_operators.c
| Show First 20 Lines • Show All 890 Lines • ▼ Show 20 Lines | if (htype & BM_FACE) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| output->len = 0; | output->len = 0; | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * \brief BMO_HEADERFLAG_TO_SLOT_EXTEND | |||||
| * | |||||
| * Copies elements of a certain type, which have a certain header flag | |||||
| * enabled/disabled into a slot for an operator and extends the current slot. | |||||
| */ | |||||
| static void bmo_slot_buffer_from_hflag_extend( | |||||
| BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, | |||||
| const char htype, const char hflag, | |||||
| const bool test_for_enabled) | |||||
| { | |||||
| BMOpSlot *output = BMO_slot_get(slot_args, slot_name); | |||||
| int totelement = output->len; | |||||
| int i = totelement; | |||||
| const bool respecthide = ((op->flag & BMO_FLAG_RESPECT_HIDE) != 0) && ((hflag & BM_ELEM_HIDDEN) == 0); | |||||
| BLI_assert(output->slot_type == BMO_OP_SLOT_ELEMENT_BUF); | |||||
| BLI_assert(((output->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype); | |||||
| BLI_assert((output->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) == 0); | |||||
| if (test_for_enabled) | |||||
| totelement += BM_mesh_elem_hflag_count_enabled(bm, htype, hflag, respecthide); | |||||
| else | |||||
| totelement += BM_mesh_elem_hflag_count_disabled(bm, htype, hflag, respecthide); | |||||
| if (totelement) { | |||||
| BMIter iter; | |||||
| BMElem *ele; | |||||
| const int elem_size = BMO_OPSLOT_TYPEINFO[output->slot_type]; | |||||
| const int alloc_size = elem_size * totelement; | |||||
| void *buf = BLI_memarena_alloc(op->arena, alloc_size); | |||||
| memcpy(buf, output->data.buf, elem_size * output->len); | |||||
| output->data.buf = buf; | |||||
| output->len = totelement; | |||||
| /* TODO - collapse these loops into one */ | |||||
| if (htype & BM_VERT) { | |||||
| BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { | |||||
| if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) && | |||||
| BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) | |||||
| { | |||||
| output->data.buf[i] = ele; | |||||
| i++; | |||||
| } | |||||
| } | |||||
| } | |||||
| if (htype & BM_EDGE) { | |||||
| BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { | |||||
| if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) && | |||||
| BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) | |||||
| { | |||||
| output->data.buf[i] = ele; | |||||
| i++; | |||||
| } | |||||
| } | |||||
| } | |||||
| if (htype & BM_FACE) { | |||||
| BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { | |||||
| if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) && | |||||
| BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) | |||||
| { | |||||
| output->data.buf[i] = ele; | |||||
| i++; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| else { | |||||
| output->len = 0; | |||||
| } | |||||
| } | |||||
| void BMO_slot_buffer_from_enabled_hflag( | void BMO_slot_buffer_from_enabled_hflag( | ||||
| BMesh *bm, BMOperator *op, | BMesh *bm, BMOperator *op, | ||||
| BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, | BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, | ||||
| const char htype, const char hflag) | 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( | void BMO_slot_buffer_from_disabled_hflag( | ||||
| BMesh *bm, BMOperator *op, | BMesh *bm, BMOperator *op, | ||||
| BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, | BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, | ||||
| const char htype, const char hflag) | 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_enabled_hflag_extend( | |||||
| 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_extend(bm, op, slot_args, slot_name, htype, hflag, true); | |||||
| } | |||||
| void BMO_slot_buffer_from_disabled_hflag_extend( | |||||
| 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_extend(bm, op, slot_args, slot_name, htype, hflag, false); | |||||
| } | |||||
| void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele) | void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele) | ||||
| { | { | ||||
| BMO_ASSERT_SLOT_IN_OP(slot, op); | BMO_ASSERT_SLOT_IN_OP(slot, op); | ||||
| BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); | BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); | ||||
| BLI_assert(slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE); | BLI_assert(slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE); | ||||
| BLI_assert(slot->len == 0 || slot->len == 1); | BLI_assert(slot->len == 0 || slot->len == 1); | ||||
| BLI_assert(slot->slot_subtype.elem & ele->htype); | BLI_assert(slot->slot_subtype.elem & ele->htype); | ||||
| ▲ Show 20 Lines • Show All 1,018 Lines • Show Last 20 Lines | |||||