BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot,
void *element, int val)
{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_INT);
+ BMO_slot_map_insert(op, slot, element, &val, sizeof(int));
+}
+
+BLI_INLINE void BMO_slot_map_bool_insert(BMOperator *op, BMOpSlot *slot,
+ void *element, int val)
+{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
+ BLI_assert(val == FALSE || val == TRUE);
BMO_slot_map_insert(op, slot, element, &val, sizeof(int));
}
BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot,
void *element, float val)
{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_FLOAT);
BMO_slot_map_insert(op, slot, element, &val, sizeof(float));
}
BLI_INLINE void BMO_slot_map_ptr_insert(BMOperator *op, BMOpSlot *slot,
const void *element, void *val)
{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
BMO_slot_map_insert(op, slot, element, &val, sizeof(void *));
}
+BLI_INLINE void BMO_slot_map_elem_insert(BMOperator *op, BMOpSlot *slot,
+ const void *element, void *val)
+{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_ELEM);
+ BMO_slot_map_insert(op, slot, element, &val, sizeof(void *));
+}
+
+
+/* no values */
+BLI_INLINE void BMO_slot_map_empty_insert(BMOperator *op, BMOpSlot *slot,
+ const void *element)
+{
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_EMPTY);
+ BMO_slot_map_insert(op, slot, element, NULL, 0);
+}
+
BLI_INLINE int BMO_slot_map_contains(BMOpSlot *slot, const void *element)
{
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
BLI_INLINE float BMO_slot_map_float_get(BMOpSlot *slot, const void *element)
{
- float *val = (float *) BMO_slot_map_data_get(slot, element);
+ float *val;
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_FLOAT);
+
+ val = (float *) BMO_slot_map_data_get(slot, element);
if (val) return *val;
return 0.0f;
BLI_INLINE int BMO_slot_map_int_get(BMOpSlot *slot, const void *element)
{
- int *val = (int *) BMO_slot_map_data_get(slot, element);
+ int *val;
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_INT);
+
+ val = (int *) BMO_slot_map_data_get(slot, element);
+ if (val) return *val;
+
+ return 0;
+}
+
+BLI_INLINE int BMO_slot_map_bool_get(BMOpSlot *slot, const void *element)
+{
+ int *val;
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
+
+ val = (int *) BMO_slot_map_data_get(slot, element);
+ BLI_assert(val == NULL || *val == FALSE || *val == TRUE);
if (val) return *val;
return 0;
}
-BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot *slot, const void *element)
+BLI_INLINE void *BMO_slot_map_ptr_get_(BMOpSlot *slot, const void *element)
+{
+ void **val = (void **) BMO_slot_map_data_get(slot, element);
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
+ if (val) return *val;
+
+ return NULL;
+}
+
+BLI_INLINE void *BMO_slot_map_elem_get(BMOpSlot *slot, const void *element)
{
void **val = (void **) BMO_slot_map_data_get(slot, element);
+ BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_ELEM);
if (val) return *val;
return NULL;
{
unsigned int i;
for (i = 0; slot_types[i].type; i++) {
- slot_args[i].slot_name = slot_types[i].name;
- slot_args[i].slot_type = slot_types[i].type;
+ slot_args[i].slot_name = slot_types[i].name;
+ slot_args[i].slot_type = slot_types[i].type;
+ slot_args[i].slot_subtype = slot_types[i].subtype;
// slot_args[i].index = i; // UNUSED
}
}
if (!slot->data.ghash) {
slot->data.ghash = BLI_ghash_ptr_new("bmesh slot map hash");
}
+ else {
+ BLI_assert(slot->data.ghash);
+ }
BLI_ghash_insert(slot->data.ghash, (void *)element, mapping);
}
if (rlen < 2) {
/* not sure what non-manifold cases of greater then three
* radial should do. */
- BMO_slot_map_ptr_insert(op, slot_boundarymap_out,
- source_edge, target_edge);
+ BMO_slot_map_elem_insert(op, slot_boundarymap_out, source_edge, target_edge);
}
/* Insert new edge into the edge hash */
/* create new face */
target_face = BM_face_create(target_mesh, vtar, edar, source_face->len, FALSE);
- BMO_slot_map_ptr_insert(op, slot_facemap_out, source_face, target_face);
- BMO_slot_map_ptr_insert(op, slot_facemap_out, target_face, source_face);
+ BMO_slot_map_elem_insert(op, slot_facemap_out, source_face, target_face);
+ BMO_slot_map_elem_insert(op, slot_facemap_out, target_face, source_face);
BM_elem_attrs_copy(source_mesh, target_mesh, source_face, target_face);
}
if (isolated) {
- BMO_slot_map_ptr_insert(op, slot_isovertmap_out, v, v2);
+ BMO_slot_map_elem_insert(op, slot_isovertmap_out, v, v2);
}
BMO_elem_flag_enable(bm_src, v, DUPE_DONE);
slot_facemap_out = BMO_slot_get(dupeop.slots_out, "facemap.out");
if (bm->act_face && BMO_elem_flag_test(bm, bm->act_face, EXT_INPUT)) {
- bm->act_face = BMO_slot_map_ptr_get(slot_facemap_out, bm->act_face);
+ bm->act_face = BMO_slot_map_elem_get(slot_facemap_out, bm->act_face);
}
if (delorig) {
v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
for (i = 0; i < ototvert; i++) {
if (fabsf(v->co[axis]) <= dist) {
- BMO_slot_map_ptr_insert(&weldop, slot_targetmap, vmap[i], v);
+ BMO_slot_map_elem_insert(&weldop, slot_targetmap, vmap[i], v);
}
v = BM_iter_step(&iter);
}
int split = FALSE;
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- v2 = BMO_slot_map_ptr_get(slot_targetmap, l->v);
+ v2 = BMO_slot_map_elem_get(slot_targetmap, l->v);
/* ok: if v2 is NULL (e.g. not in the map) then it's
* a target vert, otherwise it's a double */
if ((v2 && BM_vert_in_face(f, v2)) &&
/* mark merge verts for deletion */
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if ((v2 = BMO_slot_map_ptr_get(slot_targetmap, v))) {
+ if ((v2 = BMO_slot_map_elem_get(slot_targetmap, v))) {
BMO_elem_flag_enable(bm, v, ELE_DEL);
/* merge the vertex flags, else we get randomly selected/unselected verts */
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BMO_elem_flag_test(bm, e->v1, ELE_DEL) || BMO_elem_flag_test(bm, e->v2, ELE_DEL)) {
- v = BMO_slot_map_ptr_get(slot_targetmap, e->v1);
- v2 = BMO_slot_map_ptr_get(slot_targetmap, e->v2);
+ v = BMO_slot_map_elem_get(slot_targetmap, e->v1);
+ v2 = BMO_slot_map_elem_get(slot_targetmap, e->v2);
if (!v) v = e->v1;
if (!v2) v2 = e->v2;
v = l->v;
v2 = l->next->v;
if (BMO_elem_flag_test(bm, v, ELE_DEL)) {
- v = BMO_slot_map_ptr_get(slot_targetmap, v);
+ v = BMO_slot_map_elem_get(slot_targetmap, v);
}
if (BMO_elem_flag_test(bm, v2, ELE_DEL)) {
- v2 = BMO_slot_map_ptr_get(slot_targetmap, v2);
+ v2 = BMO_slot_map_elem_get(slot_targetmap, v2);
}
e2 = v != v2 ? BM_edge_exists(v, v2) : NULL;
v2 = loops[1]->v;
if (BMO_elem_flag_test(bm, v, ELE_DEL)) {
- v = BMO_slot_map_ptr_get(slot_targetmap, v);
+ v = BMO_slot_map_elem_get(slot_targetmap, v);
}
if (BMO_elem_flag_test(bm, v2, ELE_DEL)) {
- v2 = BMO_slot_map_ptr_get(slot_targetmap, v2);
+ v2 = BMO_slot_map_elem_get(slot_targetmap, v2);
}
f2 = BM_face_create_ngon(bm, v, v2, edges, a, TRUE);
copy_v3_v3(snapv->co, vec);
}
else {
- BMO_slot_map_ptr_insert(&weldop, slot_targetmap, v, snapv);
+ BMO_slot_map_elem_insert(&weldop, slot_targetmap, v, snapv);
}
}
copy_v3_v3(edges[i]->v2->co, center);
if (edges[i]->v1 != edges[0]->v1)
- BMO_slot_map_ptr_insert(&weldop, slot_targetmap, edges[i]->v1, edges[0]->v1);
+ BMO_slot_map_elem_insert(&weldop, slot_targetmap, edges[i]->v1, edges[0]->v1);
if (edges[i]->v2 != edges[0]->v1)
- BMO_slot_map_ptr_insert(&weldop, slot_targetmap, edges[i]->v2, edges[0]->v1);
+ BMO_slot_map_elem_insert(&weldop, slot_targetmap, edges[i]->v2, edges[0]->v1);
}
}
BMO_elem_flag_enable(bm, v_other, VERT_DOUBLE);
BMO_elem_flag_enable(bm, v_check, VERT_TARGET);
- BMO_slot_map_ptr_insert(optarget, optarget_slot, v_other, v_check);
+ BMO_slot_map_elem_insert(optarget, optarget_slot, v_other, v_check);
}
}
}
BM_face_triangulate(bm, face, projectverts, EDGE_NEW, FACE_NEW, newfaces, use_beauty);
- BMO_slot_map_ptr_insert(op, slot_facemap_out, face, face);
+ BMO_slot_map_elem_insert(op, slot_facemap_out, face, face);
for (i = 0; newfaces[i]; i++) {
- BMO_slot_map_ptr_insert(op, slot_facemap_out, newfaces[i], face);
+ BMO_slot_map_elem_insert(op, slot_facemap_out, newfaces[i], face);
}
}
if ((fabsf(co1[0]) < mmd->tolerance) &&
(fabsf(co2[0]) < mmd->tolerance))
{
- BMO_slot_map_ptr_insert(&extop, slot_edges_exclude, edge, NULL);
+ BMO_slot_map_empty_insert(&extop, slot_edges_exclude, edge);
}
}
if (mmd->flag & MOD_MIR_AXIS_Y) {
if ((fabsf(co1[1]) < mmd->tolerance) &&
(fabsf(co2[1]) < mmd->tolerance))
{
- BMO_slot_map_ptr_insert(&extop, slot_edges_exclude, edge, NULL);
+ BMO_slot_map_empty_insert(&extop, slot_edges_exclude, edge);
}
}
if (mmd->flag & MOD_MIR_AXIS_Z) {
if ((fabsf(co1[2]) < mmd->tolerance) &&
(fabsf(co2[2]) < mmd->tolerance))
{
- BMO_slot_map_ptr_insert(&extop, slot_edges_exclude, edge, NULL);
+ BMO_slot_map_empty_insert(&extop, slot_edges_exclude, edge);
}
}
}
v2 = BMO_iter_map_value_p(&oiter);
/* check in case the target vertex (v2) is already marked
* for merging */
- while ((v3 = BMO_slot_map_ptr_get(slot_targetmap, v2))) {
+ while ((v3 = BMO_slot_map_elem_get(slot_targetmap, v2))) {
v2 = v3;
}
- BMO_slot_map_ptr_insert(weld_op, slot_targetmap, v, v2);
+ BMO_slot_map_elem_insert(weld_op, slot_targetmap, v, v2);
}
BMO_op_finish(bm, &find_op);
slot_targetmap = BMO_slot_get(weld_op->slots_in, "targetmap");
BMO_ITER (v, &oiter, find_op.slots_out, "targetmap.out", 0) {
v2 = BMO_iter_map_value_p(&oiter);
- BMO_slot_map_ptr_insert(weld_op, slot_targetmap, v, v2);
+ BMO_slot_map_elem_insert(weld_op, slot_targetmap, v, v2);
}
BMO_op_finish(bm, &find_op);
/* check in case the target vertex (v2) is already marked
* for merging */
- while ((v3 = BMO_slot_map_ptr_get(slot_targetmap, v2))) {
+ while ((v3 = BMO_slot_map_elem_get(slot_targetmap, v2))) {
v2 = v3;
}
- BMO_slot_map_ptr_insert(&weld_op, slot_targetmap, v, v2);
+ BMO_slot_map_elem_insert(&weld_op, slot_targetmap, v, v2);
}
#undef _E
v_safe = shortest_edge->v1;
v_merge = shortest_edge->v2;
mid_v3_v3v3(v_safe->co, v_safe->co, v_merge->co);
- BMO_slot_map_ptr_insert(&op, slot_targetmap, v_merge, v_safe);
+ BMO_slot_map_elem_insert(&op, slot_targetmap, v_merge, v_safe);
BMO_op_exec(bm, &op);
BMO_op_finish(bm, &op);
"weld_verts");
slot_targetmap = BMO_slot_get(op.slots_in, "targetmap");
for (i = 0; i < 4; i++) {
- BMO_slot_map_ptr_insert(&op, slot_targetmap,
- verts[i], frame->verts[best_order[i]]);
+ BMO_slot_map_elem_insert(&op, slot_targetmap, verts[i], frame->verts[best_order[i]]);
}
BMO_op_exec(bm, &op);
BMO_op_finish(bm, &op);