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-03-01 20:04:37 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-01 20:04:37 +0400
commit4a5078d6c9bf59840c0fe46876a9eb71aa3ad33a (patch)
treef11bd72c483993e38dcd2c927ff68eb279323dc2 /source/blender/bmesh/intern
parent216f74880e86b7da22e708569b1de082da357dfb (diff)
style cleanup
* add extra argument to BMO_slot_map_to_flag() to filter by vert/edge/face * made BMO_slot_map_* / BMO_slot_buffer_* functions stricter with type checking.
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api_inline.c18
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c29
-rw-r--r--source/blender/bmesh/intern/bmesh_structure.c2
3 files changed, 30 insertions, 19 deletions
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.c b/source/blender/bmesh/intern/bmesh_operator_api_inline.c
index 29d85790010..a7c8f1612eb 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api_inline.c
+++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.c
@@ -88,7 +88,7 @@ BM_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *
BM_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname,
void *element, void *val)
{
- BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void*));
+ BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void *));
}
BM_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, void *element)
@@ -96,7 +96,12 @@ BM_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const cha
BMOpSlot *slot = BMO_slot_get(op, slotname);
/*sanity check*/
- if (slot->slottype != BMO_OP_SLOT_MAPPING) return 0;
+ if (slot->slottype != BMO_OP_SLOT_MAPPING) {
+#ifdef DEBUG
+ printf("%s: invalid type %d\n", __func__, slot->slottype);
+#endif
+ return 0;
+ }
if (!slot->data.ghash) return 0;
return BLI_ghash_haskey(slot->data.ghash, element);
@@ -109,7 +114,12 @@ BM_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const c
BMOpSlot *slot = BMO_slot_get(op, slotname);
/*sanity check*/
- if (slot->slottype != BMO_OP_SLOT_MAPPING) return NULL;
+ if (slot->slottype != BMO_OP_SLOT_MAPPING) {
+#ifdef DEBUG
+ printf("%s: invalid type %d\n", __func__, slot->slottype);
+#endif
+ return NULL;
+ }
if (!slot->data.ghash) return NULL;
mapping = (BMOElemMapping *)BLI_ghash_lookup(slot->data.ghash, element);
@@ -140,7 +150,7 @@ BM_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotna
BM_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname,
void *element)
{
- void **val = (void**) BMO_slot_map_data_get(bm, op, slotname, element);
+ void **val = (void **) BMO_slot_map_data_get(bm, op, slotname, element);
if (val) return *val;
return NULL;
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 9d6d7fce15a..ddb63a42400 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -153,8 +153,8 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const char *opname)
op->exec = opdefines[opcode]->exec;
/* memarena, used for operator's slot buffers */
- op->arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "bmesh operator");
- BLI_memarena_use_calloc (op->arena);
+ op->arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
+ BLI_memarena_use_calloc(op->arena);
}
/**
@@ -267,7 +267,9 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src,
BMOElemMapping *srcmap, *dstmap;
/* sanity check */
- if (!source_slot->data.ghash) return;
+ if (!source_slot->data.ghash) {
+ return;
+ }
if (!dest_slot->data.ghash) {
dest_slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash,
@@ -534,11 +536,7 @@ void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname
{
BMOElemMapping *mapping;
BMOpSlot *slot = BMO_slot_get(op, slotname);
-
- /*sanity check*/
- if (slot->slottype != BMO_OP_SLOT_MAPPING) {
- return;
- }
+ BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING);
mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len);
@@ -595,8 +593,8 @@ void *BMO_Grow_Array(BMesh *bm, BMOperator *op, int slotcode, int totadd)
}
#endif
-void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op,
- const char *slotname, const short oflag)
+void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname,
+ const short oflag, const char htype)
{
GHashIterator it;
BMOpSlot *slot = BMO_slot_get(op, slotname);
@@ -605,12 +603,13 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op,
BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING);
/* sanity check */
- if (slot->slottype != BMO_OP_SLOT_MAPPING) return;
if (!slot->data.ghash) return;
BLI_ghashIterator_init(&it, slot->data.ghash);
for ( ; (ele_f = BLI_ghashIterator_getKey(&it)); BLI_ghashIterator_step(&it)) {
- BMO_elem_flag_enable(bm, ele_f, oflag);
+ if (ele_f->head.htype & htype) {
+ BMO_elem_flag_enable(bm, ele_f, oflag);
+ }
}
}
@@ -865,7 +864,7 @@ void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname
BMHeader **data = slot->data.p;
int i;
- BLI_assert(slot->slottype > BMO_OP_SLOT_VEC);
+ BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF);
for (i = 0; i < slot->len; i++) {
if (!(htype & data[i]->htype))
@@ -886,7 +885,9 @@ void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slotnam
BMOpSlot *slot = BMO_slot_get(op, slotname);
BMHeader **data = slot->data.p;
int i;
-
+
+ BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF);
+
for (i = 0; i < slot->len; i++) {
if (!(htype & data[i]->htype))
continue;
diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c
index 97b10fab49f..03f116a03ba 100644
--- a/source/blender/bmesh/intern/bmesh_structure.c
+++ b/source/blender/bmesh/intern/bmesh_structure.c
@@ -234,7 +234,7 @@ BMEdge *bmesh_disk_edge_exists(BMVert *v1, BMVert *v2)
BMEdge *e_iter, *e_first;
if (v1->e) {
- e_first = e_iter= v1->e;
+ e_first = e_iter = v1->e;
do {
if (bmesh_verts_in_edge(v1, v2, e_iter)) {