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 *****
65 /* editmesh_utils.c */
66 void EDBM_verts_mirror_cache_begin_ex(struct BMEditMesh *em, const int axis,
67 const bool use_self, const bool use_select,
68 const bool use_topology, float maxdist, int *r_index);
69 void EDBM_verts_mirror_cache_begin(struct BMEditMesh *em, const int axis,
70 const bool use_self, const bool use_select, const bool use_toplogy);
71 void EDBM_verts_mirror_apply(struct BMEditMesh *em, const int sel_from, const int sel_to);
72 struct BMVert *EDBM_verts_mirror_get(struct BMEditMesh *em, struct BMVert *v);
73 struct BMEdge *EDBM_verts_mirror_get_edge(struct BMEditMesh *em, struct BMEdge *e);
74 struct BMFace *EDBM_verts_mirror_get_face(struct BMEditMesh *em, struct BMFace *f);
75 void EDBM_verts_mirror_cache_clear(struct BMEditMesh *em, struct BMVert *v);
76 void EDBM_verts_mirror_cache_end(struct BMEditMesh *em);
78 void EDBM_mesh_ensure_valid_dm_hack(struct Scene *scene, struct BMEditMesh *em);
79 void EDBM_mesh_normals_update(struct BMEditMesh *em);
80 void EDBM_mesh_clear(struct BMEditMesh *em);
82 void EDBM_selectmode_to_scene(struct bContext *C);
83 void EDBM_mesh_make(struct ToolSettings *ts, struct Object *ob);
84 void EDBM_mesh_free(struct BMEditMesh *em);
85 void EDBM_mesh_load(struct Object *ob);
86 struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em);
88 /* flushes based on the current select mode. if in vertex select mode,
89 * verts select/deselect edges and faces, if in edge select mode,
90 * edges select/deselect faces and vertices, and in face select mode faces select/deselect
91 * edges and vertices.*/
92 void EDBM_select_more(struct BMEditMesh *em, const bool use_face_step);
93 void EDBM_select_less(struct BMEditMesh *em, const bool use_face_step);
95 void EDBM_selectmode_flush_ex(struct BMEditMesh *em, const short selectmode);
96 void EDBM_selectmode_flush(struct BMEditMesh *em);
98 void EDBM_deselect_flush(struct BMEditMesh *em);
99 void EDBM_select_flush(struct BMEditMesh *em);
101 void undo_push_mesh(struct bContext *C, const char *name);
103 bool EDBM_vert_color_check(struct BMEditMesh *em);
105 void EDBM_mesh_hide(struct BMEditMesh *em, bool swap);
106 void EDBM_mesh_reveal(struct BMEditMesh *em);
108 void EDBM_update_generic(struct BMEditMesh *em, const bool do_tessface, const bool is_destructive);
110 struct UvElementMap *BM_uv_element_map_create(
112 const bool selected, const bool use_winding, const bool do_islands);
113 void BM_uv_element_map_free(struct UvElementMap *vmap);
114 struct UvElement *BM_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l);
116 bool EDBM_mtexpoly_check(struct BMEditMesh *em);
117 struct MTexPoly *EDBM_mtexpoly_active_get(struct BMEditMesh *em, struct BMFace **r_act_efa, 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 ARegion *ar, struct View3D *v3d, struct Object *obedit);
131 /* editmesh_select.c */
132 void EDBM_select_mirrored(struct BMEditMesh *em, bool extend,
133 int *r_totmirr, int *r_totfail);
134 void EDBM_automerge(struct Scene *scene, struct Object *ob, bool update, const char hflag);
136 bool EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
137 bool EDBM_backbuf_check(unsigned int index);
138 void EDBM_backbuf_free(void);
140 bool EDBM_backbuf_border_mask_init(struct ViewContext *vc, const int mcords[][2], short tot,
141 short xmin, short ymin, short xmax, short ymax);
142 bool EDBM_backbuf_circle_init(struct ViewContext *vc, short xs, short ys, short rads);
144 struct BMVert *EDBM_vert_find_nearest_ex(
145 struct ViewContext *vc, float *r_dist,
146 const bool use_select_bias, bool use_cycle);
147 struct BMVert *EDBM_vert_find_nearest(
148 struct ViewContext *vc, float *r_dist);
150 struct BMEdge *EDBM_edge_find_nearest_ex(
151 struct ViewContext *vc, float *r_dist,
152 float *r_dist_center,
153 const bool use_select_bias, const bool use_cycle,
154 struct BMEdge **r_eed_zbuf);
155 struct BMEdge *EDBM_edge_find_nearest(
156 struct ViewContext *vc, float *r_dist);
158 struct BMFace *EDBM_face_find_nearest_ex(
159 struct ViewContext *vc, float *r_dist,
160 float *r_dist_center,
161 const bool use_select_bias, const bool use_cycle,
162 struct BMFace **r_efa_zbuf);
163 struct BMFace *EDBM_face_find_nearest(
164 struct ViewContext *vc, float *r_dist);
166 bool EDBM_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
168 void EDBM_selectmode_set(struct BMEditMesh *em);
169 void EDBM_selectmode_convert(struct BMEditMesh *em, const short selectmode_old, const short selectmode_new);
171 /* user access this */
172 bool EDBM_selectmode_toggle(struct bContext *C, const short selectmode_new,
173 const int action, const bool use_extend, const bool use_expand);
175 bool EDBM_selectmode_disable(struct Scene *scene, struct BMEditMesh *em,
176 const short selectmode_disable,
177 const short selectmode_fallback);
179 void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const bool select);
181 void EDBM_select_toggle_all(struct BMEditMesh *em);
183 void EDBM_select_swap(struct BMEditMesh *em); /* exported for UV */
184 bool EDBM_select_interior_faces(struct BMEditMesh *em);
185 void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc); /* rename? */
187 extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs;
190 void ED_operatortypes_mesh(void);
191 void ED_operatormacros_mesh(void);
192 void ED_keymap_mesh(struct wmKeyConfig *keyconf);
194 /* editmesh_tools.c (could be moved) */
195 void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEditMesh *em);
199 void paintface_flush_flags(struct Object *ob, short flag);
200 bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle);
201 int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
202 void paintface_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
203 void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], const bool select);
204 bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]);
206 void paintface_hide(struct Object *ob, const bool unselected);
207 void paintface_reveal(struct Object *ob);
209 void paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
210 void paintvert_select_ungrouped(struct Object *ob, bool extend, bool flush_flags);
211 void paintvert_flush_flags(struct Object *ob);
214 typedef struct MirrTopoStore_t {
215 intptr_t *index_lookup;
221 bool ED_mesh_mirrtopo_recalc_check(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store);
222 void ED_mesh_mirrtopo_init(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store,
223 const bool skip_em_vert_array_init);
224 void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store);
227 /* object_vgroup.c */
228 #define WEIGHT_REPLACE 1
230 #define WEIGHT_SUBTRACT 3
232 bool ED_vgroup_sync_from_pose(struct Object *ob);
233 void ED_vgroup_select_by_name(struct Object *ob, const char *name);
234 void ED_vgroup_data_clamp_range(struct ID *id, const int total);
235 bool ED_vgroup_array_copy(struct Object *ob, struct Object *ob_from);
236 bool ED_vgroup_parray_alloc(struct ID *id, struct MDeformVert ***dvert_arr, int *dvert_tot,
237 const bool use_vert_sel);
238 void ED_vgroup_parray_mirror_sync(struct Object *ob,
239 struct MDeformVert **dvert_array, const int dvert_tot,
240 const bool *vgroup_validmap, const int vgroup_tot);
241 void ED_vgroup_parray_mirror_assign(struct Object *ob,
242 struct MDeformVert **dvert_array, const int dvert_tot);
243 void ED_vgroup_parray_remove_zero(struct MDeformVert **dvert_array, const int dvert_tot,
244 const bool *vgroup_validmap, const int vgroup_tot,
245 const float epsilon, const bool keep_single);
246 void ED_vgroup_parray_to_weight_array(const struct MDeformVert **dvert_array, const int dvert_tot,
247 float *dvert_weights, const int def_nr);
248 void ED_vgroup_parray_from_weight_array(struct MDeformVert **dvert_array, const int dvert_tot,
249 const float *dvert_weights, const int def_nr,
250 const bool remove_zero);
251 void ED_vgroup_mirror(struct Object *ob,
252 const bool mirror_weights, const bool flip_vgroups,
253 const bool all_vgroups, const bool use_topology,
254 int *r_totmirr, int *r_totfail);
256 void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode);
257 void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum);
258 float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum);
259 void ED_vgroup_vert_active_mirror(struct Object *ob, int def_nr);
263 // void ED_mesh_geometry_add(struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces);
264 void ED_mesh_polys_add(struct Mesh *mesh, struct ReportList *reports, int count);
265 void ED_mesh_tessfaces_add(struct Mesh *mesh, struct ReportList *reports, int count);
266 void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int count);
267 void ED_mesh_loops_add(struct Mesh *mesh, struct ReportList *reports, int count);
268 void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count);
270 void ED_mesh_faces_remove(struct Mesh *mesh, struct ReportList *reports, int count);
271 void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int count);
272 void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count);
274 void ED_mesh_calc_tessface(struct Mesh *mesh, bool free_mpoly);
275 void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface);
277 void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name);
278 int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set);
279 bool ED_mesh_uv_texture_remove_index(struct Mesh *me, const int n);
280 bool ED_mesh_uv_texture_remove_active(struct Mesh *me);
281 bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name);
282 void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me);
283 void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum);
284 int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set);
285 bool ED_mesh_color_remove_index(struct Mesh *me, const int n);
286 bool ED_mesh_color_remove_active(struct Mesh *me);
287 bool ED_mesh_color_remove_named(struct Mesh *me, const char *name);
289 void ED_mesh_report_mirror(struct wmOperator *op, int totmirr, int totfail);
290 void ED_mesh_report_mirror_ex(struct wmOperator *op, int totmirr, int totfail,
294 typedef struct BMBackup {
295 struct BMesh *bmcopy;
298 /* save a copy of the bmesh for restoring later */
299 struct BMBackup EDBM_redo_state_store(struct BMEditMesh *em);
300 /* restore a bmesh from backup */
301 void EDBM_redo_state_restore(struct BMBackup, struct BMEditMesh *em, int recalctess);
302 /* delete the backup, optionally flushing it to an editmesh */
303 void EDBM_redo_state_free(struct BMBackup *, struct BMEditMesh *em, int recalctess);
306 /* *** meshtools.c *** */
307 int join_mesh_exec(struct bContext *C, struct wmOperator *op);
308 int join_mesh_shapes_exec(struct bContext *C, struct wmOperator *op);
310 /* mirror lookup api */
311 int ED_mesh_mirror_spatial_table(struct Object *ob, struct BMEditMesh *em, const float co[3], char mode);
312 int ED_mesh_mirror_topo_table(struct Object *ob, char mode);
314 /* retrieves mirrored cache vert, or NULL if there isn't one.
315 * note: calling this without ensuring the mirror cache state
317 int mesh_get_x_mirror_vert(struct Object *ob, int index, const bool use_topology);
318 struct BMVert *editbmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em,
319 struct BMVert *eve, const float co[3],
320 int index, const bool use_topology);
321 int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em);
323 int ED_mesh_mirror_get_vert(struct Object *ob, int index);
325 bool ED_mesh_pick_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size, bool use_zbuf);
326 bool ED_mesh_pick_face(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size);
327 bool ED_mesh_pick_face_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size);
330 struct MDeformVert *ED_mesh_active_dvert_get_em(struct Object *ob, struct BMVert **r_eve);
331 struct MDeformVert *ED_mesh_active_dvert_get_ob(struct Object *ob, int *r_index);
332 struct MDeformVert *ED_mesh_active_dvert_get_only(struct Object *ob);
334 #define ED_MESH_PICK_DEFAULT_VERT_SIZE 50
335 #define ED_MESH_PICK_DEFAULT_FACE_SIZE 3
337 #define USE_LOOPSLIDE_HACK
343 #endif /* __ED_MESH_H__ */