2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2008 Blender Foundation.
19 * All rights reserved.
22 * Contributor(s): Blender Foundation
24 * ***** END GPL LICENSE BLOCK *****
67 /* editmesh_utils.c */
68 void EDBM_verts_mirror_cache_begin_ex(struct BMEditMesh *em, const int axis,
69 const bool use_self, const bool use_select,
70 const bool use_topology, float maxdist, int *r_index);
71 void EDBM_verts_mirror_cache_begin(struct BMEditMesh *em, const int axis,
72 const bool use_self, const bool use_select, const bool use_toplogy);
73 void EDBM_verts_mirror_apply(struct BMEditMesh *em, const int sel_from, const int sel_to);
74 struct BMVert *EDBM_verts_mirror_get(struct BMEditMesh *em, struct BMVert *v);
75 struct BMEdge *EDBM_verts_mirror_get_edge(struct BMEditMesh *em, struct BMEdge *e);
76 struct BMFace *EDBM_verts_mirror_get_face(struct BMEditMesh *em, struct BMFace *f);
77 void EDBM_verts_mirror_cache_clear(struct BMEditMesh *em, struct BMVert *v);
78 void EDBM_verts_mirror_cache_end(struct BMEditMesh *em);
80 void EDBM_mesh_normals_update(struct BMEditMesh *em);
81 void EDBM_mesh_clear(struct BMEditMesh *em);
83 void EDBM_selectmode_to_scene(struct bContext *C);
84 void EDBM_mesh_make(struct Object *ob, const int select_mode, const bool add_key_index);
85 void EDBM_mesh_free(struct BMEditMesh *em);
86 void EDBM_mesh_load(struct Object *ob);
87 struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em);
89 /* flushes based on the current select mode. if in vertex select mode,
90 * verts select/deselect edges and faces, if in edge select mode,
91 * edges select/deselect faces and vertices, and in face select mode faces select/deselect
92 * edges and vertices.*/
93 void EDBM_select_more(struct BMEditMesh *em, const bool use_face_step);
94 void EDBM_select_less(struct BMEditMesh *em, const bool use_face_step);
96 void EDBM_selectmode_flush_ex(struct BMEditMesh *em, const short selectmode);
97 void EDBM_selectmode_flush(struct BMEditMesh *em);
99 void EDBM_deselect_flush(struct BMEditMesh *em);
100 void EDBM_select_flush(struct BMEditMesh *em);
102 bool EDBM_vert_color_check(struct BMEditMesh *em);
104 void EDBM_mesh_hide(struct BMEditMesh *em, bool swap);
105 void EDBM_mesh_reveal(struct BMEditMesh *em, bool select);
107 void EDBM_update_generic(struct BMEditMesh *em, const bool do_tessface, const bool is_destructive);
109 struct UvElementMap *BM_uv_element_map_create(
111 const bool selected, const bool use_winding, const bool do_islands);
112 void BM_uv_element_map_free(struct UvElementMap *vmap);
113 struct UvElement *BM_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l);
115 bool EDBM_uv_check(struct BMEditMesh *em);
116 struct BMFace *EDBM_uv_active_face_get(
117 struct BMEditMesh *em, const bool sloppy, const bool selected);
119 void BM_uv_vert_map_free(struct UvVertMap *vmap);
120 struct UvMapVert *BM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int v);
121 struct UvVertMap *BM_uv_vert_map_create(
123 const float limit[2], const bool use_select, const bool use_winding);
125 void EDBM_flag_enable_all(struct BMEditMesh *em, const char hflag);
126 void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag);
128 bool BMBVH_EdgeVisible(struct BMBVHTree *tree, struct BMEdge *e,
129 struct Depsgraph *depsgraph,
130 struct ARegion *ar, struct View3D *v3d, struct Object *obedit);
132 /* editmesh_undo.c */
133 void ED_mesh_undosys_type(struct UndoType *ut);
135 /* editmesh_select.c */
136 void EDBM_select_mirrored(
137 struct BMEditMesh *em, const int axis, const bool extend,
138 int *r_totmirr, int *r_totfail);
139 void EDBM_automerge(struct Scene *scene, struct Object *ob, bool update, const char hflag);
141 bool EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
142 bool EDBM_backbuf_check(unsigned int index);
143 void EDBM_backbuf_free(void);
145 bool EDBM_backbuf_border_mask_init(
146 struct ViewContext *vc, const int mcords[][2], short tot,
147 short xmin, short ymin, short xmax, short ymax);
148 bool EDBM_backbuf_circle_init(struct ViewContext *vc, short xs, short ys, short rads);
150 struct BMVert *EDBM_vert_find_nearest_ex(
151 struct ViewContext *vc, float *r_dist,
152 const bool use_select_bias, bool use_cycle);
153 struct BMVert *EDBM_vert_find_nearest(
154 struct ViewContext *vc, float *r_dist);
156 struct BMEdge *EDBM_edge_find_nearest_ex(
157 struct ViewContext *vc, float *r_dist,
158 float *r_dist_center,
159 const bool use_select_bias, const bool use_cycle,
160 struct BMEdge **r_eed_zbuf);
161 struct BMEdge *EDBM_edge_find_nearest(
162 struct ViewContext *vc, float *r_dist);
164 struct BMFace *EDBM_face_find_nearest_ex(
165 struct ViewContext *vc, float *r_dist,
166 float *r_dist_center,
167 const bool use_select_bias, const bool use_cycle,
168 struct BMFace **r_efa_zbuf);
169 struct BMFace *EDBM_face_find_nearest(
170 struct ViewContext *vc, float *r_dist);
172 bool EDBM_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
174 void EDBM_selectmode_set(struct BMEditMesh *em);
175 void EDBM_selectmode_convert(struct BMEditMesh *em, const short selectmode_old, const short selectmode_new);
177 /* user access this */
178 bool EDBM_selectmode_toggle(struct bContext *C, const short selectmode_new,
179 const int action, const bool use_extend, const bool use_expand);
181 bool EDBM_selectmode_disable(struct Scene *scene, struct BMEditMesh *em,
182 const short selectmode_disable,
183 const short selectmode_fallback);
185 void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const bool select);
187 void EDBM_select_toggle_all(struct BMEditMesh *em);
189 void EDBM_select_swap(struct BMEditMesh *em); /* exported for UV */
190 bool EDBM_select_interior_faces(struct BMEditMesh *em);
191 void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc); /* rename? */
193 extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs;
196 void ED_operatortypes_mesh(void);
197 void ED_operatormacros_mesh(void);
198 void ED_keymap_mesh(struct wmKeyConfig *keyconf);
200 /* editmesh_tools.c (could be moved) */
201 void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEditMesh *em);
205 void paintface_flush_flags(struct Object *ob, short flag);
206 bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle);
207 int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
208 void paintface_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
209 void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], const bool select);
210 bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]);
212 void paintface_hide(struct Object *ob, const bool unselected);
213 void paintface_reveal(struct Object *ob, const bool select);
215 void paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
216 void paintvert_select_ungrouped(struct Object *ob, bool extend, bool flush_flags);
217 void paintvert_flush_flags(struct Object *ob);
220 typedef struct MirrTopoStore_t {
221 intptr_t *index_lookup;
224 bool prev_is_editmode;
227 bool ED_mesh_mirrtopo_recalc_check(
228 struct Mesh *me, struct DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store);
229 void ED_mesh_mirrtopo_init(
230 struct Mesh *me, struct DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store,
231 const bool skip_em_vert_array_init);
232 void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store);
235 /* object_vgroup.c */
236 #define WEIGHT_REPLACE 1
238 #define WEIGHT_SUBTRACT 3
240 bool ED_vgroup_sync_from_pose(struct Object *ob);
241 void ED_vgroup_select_by_name(struct Object *ob, const char *name);
242 void ED_vgroup_data_clamp_range(struct ID *id, const int total);
243 bool ED_vgroup_array_copy(struct Object *ob, struct Object *ob_from);
244 bool ED_vgroup_parray_alloc(struct ID *id, struct MDeformVert ***dvert_arr, int *dvert_tot,
245 const bool use_vert_sel);
246 void ED_vgroup_parray_mirror_sync(struct Object *ob,
247 struct MDeformVert **dvert_array, const int dvert_tot,
248 const bool *vgroup_validmap, const int vgroup_tot);
249 void ED_vgroup_parray_mirror_assign(struct Object *ob,
250 struct MDeformVert **dvert_array, const int dvert_tot);
251 void ED_vgroup_parray_remove_zero(struct MDeformVert **dvert_array, const int dvert_tot,
252 const bool *vgroup_validmap, const int vgroup_tot,
253 const float epsilon, const bool keep_single);
254 void ED_vgroup_parray_to_weight_array(const struct MDeformVert **dvert_array, const int dvert_tot,
255 float *dvert_weights, const int def_nr);
256 void ED_vgroup_parray_from_weight_array(struct MDeformVert **dvert_array, const int dvert_tot,
257 const float *dvert_weights, const int def_nr,
258 const bool remove_zero);
259 void ED_vgroup_mirror(struct Object *ob,
260 const bool mirror_weights, const bool flip_vgroups,
261 const bool all_vgroups, const bool use_topology,
262 int *r_totmirr, int *r_totfail);
264 void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode);
265 void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum);
266 float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum);
267 void ED_vgroup_vert_active_mirror(struct Object *ob, int def_nr);
270 // void ED_mesh_geometry_add(struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces);
271 void ED_mesh_polys_add(struct Mesh *mesh, struct ReportList *reports, int count);
272 void ED_mesh_tessfaces_add(struct Mesh *mesh, struct ReportList *reports, int count);
273 void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int count);
274 void ED_mesh_loops_add(struct Mesh *mesh, struct ReportList *reports, int count);
275 void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count);
277 void ED_mesh_faces_remove(struct Mesh *mesh, struct ReportList *reports, int count);
278 void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int count);
279 void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count);
281 void ED_mesh_calc_tessface(struct Mesh *mesh, bool free_mpoly);
282 void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface);
284 void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name);
285 int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set);
286 bool ED_mesh_uv_texture_remove_index(struct Mesh *me, const int n);
287 bool ED_mesh_uv_texture_remove_active(struct Mesh *me);
288 bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name);
289 void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me);
290 void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum);
291 bool ED_mesh_color_ensure(struct Mesh *me, const char *name);
292 int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set);
293 bool ED_mesh_color_remove_index(struct Mesh *me, const int n);
294 bool ED_mesh_color_remove_active(struct Mesh *me);
295 bool ED_mesh_color_remove_named(struct Mesh *me, const char *name);
297 void ED_mesh_report_mirror(struct wmOperator *op, int totmirr, int totfail);
298 void ED_mesh_report_mirror_ex(struct wmOperator *op, int totmirr, int totfail,
302 typedef struct BMBackup {
303 struct BMesh *bmcopy;
306 /* save a copy of the bmesh for restoring later */
307 struct BMBackup EDBM_redo_state_store(struct BMEditMesh *em);
308 /* restore a bmesh from backup */
309 void EDBM_redo_state_restore(struct BMBackup, struct BMEditMesh *em, int recalctess);
310 /* delete the backup, optionally flushing it to an editmesh */
311 void EDBM_redo_state_free(struct BMBackup *, struct BMEditMesh *em, int recalctess);
314 /* *** meshtools.c *** */
315 int join_mesh_exec(struct bContext *C, struct wmOperator *op);
316 int join_mesh_shapes_exec(struct bContext *C, struct wmOperator *op);
318 /* mirror lookup api */
319 int ED_mesh_mirror_spatial_table(
320 struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, const float co[3], char mode);
321 int ED_mesh_mirror_topo_table(struct Object *ob, struct DerivedMesh *dm, char mode);
323 /* retrieves mirrored cache vert, or NULL if there isn't one.
324 * note: calling this without ensuring the mirror cache state
326 int mesh_get_x_mirror_vert(struct Object *ob, struct DerivedMesh *dm, int index, const bool use_topology);
327 struct BMVert *editbmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em,
328 struct BMVert *eve, const float co[3],
329 int index, const bool use_topology);
330 int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm);
332 int ED_mesh_mirror_get_vert(struct Object *ob, int index);
334 bool ED_mesh_pick_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size, bool use_zbuf);
335 bool ED_mesh_pick_face(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size);
336 bool ED_mesh_pick_face_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size);
339 struct MDeformVert *ED_mesh_active_dvert_get_em(struct Object *ob, struct BMVert **r_eve);
340 struct MDeformVert *ED_mesh_active_dvert_get_ob(struct Object *ob, int *r_index);
341 struct MDeformVert *ED_mesh_active_dvert_get_only(struct Object *ob);
343 void EDBM_mesh_stats_multi(struct Object **objects, const uint objects_len, int totelem[3], int totelem_sel[3]);
344 void EDBM_mesh_elem_index_ensure_multi(struct Object **objects, const uint objects_len, const char htype);
346 #define ED_MESH_PICK_DEFAULT_VERT_SIZE 50
347 #define ED_MESH_PICK_DEFAULT_FACE_SIZE 3
349 #define USE_LOOPSLIDE_HACK
355 #endif /* __ED_MESH_H__ */