Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / mesh / mesh_ops.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
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.
8  *
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.
13  *
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.
17  *
18  * The Original Code is Copyright (C) 2009 Blender Foundation.
19  * All rights reserved.
20  *
21  *
22  * Contributor(s): Blender Foundation
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/editors/mesh/mesh_ops.c
28  *  \ingroup edmesh
29  */
30
31 #include "DNA_scene_types.h"
32 #include "DNA_modifier_types.h"
33
34
35 #include "RNA_access.h"
36
37 #include "WM_api.h"
38 #include "WM_types.h"
39
40 #include "ED_object.h"
41 #include "ED_mesh.h"
42 #include "ED_screen.h"
43
44 #include "mesh_intern.h"  /* own include */
45
46 /**************************** registration **********************************/
47
48 void ED_operatortypes_mesh(void)
49 {
50         WM_operatortype_append(MESH_OT_select_all);
51         WM_operatortype_append(MESH_OT_select_interior_faces);
52         WM_operatortype_append(MESH_OT_select_more);
53         WM_operatortype_append(MESH_OT_select_less);
54         WM_operatortype_append(MESH_OT_select_non_manifold);
55         WM_operatortype_append(MESH_OT_select_linked);
56         WM_operatortype_append(MESH_OT_select_linked_pick);
57         WM_operatortype_append(MESH_OT_select_random);
58         WM_operatortype_append(MESH_OT_select_ungrouped);
59         WM_operatortype_append(MESH_OT_hide);
60         WM_operatortype_append(MESH_OT_reveal);
61         WM_operatortype_append(MESH_OT_select_face_by_sides);
62         WM_operatortype_append(MESH_OT_select_loose);
63         WM_operatortype_append(MESH_OT_select_mirror);
64         WM_operatortype_append(MESH_OT_normals_make_consistent);
65         WM_operatortype_append(MESH_OT_merge);
66         WM_operatortype_append(MESH_OT_subdivide);
67         WM_operatortype_append(MESH_OT_subdivide_edgering);
68         WM_operatortype_append(MESH_OT_unsubdivide);
69         WM_operatortype_append(MESH_OT_faces_select_linked_flat);
70         WM_operatortype_append(MESH_OT_edges_select_sharp);
71         WM_operatortype_append(MESH_OT_primitive_plane_add);
72         WM_operatortype_append(MESH_OT_primitive_cube_add);
73         WM_operatortype_append(MESH_OT_primitive_circle_add);
74         WM_operatortype_append(MESH_OT_primitive_cylinder_add);
75         WM_operatortype_append(MESH_OT_primitive_cone_add);
76         WM_operatortype_append(MESH_OT_primitive_grid_add);
77         WM_operatortype_append(MESH_OT_primitive_monkey_add);
78         WM_operatortype_append(MESH_OT_primitive_uv_sphere_add);
79         WM_operatortype_append(MESH_OT_primitive_ico_sphere_add);
80
81         WM_operatortype_append(MESH_OT_primitive_cube_add_manipulator);
82
83         WM_operatortype_append(MESH_OT_duplicate);
84         WM_operatortype_append(MESH_OT_remove_doubles);
85         WM_operatortype_append(MESH_OT_spin);
86         WM_operatortype_append(MESH_OT_screw);
87
88         WM_operatortype_append(MESH_OT_extrude_region);
89         WM_operatortype_append(MESH_OT_extrude_context);
90         WM_operatortype_append(MESH_OT_extrude_faces_indiv);
91         WM_operatortype_append(MESH_OT_extrude_edges_indiv);
92         WM_operatortype_append(MESH_OT_extrude_verts_indiv);
93
94         WM_operatortype_append(MESH_OT_split);
95         WM_operatortype_append(MESH_OT_extrude_repeat);
96         WM_operatortype_append(MESH_OT_edge_rotate);
97         WM_operatortype_append(MESH_OT_shortest_path_select);
98         WM_operatortype_append(MESH_OT_loop_to_region);
99         WM_operatortype_append(MESH_OT_region_to_loop);
100         WM_operatortype_append(MESH_OT_select_axis);
101
102         WM_operatortype_append(MESH_OT_uvs_rotate);
103         WM_operatortype_append(MESH_OT_uvs_reverse);
104         WM_operatortype_append(MESH_OT_colors_rotate);
105         WM_operatortype_append(MESH_OT_colors_reverse);
106
107         WM_operatortype_append(MESH_OT_fill);
108         WM_operatortype_append(MESH_OT_fill_grid);
109         WM_operatortype_append(MESH_OT_fill_holes);
110         WM_operatortype_append(MESH_OT_beautify_fill);
111         WM_operatortype_append(MESH_OT_quads_convert_to_tris);
112         WM_operatortype_append(MESH_OT_tris_convert_to_quads);
113         WM_operatortype_append(MESH_OT_decimate);
114         WM_operatortype_append(MESH_OT_dissolve_verts);
115         WM_operatortype_append(MESH_OT_dissolve_edges);
116         WM_operatortype_append(MESH_OT_dissolve_faces);
117         WM_operatortype_append(MESH_OT_dissolve_mode);
118         WM_operatortype_append(MESH_OT_dissolve_limited);
119         WM_operatortype_append(MESH_OT_dissolve_degenerate);
120         WM_operatortype_append(MESH_OT_delete_edgeloop);
121         WM_operatortype_append(MESH_OT_faces_shade_smooth);
122         WM_operatortype_append(MESH_OT_faces_shade_flat);
123         WM_operatortype_append(MESH_OT_sort_elements);
124 #ifdef WITH_FREESTYLE
125         WM_operatortype_append(MESH_OT_mark_freestyle_face);
126 #endif
127
128         WM_operatortype_append(MESH_OT_delete);
129         WM_operatortype_append(MESH_OT_delete_loose);
130         WM_operatortype_append(MESH_OT_edge_collapse);
131
132         WM_operatortype_append(MESH_OT_separate);
133         WM_operatortype_append(MESH_OT_dupli_extrude_cursor);
134         WM_operatortype_append(MESH_OT_loop_select);
135         WM_operatortype_append(MESH_OT_edge_face_add);
136         WM_operatortype_append(MESH_OT_shortest_path_pick);
137         WM_operatortype_append(MESH_OT_select_similar);
138         WM_operatortype_append(MESH_OT_select_similar_region);
139         WM_operatortype_append(MESH_OT_select_mode);
140         WM_operatortype_append(MESH_OT_loop_multi_select);
141         WM_operatortype_append(MESH_OT_mark_seam);
142         WM_operatortype_append(MESH_OT_mark_sharp);
143 #ifdef WITH_FREESTYLE
144         WM_operatortype_append(MESH_OT_mark_freestyle_edge);
145 #endif
146         WM_operatortype_append(MESH_OT_vertices_smooth);
147         WM_operatortype_append(MESH_OT_vertices_smooth_laplacian);
148         WM_operatortype_append(MESH_OT_flip_normals);
149         WM_operatortype_append(MESH_OT_rip);
150         WM_operatortype_append(MESH_OT_rip_edge);
151         WM_operatortype_append(MESH_OT_blend_from_shape);
152         WM_operatortype_append(MESH_OT_shape_propagate_to_all);
153
154         /* editmesh_polybuild */
155         WM_operatortype_append(MESH_OT_polybuild_face_at_cursor);
156         WM_operatortype_append(MESH_OT_polybuild_split_at_cursor);
157         WM_operatortype_append(MESH_OT_polybuild_dissolve_at_cursor);
158         WM_operatortype_append(MESH_OT_polybuild_hover);
159
160         WM_operatortype_append(MESH_OT_uv_texture_add);
161         WM_operatortype_append(MESH_OT_uv_texture_remove);
162         WM_operatortype_append(MESH_OT_vertex_color_add);
163         WM_operatortype_append(MESH_OT_vertex_color_remove);
164         WM_operatortype_append(MESH_OT_customdata_mask_clear);
165         WM_operatortype_append(MESH_OT_customdata_skin_add);
166         WM_operatortype_append(MESH_OT_customdata_skin_clear);
167         WM_operatortype_append(MESH_OT_customdata_custom_splitnormals_add);
168         WM_operatortype_append(MESH_OT_customdata_custom_splitnormals_clear);
169         WM_operatortype_append(MESH_OT_drop_named_image);
170
171         WM_operatortype_append(MESH_OT_edgering_select);
172         WM_operatortype_append(MESH_OT_loopcut);
173
174         WM_operatortype_append(MESH_OT_solidify);
175         WM_operatortype_append(MESH_OT_select_nth);
176         WM_operatortype_append(MESH_OT_vert_connect);
177         WM_operatortype_append(MESH_OT_vert_connect_path);
178         WM_operatortype_append(MESH_OT_vert_connect_concave);
179         WM_operatortype_append(MESH_OT_vert_connect_nonplanar);
180         WM_operatortype_append(MESH_OT_face_make_planar);
181         WM_operatortype_append(MESH_OT_knife_tool);
182         WM_operatortype_append(MESH_OT_knife_project);
183
184         WM_operatortype_append(MESH_OT_bevel);
185
186         WM_operatortype_append(MESH_OT_bridge_edge_loops);
187         WM_operatortype_append(MESH_OT_inset);
188         WM_operatortype_append(MESH_OT_offset_edge_loops);
189         WM_operatortype_append(MESH_OT_intersect);
190         WM_operatortype_append(MESH_OT_intersect_boolean);
191         WM_operatortype_append(MESH_OT_face_split_by_edges);
192         WM_operatortype_append(MESH_OT_poke);
193         WM_operatortype_append(MESH_OT_wireframe);
194         WM_operatortype_append(MESH_OT_edge_split);
195
196 #ifdef WITH_BULLET
197         WM_operatortype_append(MESH_OT_convex_hull);
198 #endif
199
200         WM_operatortype_append(MESH_OT_bisect);
201         WM_operatortype_append(MESH_OT_symmetrize);
202         WM_operatortype_append(MESH_OT_symmetry_snap);
203 }
204
205 #if 0 /* UNUSED, remove? */
206 static int ED_operator_editmesh_face_select(bContext *C)
207 {
208         Object *obedit = CTX_data_edit_object(C);
209         if (obedit && obedit->type == OB_MESH) {
210                 BMEditMesh *em = BKE_editmesh_from_object(obedit);
211                 if (em && em->selectmode & SCE_SELECT_FACE) {
212                         return 1;
213                 }
214         }
215         return 0;
216 }
217 #endif
218
219 void ED_operatormacros_mesh(void)
220 {
221         wmOperatorType *ot;
222         wmOperatorTypeMacro *otmacro;
223
224         ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", "Cut mesh loop and slide it",
225                                           OPTYPE_UNDO | OPTYPE_REGISTER);
226         WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
227         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
228         RNA_boolean_set(otmacro->ptr, "release_confirm", false);
229
230         ot = WM_operatortype_append_macro("MESH_OT_offset_edge_loops_slide", "Offset Edge Slide", "Offset edge loop slide",
231                                           OPTYPE_UNDO | OPTYPE_REGISTER);
232         WM_operatortype_macro_define(ot, "MESH_OT_offset_edge_loops");
233         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
234         RNA_boolean_set(otmacro->ptr, "release_confirm", false);
235         RNA_boolean_set(otmacro->ptr, "single_side", true);
236
237         ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", "Duplicate mesh and move",
238                                           OPTYPE_UNDO | OPTYPE_REGISTER);
239         WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
240         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
241         RNA_enum_set(otmacro->ptr, "proportional", 0);
242         RNA_boolean_set(otmacro->ptr, "mirror", false);
243
244         ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", "Rip polygons and move the result",
245                                           OPTYPE_UNDO | OPTYPE_REGISTER);
246         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
247         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
248         RNA_enum_set(otmacro->ptr, "proportional", 0);
249         RNA_boolean_set(otmacro->ptr, "mirror", false);
250
251         ot = WM_operatortype_append_macro("MESH_OT_rip_edge_move", "Extend Vertices", "Extend vertices and move the result",
252                                           OPTYPE_UNDO | OPTYPE_REGISTER);
253         WM_operatortype_macro_define(ot, "MESH_OT_rip_edge");
254         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
255         RNA_enum_set(otmacro->ptr, "proportional", 0);
256         RNA_boolean_set(otmacro->ptr, "mirror", false);
257
258         ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move",
259                                           "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
260         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
261         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
262         RNA_enum_set(otmacro->ptr, "proportional", 0);
263         RNA_boolean_set(otmacro->ptr, "mirror", false);
264
265         ot = WM_operatortype_append_macro("MESH_OT_extrude_context_move", "Extrude Region and Move",
266                                           "Extrude context and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
267         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_context");
268         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
269         RNA_enum_set(otmacro->ptr, "proportional", 0);
270         RNA_boolean_set(otmacro->ptr, "mirror", false);
271
272         ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten", "Extrude Region and Shrink/Fatten",
273                                           "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
274         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
275         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
276         RNA_enum_set(otmacro->ptr, "proportional", 0);
277         RNA_boolean_set(otmacro->ptr, "mirror", false);
278
279         ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move",
280                                           "Extrude faces and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
281         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");
282         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
283         RNA_enum_set(otmacro->ptr, "proportional", 0);
284         RNA_boolean_set(otmacro->ptr, "mirror", false);
285
286         ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move",
287                                           "Extrude edges and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
288         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
289         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
290         RNA_enum_set(otmacro->ptr, "proportional", 0);
291         RNA_boolean_set(otmacro->ptr, "mirror", false);
292
293         ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move",
294                                           "Extrude vertices and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
295         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv");
296         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
297         RNA_enum_set(otmacro->ptr, "proportional", 0);
298         RNA_boolean_set(otmacro->ptr, "mirror", false);
299
300
301         ot = WM_operatortype_append_macro(
302                 "MESH_OT_polybuild_face_at_cursor_move", "Face At Cursor Move", "",
303                 OPTYPE_UNDO | OPTYPE_REGISTER);
304         WM_operatortype_macro_define(ot, "MESH_OT_polybuild_face_at_cursor");
305         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
306         RNA_enum_set(otmacro->ptr, "proportional", 0);
307         RNA_boolean_set(otmacro->ptr, "mirror", false);
308
309         ot = WM_operatortype_append_macro(
310                 "MESH_OT_polybuild_split_at_cursor_move", "Split At Cursor Move", "",
311                 OPTYPE_UNDO | OPTYPE_REGISTER);
312         WM_operatortype_macro_define(ot, "MESH_OT_polybuild_split_at_cursor");
313         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
314         RNA_enum_set(otmacro->ptr, "proportional", 0);
315         RNA_boolean_set(otmacro->ptr, "mirror", false);
316 }
317
318 /* note mesh keymap also for other space? */
319 void ED_keymap_mesh(wmKeyConfig *keyconf)
320 {
321         wmKeyMap *keymap;
322         wmKeyMapItem *kmi;
323         int i;
324
325         keymap = WM_keymap_find(keyconf, "Mesh", 0, 0);
326         keymap->poll = ED_operator_editmesh;
327
328         WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0);
329         WM_keymap_add_item(keymap, "MESH_OT_offset_edge_loops_slide", RKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
330         WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0);
331         WM_keymap_add_item(keymap, "MESH_OT_poke", PKEY, KM_PRESS, KM_ALT, 0);
332         kmi = WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL, 0);
333         RNA_boolean_set(kmi->ptr, "vertex_only", false);
334         kmi = WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
335         RNA_boolean_set(kmi->ptr, "vertex_only", true);
336
337         /* selecting */
338         /* standard mouse selection goes via space_view3d */
339         kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
340         RNA_boolean_set(kmi->ptr, "extend", false);
341         RNA_boolean_set(kmi->ptr, "deselect", false);
342         RNA_boolean_set(kmi->ptr, "toggle", false);
343         kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0);
344         RNA_boolean_set(kmi->ptr, "extend", false);
345         RNA_boolean_set(kmi->ptr, "deselect", false);
346         RNA_boolean_set(kmi->ptr, "toggle", true);
347
348         kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0);
349         RNA_boolean_set(kmi->ptr, "extend", false);
350         RNA_boolean_set(kmi->ptr, "deselect", false);
351         RNA_boolean_set(kmi->ptr, "toggle", false);
352         kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT | KM_CTRL, 0);
353         RNA_boolean_set(kmi->ptr, "extend", false);
354         RNA_boolean_set(kmi->ptr, "deselect", false);
355         RNA_boolean_set(kmi->ptr, "toggle", true);
356
357         kmi = WM_keymap_add_item(keymap, "MESH_OT_shortest_path_pick", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
358         RNA_boolean_set(kmi->ptr, "use_fill", false);
359
360         kmi = WM_keymap_add_item(keymap, "MESH_OT_shortest_path_pick", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
361         RNA_boolean_set(kmi->ptr, "use_fill", true);
362
363         kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", AKEY, KM_PRESS, 0, 0);
364         RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
365         kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
366         RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
367
368         WM_keymap_add_item(keymap, "MESH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
369         WM_keymap_add_item(keymap, "MESH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
370
371         WM_keymap_add_item(keymap, "MESH_OT_select_next_item", PADPLUSKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
372         WM_keymap_add_item(keymap, "MESH_OT_select_prev_item", PADMINUS, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
373
374         WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
375
376         WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
377         kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
378         RNA_boolean_set(kmi->ptr, "deselect", false);
379         kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0);
380         RNA_boolean_set(kmi->ptr, "deselect", true);
381
382         WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
383
384         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
385
386         /* hide */
387         kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0);
388         RNA_boolean_set(kmi->ptr, "unselected", false);
389         kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
390         RNA_boolean_set(kmi->ptr, "unselected", true);
391         WM_keymap_add_item(keymap, "MESH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
392
393         /* tools */
394         kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0);
395         RNA_boolean_set(kmi->ptr, "inside", false);
396         kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
397         RNA_boolean_set(kmi->ptr, "inside", true);
398
399         WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */
400         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, KM_ALT, 0);
401
402         WM_keymap_add_item(keymap, "TRANSFORM_OT_edge_crease", EKEY, KM_PRESS, KM_SHIFT, 0);
403
404         WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0);
405
406         WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0);
407         WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
408
409         kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0);
410         RNA_enum_set(kmi->ptr, "quad_method", MOD_TRIANGULATE_QUAD_BEAUTY);
411         RNA_enum_set(kmi->ptr, "ngon_method", MOD_TRIANGULATE_NGON_BEAUTY);
412         kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
413         RNA_enum_set(kmi->ptr, "quad_method", MOD_TRIANGULATE_QUAD_FIXED);
414         RNA_enum_set(kmi->ptr, "ngon_method", MOD_TRIANGULATE_NGON_EARCLIP);
415
416         WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0);
417
418         kmi = WM_keymap_add_item(keymap, "MESH_OT_rip_move", VKEY, KM_PRESS, 0, 0);
419         {
420                 PointerRNA macro_ptr = RNA_pointer_get(kmi->ptr, "MESH_OT_rip");
421                 RNA_boolean_set(&macro_ptr, "use_fill", false);
422         }
423         kmi = WM_keymap_add_item(keymap, "MESH_OT_rip_move", VKEY, KM_PRESS, KM_ALT, 0);
424         {
425                 PointerRNA macro_ptr = RNA_pointer_get(kmi->ptr, "MESH_OT_rip");
426                 RNA_boolean_set(&macro_ptr, "use_fill", true);
427         }
428
429         WM_keymap_add_item(keymap, "MESH_OT_rip_edge_move", DKEY, KM_PRESS, KM_ALT, 0);
430
431         WM_keymap_add_item(keymap, "MESH_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
432
433         WM_keymap_add_item(keymap, "TRANSFORM_OT_shrink_fatten", SKEY, KM_PRESS, KM_ALT, 0);
434
435         /* add/remove */
436         WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0);
437 //      WM_keymap_add_item(keymap, "MESH_OT_skin", FKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); /* python, removed */
438         WM_keymap_add_item(keymap, "MESH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
439
440         WM_keymap_add_menu(keymap, "INFO_MT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0);
441
442         WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, 0, 0);
443         WM_keymap_add_item(keymap, "MESH_OT_split", YKEY, KM_PRESS, 0, 0);
444         WM_keymap_add_item(keymap, "MESH_OT_vert_connect_path", JKEY, KM_PRESS, 0, 0);
445
446         /* Vertex Slide */
447         WM_keymap_add_item(keymap, "TRANSFORM_OT_vert_slide", VKEY, KM_PRESS, KM_SHIFT, 0);
448         /* use KM_CLICK because same key is used for tweaks */
449         kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0);
450         RNA_boolean_set(kmi->ptr, "rotate_source", true);
451         kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_SHIFT | KM_CTRL, 0);
452         RNA_boolean_set(kmi->ptr, "rotate_source", false);
453
454         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", XKEY, KM_PRESS, 0, 0);
455         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", DELKEY, KM_PRESS, 0, 0);
456
457         WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", XKEY, KM_PRESS, KM_CTRL, 0);
458         WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", DELKEY, KM_PRESS, KM_CTRL, 0);
459
460         kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0);
461         RNA_boolean_set(kmi->ptr, "use_occlude_geometry", true);
462         RNA_boolean_set(kmi->ptr, "only_selected",          false);
463
464         kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0);
465         RNA_boolean_set(kmi->ptr, "use_occlude_geometry", false);
466         RNA_boolean_set(kmi->ptr, "only_selected",          true);
467
468         WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
469
470         /* menus */
471         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_specials", WKEY, KM_PRESS, 0, 0);
472         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_faces", FKEY, KM_PRESS, KM_CTRL, 0);
473         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_edges", EKEY, KM_PRESS, KM_CTRL, 0);
474         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_vertices", VKEY, KM_PRESS, KM_CTRL, 0);
475         WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
476         WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0);
477         WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0);
478
479         /* useful stuff from object-mode */
480         for (i = 0; i <= 5; i++) {
481                 kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0);
482                 RNA_int_set(kmi->ptr, "level", i);
483         }
484
485         ED_keymap_proportional_cycle(keyconf, keymap);
486         ED_keymap_proportional_editmode(keyconf, keymap, true);
487
488         knifetool_modal_keymap(keyconf);
489 }
490