Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-27 13:21:57 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-27 13:21:57 +0400
commita9855c227e6bfc955a6b2f15e8ee656218c3f916 (patch)
tree8e49eb73516a927b9cfb1516d764d14c857a9af1 /source/blender/bmesh/intern/bmesh_operators.c
parent0cd26e6066a071ecd230aa9b865b9223ea4ba13a (diff)
py/bmesh api - add support for single item buffers (odd feature but used quite a bit with bmesh operators).
also add utility functions BMO_slot_buffer_from_single(), BMO_slot_buffer_get_single()
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_operators.c')
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 20fffe71636..54866c756cb 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -867,6 +867,29 @@ void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op,
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)
+{
+ BMO_ASSERT_SLOT_IN_OP(slot, op);
+ 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->len == 0 || slot->len == 1);
+
+ BLI_assert(slot->slot_subtype.elem & ele->htype);
+
+ slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void *) * 4); /* XXX, why 'x4' ? */
+ slot->len = 1;
+ *slot->data.buf = ele;
+}
+
+void *BMO_slot_buffer_get_single(BMOpSlot *slot)
+{
+ 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->len == 0 || slot->len == 1);
+
+ return slot->len ? (BMHeader *)slot->data.buf[0] : NULL;
+}
+
/**
* Copies the values from another slot to the end of the output slot.
*/
@@ -1580,12 +1603,11 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v
}
case 'e':
{
+ /* XXX we have 'e' but no equivalent for verts/faces - why? we could use (V/E/P)*/
BMHeader *ele = va_arg(vlist, void *);
BMOpSlot *slot = BMO_slot_get(op->slots_in, slot_name);
- slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void *) * 4);
- slot->len = 1;
- *slot->data.buf = ele;
+ BMO_slot_buffer_from_single(op, slot, ele);
state = 1;
break;