69
69
oflags[bm->stackdepth - 1].f ^= oflag;
72
BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname,
73
void *element, int val)
75
BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(int));
78
BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname,
79
void *element, float val)
81
BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(float));
72
BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot,
73
void *element, const int val)
75
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INT);
76
BMO_slot_map_insert(op, slot, element, &val, sizeof(int));
79
BLI_INLINE void BMO_slot_map_bool_insert(BMOperator *op, BMOpSlot *slot,
80
void *element, const int val)
82
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
83
BLI_assert(val == false || val == true);
84
BMO_slot_map_insert(op, slot, element, &val, sizeof(int));
87
BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot,
88
void *element, const float val)
90
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_FLT);
91
BMO_slot_map_insert(op, slot, element, &val, sizeof(float));
87
97
* do NOT use these for non-operator-api-allocated memory! instead
88
98
* use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */
90
BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname,
91
void *element, void *val)
93
BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void *));
96
BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, void *element)
98
BMOpSlot *slot = BMO_slot_get(op, slotname);
99
BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING);
100
BLI_INLINE void BMO_slot_map_ptr_insert(BMOperator *op, BMOpSlot *slot,
101
const void *element, void *val)
103
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
104
BMO_slot_map_insert(op, slot, element, &val, sizeof(void *));
107
BLI_INLINE void BMO_slot_map_elem_insert(BMOperator *op, BMOpSlot *slot,
108
const void *element, void *val)
110
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_ELEM);
111
BMO_slot_map_insert(op, slot, element, &val, sizeof(void *));
116
BLI_INLINE void BMO_slot_map_empty_insert(BMOperator *op, BMOpSlot *slot,
119
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_EMPTY);
120
BMO_slot_map_insert(op, slot, element, NULL, 0);
123
BLI_INLINE int BMO_slot_map_contains(BMOpSlot *slot, const void *element)
125
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
101
127
/* sanity check */
102
if (!slot->data.ghash) return 0;
128
if (UNLIKELY(slot->data.ghash == NULL)) {
104
132
return BLI_ghash_haskey(slot->data.ghash, element);
107
BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slotname,
135
BLI_INLINE void *BMO_slot_map_data_get(BMOpSlot *slot, const void *element)
110
137
BMOElemMapping *mapping;
111
BMOpSlot *slot = BMO_slot_get(op, slotname);
112
BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING);
138
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
114
140
/* sanity check */
115
if (!slot->data.ghash) return NULL;
141
if (UNLIKELY(slot->data.ghash == NULL)) {
117
145
mapping = (BMOElemMapping *)BLI_ghash_lookup(slot->data.ghash, element);
119
if (!mapping) return NULL;
121
151
return mapping + 1;
124
BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname,
154
BLI_INLINE float BMO_slot_map_float_get(BMOpSlot *slot, const void *element)
127
float *val = (float *) BMO_slot_map_data_get(bm, op, slotname, element);
157
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_FLT);
159
val = (float *) BMO_slot_map_data_get(slot, element);
128
160
if (val) return *val;
133
BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotname,
165
BLI_INLINE int BMO_slot_map_int_get(BMOpSlot *slot, const void *element)
136
int *val = (int *) BMO_slot_map_data_get(bm, op, slotname, element);
168
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INT);
170
val = (int *) BMO_slot_map_data_get(slot, element);
137
171
if (val) return *val;
142
BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname,
145
void **val = (void **) BMO_slot_map_data_get(bm, op, slotname, element);
176
BLI_INLINE bool BMO_slot_map_bool_get(BMOpSlot *slot, const void *element)
179
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
181
val = (int *) BMO_slot_map_data_get(slot, element);
182
BLI_assert(val == NULL || *val == false || *val == true);
183
if (val) return (bool)*val;
188
BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot *slot, const void *element)
190
void **val = (void **) BMO_slot_map_data_get(slot, element);
191
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
192
if (val) return *val;
197
BLI_INLINE void *BMO_slot_map_elem_get(BMOpSlot *slot, const void *element)
199
void **val = (void **) BMO_slot_map_data_get(slot, element);
200
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_ELEM);
146
201
if (val) return *val;