LEFT | RIGHT |
1 /* | 1 /* |
2 * ***** BEGIN GPL LICENSE BLOCK ***** | 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version. | 7 * of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 struct GHashIterator; | 76 struct GHashIterator; |
77 | 77 |
78 #define BMO_elem_flag_test( bm, ele, oflag) _bmo_elem_flag_test (bm
, (ele)->oflags, oflag) | 78 #define BMO_elem_flag_test( bm, ele, oflag) _bmo_elem_flag_test (bm
, (ele)->oflags, oflag) |
79 #define BMO_elem_flag_test_bool(bm, ele, oflag) _bmo_elem_flag_test_bool(bm
, (ele)->oflags, oflag) | 79 #define BMO_elem_flag_test_bool(bm, ele, oflag) _bmo_elem_flag_test_bool(bm
, (ele)->oflags, oflag) |
80 #define BMO_elem_flag_enable( bm, ele, oflag) _bmo_elem_flag_enable (bm
, (ele)->oflags, oflag) | 80 #define BMO_elem_flag_enable( bm, ele, oflag) _bmo_elem_flag_enable (bm
, (ele)->oflags, oflag) |
81 #define BMO_elem_flag_disable( bm, ele, oflag) _bmo_elem_flag_disable (bm
, (ele)->oflags, oflag) | 81 #define BMO_elem_flag_disable( bm, ele, oflag) _bmo_elem_flag_disable (bm
, (ele)->oflags, oflag) |
82 #define BMO_elem_flag_set( bm, ele, oflag, val) _bmo_elem_flag_set (bm
, (ele)->oflags, oflag, val) | 82 #define BMO_elem_flag_set( bm, ele, oflag, val) _bmo_elem_flag_set (bm
, (ele)->oflags, oflag, val) |
83 #define BMO_elem_flag_toggle( bm, ele, oflag) _bmo_elem_flag_toggle (bm
, (ele)->oflags, oflag) | 83 #define BMO_elem_flag_toggle( bm, ele, oflag) _bmo_elem_flag_toggle (bm
, (ele)->oflags, oflag) |
84 | 84 |
85 BLI_INLINE short _bmo_elem_flag_test( BMesh *bm, BMFlagLayer *oflags, const
short oflag); | 85 BLI_INLINE short _bmo_elem_flag_test( BMesh *bm, BMFlagLayer *oflags, const
short oflag); |
86 BLI_INLINE short _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const
short oflag); | 86 BLI_INLINE bool _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const
short oflag); |
87 BLI_INLINE void _bmo_elem_flag_enable( BMesh *bm, BMFlagLayer *oflags, const
short oflag); | 87 BLI_INLINE void _bmo_elem_flag_enable( BMesh *bm, BMFlagLayer *oflags, const
short oflag); |
88 BLI_INLINE void _bmo_elem_flag_disable( BMesh *bm, BMFlagLayer *oflags, const
short oflag); | 88 BLI_INLINE void _bmo_elem_flag_disable( BMesh *bm, BMFlagLayer *oflags, const
short oflag); |
89 BLI_INLINE void _bmo_elem_flag_set( BMesh *bm, BMFlagLayer *oflags, const
short oflag, int val); | 89 BLI_INLINE void _bmo_elem_flag_set( BMesh *bm, BMFlagLayer *oflags, const
short oflag, int val); |
90 BLI_INLINE void _bmo_elem_flag_toggle( BMesh *bm, BMFlagLayer *oflags, const
short oflag); | 90 BLI_INLINE void _bmo_elem_flag_toggle( BMesh *bm, BMFlagLayer *oflags, const
short oflag); |
91 | 91 |
92 /* slot type arrays are terminated by the last member | 92 /* slot type arrays are terminated by the last member |
93 * having a slot type of 0 */ | 93 * having a slot type of 0 */ |
94 enum { | 94 typedef enum eBMOpSlotType { |
95 » BMO_OP_SLOT_SENTINEL = 0, | 95 » /* BMO_OP_SLOT_SENTINEL = 0, */ |
96 BMO_OP_SLOT_BOOL = 1, | 96 BMO_OP_SLOT_BOOL = 1, |
97 BMO_OP_SLOT_INT = 2, | 97 BMO_OP_SLOT_INT = 2, |
98 BMO_OP_SLOT_FLT = 3, | 98 BMO_OP_SLOT_FLT = 3, |
99 | 99 |
100 /* normally store pointers to object, scene, | 100 /* normally store pointers to object, scene, |
101 * _never_ store arrays corresponding to mesh elements with this */ | 101 * _never_ store arrays corresponding to mesh elements with this */ |
102 » BMO_OP_SLOT_PTR = 4, | 102 » BMO_OP_SLOT_PTR = 4, /* requres subtype BMO_OP_SLOT_SUBTYPE_PTR_xxx */ |
103 BMO_OP_SLOT_MAT = 5, | 103 BMO_OP_SLOT_MAT = 5, |
104 BMO_OP_SLOT_VEC = 8, | 104 BMO_OP_SLOT_VEC = 8, |
105 | 105 |
106 /* after BMO_OP_SLOT_VEC, everything is dynamically allocated arrays. | 106 /* after BMO_OP_SLOT_VEC, everything is dynamically allocated arrays. |
107 * We leave a space in the identifiers for future growth. | 107 * We leave a space in the identifiers for future growth. |
108 * | 108 * |
109 * it's very important this remain a power of two */ | 109 * it's very important this remain a power of two */ |
110 BMO_OP_SLOT_ELEMENT_BUF = 9, /* list of verts/edges/faces */ | 110 BMO_OP_SLOT_ELEMENT_BUF = 9, /* list of verts/edges/faces */ |
111 » BMO_OP_SLOT_MAPPING = 10 /* simple hash map */ | 111 » BMO_OP_SLOT_MAPPING = 10 /* simple hash map, requres subtype BMO_OP_SLOT
_SUBTYPE_MAP_xxx */ |
112 }; | 112 } eBMOpSlotType; |
113 #define BMO_OP_SLOT_TOTAL_TYPES 11 | 113 #define BMO_OP_SLOT_TOTAL_TYPES 11 |
| 114 |
| 115 /* don't overlap values to avoid confusion */ |
| 116 typedef enum eBMOpSlotSubType_Elem { |
| 117 /* use as flags */ |
| 118 BMO_OP_SLOT_SUBTYPE_ELEM_VERT = BM_VERT, |
| 119 BMO_OP_SLOT_SUBTYPE_ELEM_EDGE = BM_EDGE, |
| 120 BMO_OP_SLOT_SUBTYPE_ELEM_FACE = BM_FACE, |
| 121 BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE = (BM_FACE << 1), |
| 122 } eBMOpSlotSubType_Elem; |
| 123 typedef enum eBMOpSlotSubType_Map { |
| 124 BMO_OP_SLOT_SUBTYPE_MAP_EMPTY = 64, /* use as a set(), unused value
*/ |
| 125 BMO_OP_SLOT_SUBTYPE_MAP_ELEM = 65, |
| 126 BMO_OP_SLOT_SUBTYPE_MAP_FLT = 66, |
| 127 BMO_OP_SLOT_SUBTYPE_MAP_INT = 67, |
| 128 BMO_OP_SLOT_SUBTYPE_MAP_BOOL = 68, |
| 129 BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL = 69, /* python can't convert these */ |
| 130 } eBMOpSlotSubType_Map; |
| 131 typedef enum eBMOpSlotSubType_Ptr { |
| 132 BMO_OP_SLOT_SUBTYPE_PTR_BMESH = 100, |
| 133 BMO_OP_SLOT_SUBTYPE_PTR_SCENE = 101, |
| 134 BMO_OP_SLOT_SUBTYPE_PTR_OBJECT = 102, |
| 135 BMO_OP_SLOT_SUBTYPE_PTR_MESH = 103, |
| 136 } eBMOpSlotSubType_Ptr; |
| 137 |
| 138 typedef union eBMOpSlotSubType_Union { |
| 139 eBMOpSlotSubType_Elem elem; |
| 140 eBMOpSlotSubType_Ptr ptr; |
| 141 eBMOpSlotSubType_Map map; |
| 142 } eBMOpSlotSubType_Union; |
114 | 143 |
115 /* please ignore all these structures, don't touch them in tool code, except | 144 /* please ignore all these structures, don't touch them in tool code, except |
116 * for when your defining an operator with BMOpDefine.*/ | 145 * for when your defining an operator with BMOpDefine.*/ |
117 | 146 |
118 typedef struct BMOpSlot { | 147 typedef struct BMOpSlot { |
119 » int slot_type; | 148 » const char *slot_name; /* pointer to BMOpDefine.slot_args */ |
| 149 » eBMOpSlotType slot_type; |
| 150 » eBMOpSlotSubType_Union slot_subtype; |
| 151 |
120 int len; | 152 int len; |
121 » int flag; | 153 //» int flag; /* UNUSED */ |
122 » int index; /* index within slot array */ | 154 //» int index; /* index within slot array */ /* UNUSED */ |
123 union { | 155 union { |
124 int i; | 156 int i; |
125 float f; | 157 float f; |
126 void *p; | 158 void *p; |
127 float vec[3]; | 159 float vec[3]; |
128 » » void *buf; | 160 » » void **buf; |
129 GHash *ghash; | 161 GHash *ghash; |
130 } data; | 162 } data; |
131 } BMOpSlot; | 163 } BMOpSlot; |
132 | 164 |
133 #define BMO_OP_MAX_SLOTS 16 /* way more than probably needed */ | 165 /* mainly for use outside bmesh internal code */ |
| 166 #define BMO_SLOT_AS_BOOL(slot) ((slot)->data.i) |
| 167 #define BMO_SLOT_AS_INT(slot) ((slot)->data.i) |
| 168 #define BMO_SLOT_AS_FLOAT(slot) ((slot)->data.f) |
| 169 #define BMO_SLOT_AS_VECTOR(slot) ((slot)->data.vec) |
| 170 #define BMO_SLOT_AS_MATRIX(slot ) ((float (*)[4])((slot)->data.p)) |
| 171 #define BMO_SLOT_AS_BUFFER(slot ) ((slot)->data.buf) |
| 172 #define BMO_SLOT_AS_GHASH(slot ) ((slot)->data.ghash) |
| 173 |
| 174 #define BMO_ASSERT_SLOT_IN_OP(slot, op) \ |
| 175 » BLI_assert(((slot >= (op)->slots_in) && (slot < &(op)->slots_in[BMO_OP_
MAX_SLOTS])) || \ |
| 176 » ((slot >= (op)->slots_out) && (slot < &(op)->slots_out[BMO_OP
_MAX_SLOTS]))) |
| 177 |
| 178 /* way more than probably needed, compiler complains if limit hit */ |
| 179 #define BMO_OP_MAX_SLOTS 16 |
| 180 |
| 181 /* BMOpDefine->type_flag */ |
| 182 typedef enum { |
| 183 » BMO_OPTYPE_FLAG_NOP = 0, |
| 184 » BMO_OPTYPE_FLAG_UNTAN_MULTIRES = (1 << 0), /* switch from multires
tangent space to absolute coordinates */ |
| 185 » BMO_OPTYPE_FLAG_NORMALS_CALC = (1 << 1), /*switch from multires
tangent space to absolute coordinates*/ |
| 186 » BMO_OPTYPE_FLAG_SELECT_FLUSH = (1 << 2) /*switch from multires
tangent space to absolute coordinates*/ |
| 187 } BMOpTypeFlag; |
134 | 188 |
135 typedef struct BMOperator { | 189 typedef struct BMOperator { |
136 » int type; | 190 » struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]; |
137 » int slot_type; | 191 » struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]; |
138 » int type_flag; | |
139 » int flag; /* runtime options */ | |
140 » struct BMOpSlot slot_args[BMO_OP_MAX_SLOTS]; | |
141 void (*exec)(BMesh *bm, struct BMOperator *op); | 192 void (*exec)(BMesh *bm, struct BMOperator *op); |
142 struct MemArena *arena; | 193 struct MemArena *arena; |
| 194 int type; |
| 195 BMOpTypeFlag type_flag; |
| 196 int flag; /* runtime options */ |
143 } BMOperator; | 197 } BMOperator; |
144 | 198 |
145 enum { | 199 enum { |
146 BMO_FLAG_RESPECT_HIDE = 1, | 200 BMO_FLAG_RESPECT_HIDE = 1, |
147 }; | 201 }; |
148 | 202 |
149 #define BMO_FLAG_DEFAULTS BMO_FLAG_RESPECT_HIDE | 203 #define BMO_FLAG_DEFAULTS BMO_FLAG_RESPECT_HIDE |
150 | 204 |
151 #define MAX_SLOTNAME 32 | 205 #define MAX_SLOTNAME 32 |
152 | 206 |
153 typedef struct BMOSlotType { | 207 typedef struct BMOSlotType { |
154 int type; | |
155 char name[MAX_SLOTNAME]; | 208 char name[MAX_SLOTNAME]; |
| 209 eBMOpSlotType type; |
| 210 eBMOpSlotSubType_Union subtype; |
156 } BMOSlotType; | 211 } BMOSlotType; |
157 | 212 |
158 typedef struct BMOpDefine { | 213 typedef struct BMOpDefine { |
159 » const char *name; | 214 » const char *opname; |
160 » BMOSlotType slot_types[BMO_OP_MAX_SLOTS]; | 215 » BMOSlotType slot_types_in[BMO_OP_MAX_SLOTS]; |
| 216 » BMOSlotType slot_types_out[BMO_OP_MAX_SLOTS]; |
161 void (*exec)(BMesh *bm, BMOperator *op); | 217 void (*exec)(BMesh *bm, BMOperator *op); |
162 » int type_flag; | 218 » BMOpTypeFlag type_flag; |
163 } BMOpDefine; | 219 } BMOpDefine; |
164 | |
165 /* BMOpDefine->type_flag */ | |
166 enum { | |
167 BMO_OP_FLAG_UNTAN_MULTIRES = 1 /*switch from multires tangent space to
absolute coordinates*/ | |
168 }; | |
169 | 220 |
170 /*------------- Operator API --------------*/ | 221 /*------------- Operator API --------------*/ |
171 | 222 |
172 /* data types that use pointers (arrays, etc) should never | 223 /* data types that use pointers (arrays, etc) should never |
173 * have it set directly. and never use BMO_slot_ptr_set to | 224 * have it set directly. and never use BMO_slot_ptr_set to |
174 * pass in a list of edges or any arrays, really.*/ | 225 * pass in a list of edges or any arrays, really.*/ |
175 | 226 |
176 void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname); | 227 void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname); |
177 | 228 |
178 /* executes an operator, pushing and popping a new tool flag | 229 /* executes an operator, pushing and popping a new tool flag |
179 * layer as appropriate.*/ | 230 * layer as appropriate.*/ |
180 void BMO_op_exec(BMesh *bm, BMOperator *op); | 231 void BMO_op_exec(BMesh *bm, BMOperator *op); |
181 | 232 |
182 /* finishes an operator (though note the operator's tool flag is removed | 233 /* finishes an operator (though note the operator's tool flag is removed |
183 * after it finishes executing in BMO_op_exec).*/ | 234 * after it finishes executing in BMO_op_exec).*/ |
184 void BMO_op_finish(BMesh *bm, BMOperator *op); | 235 void BMO_op_finish(BMesh *bm, BMOperator *op); |
185 | 236 |
186 /* count the number of elements with the specified flag enabled. | 237 /* count the number of elements with the specified flag enabled. |
187 * type can be a bitmask of BM_FACE, BM_EDGE, or BM_FACE. */ | 238 * type can be a bitmask of BM_FACE, BM_EDGE, or BM_FACE. */ |
188 int BMO_mesh_enabled_flag_count(BMesh *bm, const char htype, const short oflag); | 239 int BMO_mesh_enabled_flag_count(BMesh *bm, const char htype, const short oflag); |
189 | 240 |
190 /* count the number of elements with the specified flag disabled. | 241 /* count the number of elements with the specified flag disabled. |
191 * type can be a bitmask of BM_FACE, BM_EDGE, or BM_FACE. */ | 242 * type can be a bitmask of BM_FACE, BM_EDGE, or BM_FACE. */ |
192 int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag)
; | 243 int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag)
; |
193 | 244 |
194 /*---------formatted operator initialization/execution-----------*/ | 245 /*---------formatted operator initialization/execution-----------*/ |
195 /* | |
196 * this system is used to execute or initialize an operator, | |
197 * using a formatted-string system. | |
198 * | |
199 * for example, BMO_op_callf(bm, BMO_FLAG_DEFAULTS, "delete geom=%hf context=%i"
, BM_ELEM_SELECT, DEL_FACES); | |
200 * . . .will execute the delete operator, feeding in selected faces, deleting th
em. | |
201 * | |
202 * the basic format for the format string is: | |
203 * [operatorname] [slot_name]=%[code] [slot_name]=%[code] | |
204 * | |
205 * as in printf, you pass in one additional argument to the function | |
206 * for every code. | |
207 * | |
208 * the formatting codes are: | |
209 * %d - put int in slot | |
210 * %f - put float in slot | |
211 * %p - put pointer in slot | |
212 * %h[f/e/v] - put elements with a header flag in slot. | |
213 * the letters after %h define which element types to use, | |
214 * so e.g. %hf will do faces, %hfe will do faces and edges, | |
215 * %hv will do verts, etc. must pass in at least one | |
216 * element type letter. | |
217 * %H[f/e/v] - same as %h, but tests if the flag is disabled | |
218 * %f[f/e/v] - same as %h, except it deals with tool flags instead of | |
219 * header flags. | |
220 * %F[f/e/v] - same as %f, but tests if the flag is disabled | |
221 * %a[f/e/v] - pass all elements (of types specified by f/e/v) to the | |
222 * slot. | |
223 * %e - pass in a single element. | |
224 * %v - pointer to a float vector of length 3. | |
225 * %m[3/4] - matrix, 3/4 refers to the matrix size, 3 or 4. the | |
226 * corresponding argument must be a pointer to | |
227 * a float matrix. | |
228 * %s - copy a slot from another op, instead of mapping to one | |
229 * argument, it maps to two, a pointer to an operator and | |
230 * a slot name. | |
231 */ | |
232 void BMO_push(BMesh *bm, BMOperator *op); | 246 void BMO_push(BMesh *bm, BMOperator *op); |
233 void BMO_pop(BMesh *bm); | 247 void BMO_pop(BMesh *bm); |
234 | 248 |
235 /*executes an operator*/ | 249 /*executes an operator*/ |
236 int BMO_op_callf(BMesh *bm, const int flag, const char *fmt, ...); | 250 bool BMO_op_callf(BMesh *bm, const int flag, const char *fmt, ...); |
237 | 251 |
238 /* initializes, but doesn't execute an operator. this is so you can | 252 /* initializes, but doesn't execute an operator. this is so you can |
239 * gain access to the outputs of the operator. note that you have | 253 * gain access to the outputs of the operator. note that you have |
240 * to execute/finish (BMO_op_exec and BMO_op_finish) yourself. */ | 254 * to execute/finish (BMO_op_exec and BMO_op_finish) yourself. */ |
241 int BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, ...
); | 255 bool BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, ..
.); |
242 | 256 |
243 /* va_list version, used to implement the above two functions, | 257 /* va_list version, used to implement the above two functions, |
244 * plus EDBM_op_callf in editmesh_utils.c. */ | 258 * plus EDBM_op_callf in editmesh_utils.c. */ |
245 int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, va
_list vlist); | 259 bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, v
a_list vlist); |
246 | 260 |
247 /* test whether a named slot exists */ | 261 /* test whether a named slot exists */ |
248 int BMO_slot_exists(BMOperator *op, const char *slot_name); | 262 bool BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifie
r); |
249 | 263 |
250 /* get a pointer to a slot. this may be removed layer on from the public API. *
/ | 264 /* get a pointer to a slot. this may be removed layer on from the public API. *
/ |
251 BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name); | 265 BMOpSlot *BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identif
ier); |
252 | |
253 /* copies the data of a slot from one operator to another. src and dst are the | |
254 * source/destination slot codes, respectively. */ | |
255 void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, | |
256 const char *src, const char *dst); | |
257 | |
258 /* del "context" slot values, used for operator too */ | |
259 enum { | |
260 » DEL_VERTS = 1, | |
261 » DEL_EDGES, | |
262 » DEL_ONLYFACES, | |
263 » DEL_EDGESFACES, | |
264 » DEL_FACES, | |
265 » DEL_ALL, | |
266 DEL_ONLYTAGGED | 266 DEL_ONLYTAGGED |
267 }; | 267 }; |
268 | 268 |
269 typedef enum { | |
270 BMO_SYMMETRIZE_NEGATIVE_X, | |
271 BMO_SYMMETRIZE_NEGATIVE_Y, | |
272 BMO_SYMMETRIZE_NEGATIVE_Z, | |
273 | |
274 BMO_SYMMETRIZE_POSITIVE_X, | |
275 BMO_SYMMETRIZE_POSITIVE_Y, | |
276 BMO_SYMMETRIZE_POSITIVE_Z, | |
277 } BMO_SymmDirection; | |
278 | |
279 void BMO_op_flag_enable(BMesh *bm, BMOperator *op, const int op_flag); | 269 void BMO_op_flag_enable(BMesh *bm, BMOperator *op, const int op_flag); |
280 void BMO_op_flag_disable(BMesh *bm, BMOperator *op, const int op_flag); | 270 void BMO_op_flag_disable(BMesh *bm, BMOperator *op, const int op_flag); |
281 | 271 |
282 void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f); | |
283 float BMO_slot_float_get(BMOperator *op, const char *slot_name); | |
284 void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i); | |
285 int BMO_slot_int_get(BMOperator *op, const char *slot_name); | |
286 void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i); | |
287 int BMO_slot_bool_get(BMOperator *op, const char *slot_name); | |
288 | |
289 /* don't pass in arrays that are supposed to map to elements this way. | |
290 * | |
291 * so, e.g. passing in list of floats per element in another slot is bad. | |
292 * passing in, e.g. pointer to an editmesh for the conversion operator is fine | |
293 * though. */ | |
294 void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p); | |
295 void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name); | |
296 void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]
); | |
297 void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]); | |
298 | |
299 /* only supports square mats */ | |
300 /* size must be 3 or 4; this api is meant only for transformation matrices. | |
301 * note that internally the matrix is stored in 4x4 form, and it's safe to | |
302 * call whichever BMO_Get_MatXXX function you want. */ | |
303 void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, i
nt size); | |
304 void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4])
; | |
305 void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3])
; | |
306 | |
307 void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *op, const char htype, cons
t short oflag); | |
308 | |
309 /* copies the values from another slot to the end of the output slot */ | |
310 void BMO_slot_buffer_append(BMOperator *output_op, const char *output_op_slot, | |
311 BMOperator *other_op, const char *other_op_slot); | |
312 | |
313 /* puts every element of type 'type' (which is a bitmask) with tool | |
314 * flag 'flag', into a slot. */ | |
315 void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *sl
ot_name, | |
316 const char htype, const short oflag); | |
317 | |
318 /* puts every element of type 'type' (which is a bitmask) without tool | |
319 * flag 'flag', into a slot. */ | |
320 void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *s
lot_name, | |
321 const char htype, const short oflag); | |
322 | |
323 /* tool-flags all elements inside an element slot array with flag flag. */ | |
324 void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_nam
e, | |
325 const char htype, const short oflag); | |
326 /* clears tool-flag flag from all elements inside a slot array. */ | |
327 void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_na
me, | |
328 const char htype, const short oflag); | |
329 | |
330 /* tool-flags all elements inside an element slot array with flag flag. */ | |
331 void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_na
me, | |
332 const char htype, const char hflag, const char
do_flush); | |
333 /* clears tool-flag flag from all elements inside a slot array. */ | |
334 void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_n
ame, | |
335 const char htype, const char hflag, const cha
r do_flush); | |
336 | |
337 /* puts every element of type 'type' (which is a bitmask) with header | |
338 * flag 'flag', into a slot. note: ignores hidden elements | |
339 * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ | |
340 void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, | |
341 const char *slot_name, | |
342 const char htype, const char hflag); | |
343 | |
344 /* puts every element of type 'type' (which is a bitmask) without | |
345 * header flag 'flag', into a slot. note: ignores hidden elements | |
346 * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ | |
347 void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, | |
348 const char *slot_name, | |
349 const char htype, const char hflag); | |
350 | |
351 /* counts number of elements inside a slot array. */ | |
352 int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slot_name); | |
353 int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slot_name); | |
354 | |
355 void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_nam
e, | |
356 void *element, void *data, int len); | |
357 | |
358 /* Counts the number of edges with tool flag toolflag around | |
359 */ | |
360 int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag); | |
361 | |
362 /* flags all elements in a mapping. note that the mapping must only have | |
363 * bmesh elements in it.*/ | |
364 void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, | |
365 const char hflag, const short oflag); | |
366 | |
367 void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len
); | |
368 | |
369 void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, | |
370 const char htype); | |
371 | |
372 /* this part of the API is used to iterate over element buffer or | |
373 * mapping slots. | |
374 * | |
375 * for example, iterating over the faces in a slot is: | |
376 * | |
377 * BMOIter oiter; | |
378 * BMFace *f; | |
379 * | |
380 * f = BMO_iter_new(&oiter, bm, some_operator, "slot_name", BM_FACE); | |
381 * for (; f; f = BMO_iter_step(&oiter)) { | |
382 * /do something with the face | |
383 * } | |
384 * | |
385 * another example, iterating over a mapping: | |
386 * BMOIter oiter; | |
387 * void *key; | |
388 * void *val; | |
389 * | |
390 * key = BMO_iter_new(&oiter, bm, some_operator, "slot_name", 0); | |
391 * for (; key; key = BMO_iter_step(&oiter)) { | |
392 * val = BMO_iter_map_value(&oiter); | |
393 * //do something with the key/val pair | |
394 * //note that val is a pointer to the val data, | |
395 * //whether it's a float, pointer, whatever. | |
396 * // | |
397 * // so to get a pointer, for example, use: | |
398 * // *((void**)BMO_iter_map_value(&oiter)); | |
399 * //or something like that. | |
400 * } | |
401 */ | |
402 | |
403 /* contents of this structure are private, | |
404 * don't directly access. */ | |
405 typedef struct BMOIter { | |
406 BMOpSlot *slot; | |
407 int cur; //for arrays | |
408 GHashIterator giter; | |
409 void *val; | |
410 char restrictmask; /* bitwise '&' with BMHeader.htype */ | |
411 } BMOIter; | |
412 | |
413 void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name); | |
414 | |
415 void *BMO_iter_new(BMOIter *iter, BMesh *bm, BMOperator *op, | |
416 const char *slot_name, const char restrictmask); | |
417 void *BMO_iter_step(BMOIter *iter); | |
418 | |
419 /* returns a pointer to the key value when iterating over mappings. | |
420 * remember for pointer maps this will be a pointer to a pointer.*/ | |
421 void *BMO_iter_map_value(BMOIter *iter); | |
422 | |
423 /* use this for pointer mappings */ | |
424 void *BMO_iter_map_value_p(BMOIter *iter); | |
425 | |
426 /* use this for float mappings */ | |
427 float BMO_iter_map_value_f(BMOIter *iter); | |
428 | |
429 #define BMO_ITER(ele, iter, bm, op, slot_name, restrict) \ | |
430 for (ele = BMO_iter_new(iter, bm, op, slot_name, restrict); ele; ele = B
MO_iter_step(iter)) | |
431 | |
432 /******************* Inlined Functions********************/ | |
433 typedef void (*opexec)(BMesh *bm, BMOperator *op); | |
434 | |
435 /* mappings map elements to data, which | |
436 * follows the mapping struct in memory. */ | |
437 typedef struct BMOElemMapping { | |
438 BMHeader *element; | |
439 int len; | |
440 } BMOElemMapping; | |
441 | |
442 extern const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES]; | |
443 | |
444 #ifdef __cplusplus | |
445 } | |
446 #endif | |
447 | |
448 #endif /* __BMESH_OPERATOR_API_H__ */ | |
LEFT | RIGHT |