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 *****
46 struct wmWindowManager;
64 struct BMEditSelection;
78 // edge and face flag both
81 #define EM_FGON_DRAW 1
88 #define B_BEAUTY_SHORT 16
91 #define B_PERCENTSUBD 0x40
92 //#define B_MESH_X_MIRROR 0x100 // deprecated, use mesh
93 #define B_JOINTRIA_UV 0x200
94 #define B_JOINTRIA_VCOL 0X400
95 #define B_JOINTRIA_SHARP 0X800
96 #define B_JOINTRIA_MAT 0X1000
97 #define B_FRACTAL 0x2000
98 #define B_SPHERE 0x4000
100 float *bm_get_cd_float(struct CustomData *cdata, void *data, int type);
105 [note: I've decided to use ideasman's code for non-editmode stuff, but since
106 it has a big "not for editmode!" disclaimer, I'm going to keep what I have here
109 x-mirror editing api. usage:
111 EDBM_CacheMirrorVerts(em);
114 BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
115 mirrorv = EDBM_GetMirrorVert(em, v);
119 EDBM_EndMirrorCache(em);
121 note: why do we only allow x axis mirror editing?
123 void EDBM_CacheMirrorVerts(struct BMEditMesh *em, const short use_select); /* note, replaces EM_cache_x_mirror_vert in trunk */
125 /*retrieves mirrored cache vert, or NULL if there isn't one.
126 note: calling this without ensuring the mirror cache state
128 struct BMVert *EDBM_GetMirrorVert(struct BMEditMesh *em, struct BMVert *v);
129 void EDBM_ClearMirrorVert(struct BMEditMesh *em, struct BMVert *v);
130 void EDBM_EndMirrorCache(struct BMEditMesh *em);
131 void EDBM_ApplyMirrorCache(struct BMEditMesh *em, const int sel_from, const int sel_to);
133 void EDBM_RecalcNormals(struct BMEditMesh *em);
135 void EDBM_MakeEditBMesh(struct ToolSettings *ts, struct Scene *scene, struct Object *ob);
136 void EDBM_FreeEditBMesh(struct BMEditMesh *tm);
137 void EDBM_LoadEditBMesh(struct Scene *scene, struct Object *ob);
139 void EDBM_init_index_arrays(struct BMEditMesh *em, int forvert, int foredge, int forface);
140 void EDBM_free_index_arrays(struct BMEditMesh *em);
141 struct BMVert *EDBM_get_vert_for_index(struct BMEditMesh *em, int index);
142 struct BMEdge *EDBM_get_edge_for_index(struct BMEditMesh *em, int index);
143 struct BMFace *EDBM_get_face_for_index(struct BMEditMesh *em, int index);
145 int EDBM_CallAndSelectOpf(struct BMEditMesh *em, struct wmOperator *op,
146 const char *selectslot, const char *fmt, ...);
148 /*flushes based on the current select mode. if in vertex select mode,
149 verts select/deselect edges and faces, if in edge select mode,
150 edges select/deselect faces and vertices, and in face select mode faces select/deselect
151 edges and vertices.*/
152 void EDBM_selectmode_flush(struct BMEditMesh *em);
154 int EDBM_get_actSelection(struct BMEditMesh *em, struct BMEditSelection *ese);
156 /*exactly the same as EDBM_selectmode_flush, but you pass in the selectmode
157 instead of using the current one*/
158 void EDBM_select_flush(struct BMEditMesh *em, int selectmode);
159 void EDBM_deselect_flush(struct BMEditMesh *em);
161 void EDBM_selectmode_set(struct BMEditMesh *em);
162 void EDBM_convertsel(struct BMEditMesh *em, short oldmode, short selectmode);
163 void undo_push_mesh(struct bContext *C, const char *name);
165 void EDBM_editselection_center(struct BMEditMesh *em, float *center, struct BMEditSelection *ese);
166 void EDBM_editselection_plane(struct BMEditMesh *em, float *plane, struct BMEditSelection *ese);
167 void EDBM_editselection_normal(float *normal, struct BMEditSelection *ese);
168 int EDBM_vertColorCheck(struct BMEditMesh *em);
169 void EDBM_validate_selections(struct BMEditMesh *em);
171 void EDBM_hide_mesh(struct BMEditMesh *em, int swap);
172 void EDBM_reveal_mesh(struct BMEditMesh *em);
174 int EDBM_check_backbuf(unsigned int index);
175 int EDBM_mask_init_backbuf_border(struct ViewContext *vc, int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax);
176 void EDBM_free_backbuf(void);
177 int EDBM_init_backbuf_border(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
178 int EDBM_init_backbuf_circle(struct ViewContext *vc, short xs, short ys, short rads);
180 void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const short select);
182 void EDBM_select_swap(struct BMEditMesh *em); /* exported for UV */
184 int EDBM_texFaceCheck(struct BMEditMesh *em);
185 struct MTexPoly *EDBM_get_active_mtexpoly(struct BMEditMesh *em, struct BMFace **act_efa, int sloppy);
187 void EDBM_free_uv_vert_map(struct UvVertMap *vmap);
188 struct UvMapVert *EDBM_get_uv_map_vert(struct UvVertMap *vmap, unsigned int v);
189 struct UvVertMap *EDBM_make_uv_vert_map(struct BMEditMesh *em, int selected, int do_face_idx_array, float *limit);
190 void EM_add_data_layer(struct BMEditMesh *em, struct CustomData *data, int type, const char *name);
191 void EM_free_data_layer(struct BMEditMesh *em, struct CustomData *data, int type);
193 void EDBM_toggle_select_all(struct BMEditMesh *em);
194 void EDBM_set_flag_all(struct BMEditMesh *em, const char hflag);
195 void EDBM_clear_flag_all(struct BMEditMesh *em, const char hflag);
196 void EDBM_automerge(struct Scene *scene, struct Object *ob, int update);
198 /* editmesh_mods.c */
199 extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs;
201 intptr_t mesh_octree_table(struct Object *ob, struct BMEditMesh *em, float *co, char mode);
202 long mesh_mirrtopo_table(struct Object *ob, char mode);
204 int mouse_mesh(struct bContext *C, const int mval[2], short extend);
206 struct BMVert *editbmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em, struct BMVert *eve, float *co, int index);
207 int mesh_get_x_mirror_vert(struct Object *ob, int index);
208 int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em);
210 int join_mesh_exec(struct bContext *C, struct wmOperator *op);
211 int join_mesh_shapes_exec(struct bContext *C, struct wmOperator *op);
214 void ED_operatortypes_mesh(void);
215 void ED_operatormacros_mesh(void);
216 void ED_keymap_mesh(struct wmKeyConfig *keyconf);
221 void ED_spacetypes_init(void);
222 void ED_keymap_mesh(struct wmKeyConfig *keyconf);
225 extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs;
227 /* bmesh_tools.c (could be moved) */
228 void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct Object *obedit, struct BMEditMesh *em);
231 void paintface_flush_flags(struct Object *ob);
232 struct MTexPoly *EM_get_active_mtexpoly(struct BMEditMesh *em, struct BMFace **act_efa, struct MLoopCol **col, int sloppy);
233 int paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], int extend);
234 int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int select, int extend);
235 void paintface_deselect_all_visible(struct Object *ob, int action, short flush_flags);
236 void paintface_select_linked(struct bContext *C, struct Object *ob, int mval[2], int mode);
237 int paintface_minmax(struct Object *ob, float *min, float *max);
239 void paintface_hide(struct Object *ob, const int unselected);
240 void paintface_reveal(struct Object *ob);
242 void paintvert_deselect_all_visible(struct Object *ob, int action, short flush_flags);
243 void paintvert_flush_flags(struct Object *ob);
245 /* object_vgroup.c */
247 #define WEIGHT_REPLACE 1
249 #define WEIGHT_SUBTRACT 3
251 struct bDeformGroup *ED_vgroup_add(struct Object *ob);
252 struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, const char *name);
253 void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *defgroup);
254 void ED_vgroup_select_by_name(struct Object *ob, const char *name);
255 int ED_vgroup_data_create(struct ID *id);
256 int ED_vgroup_give_array(struct ID *id, struct MDeformVert **dvert_arr, int *dvert_tot);
257 int ED_vgroup_copy_array(struct Object *ob, struct Object *ob_from);
258 void ED_vgroup_mirror(struct Object *ob, const short mirror_weights, const short flip_vgroups, const short all_vgroups);
260 int ED_vgroup_object_is_edit_mode(struct Object *ob);
262 void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode);
263 void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum);
264 float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum);
269 * dist (in/out): minimal distance to the nearest and at the end, actual distance
270 * sel: selection bias
271 * if SELECT, selected vertice are given a 5 pixel bias to make them farter than unselect verts
272 * if 0, unselected vertice are given the bias
273 * strict: if 1, the vertice corresponding to the sel parameter are ignored and not just biased
276 struct BMVert *EDBM_findnearestvert(struct ViewContext *vc, int *dist, short sel, short strict);
277 struct BMEdge *EDBM_findnearestedge(struct ViewContext *vc, int *dist);
278 struct BMFace *EDBM_findnearestface(struct ViewContext *vc, int *dist);
281 // void ED_mesh_geometry_add(struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces);
282 void ED_mesh_polys_add(struct Mesh *mesh, struct ReportList *reports, int count);
283 void ED_mesh_faces_add(struct Mesh *mesh, struct ReportList *reports, int count);
284 void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int count);
285 void ED_mesh_loops_add(struct Mesh *mesh, struct ReportList *reports, int count);
286 void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count);
288 void ED_mesh_transform(struct Mesh *me, float *mat);
289 void ED_mesh_calc_normals(struct Mesh *me);
290 void ED_mesh_material_link(struct Mesh *me, struct Material *ma);
291 void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges);
293 int ED_mesh_uv_texture_add(struct bContext *C, struct Mesh *me, const char *name, int active_set);
294 int ED_mesh_uv_texture_remove(struct bContext *C, struct Object *ob, struct Mesh *me);
295 int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me, const char *name, int active_set);
296 int ED_mesh_color_remove(struct bContext *C, struct Object *ob, struct Mesh *me);
298 void EDBM_selectmode_to_scene(struct bContext *C);
299 void EDBM_ClearMesh(struct BMEditMesh *em);
301 #include "../mesh/editbmesh_bvh.h"
307 #endif /* ED_MESH_H */