Slightly generalized the crash fix in revision 54111.
[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
32
33
34
35 #include "BLI_math.h"
36
37
38 #include "RNA_access.h"
39
40 #include "WM_api.h"
41 #include "WM_types.h"
42
43 #include "ED_object.h"
44 #include "ED_mesh.h"
45 #include "ED_screen.h"
46
47
48 #include "mesh_intern.h"
49
50 /**************************** registration **********************************/
51
52 void ED_operatortypes_mesh(void)
53 {
54         WM_operatortype_append(MESH_OT_select_all);
55         WM_operatortype_append(MESH_OT_select_interior_faces);
56         WM_operatortype_append(MESH_OT_select_more);
57         WM_operatortype_append(MESH_OT_select_less);
58         WM_operatortype_append(MESH_OT_select_non_manifold);
59         WM_operatortype_append(MESH_OT_select_linked);
60         WM_operatortype_append(MESH_OT_select_linked_pick);
61         WM_operatortype_append(MESH_OT_select_random);
62         WM_operatortype_append(MESH_OT_hide);
63         WM_operatortype_append(MESH_OT_reveal);
64         WM_operatortype_append(MESH_OT_select_face_by_sides);
65         WM_operatortype_append(MESH_OT_select_loose_verts);
66         WM_operatortype_append(MESH_OT_select_mirror);
67         WM_operatortype_append(MESH_OT_normals_make_consistent);
68         WM_operatortype_append(MESH_OT_merge);
69         WM_operatortype_append(MESH_OT_subdivide);
70         WM_operatortype_append(MESH_OT_unsubdivide);
71         WM_operatortype_append(MESH_OT_faces_select_linked_flat);
72         WM_operatortype_append(MESH_OT_edges_select_sharp);
73         WM_operatortype_append(MESH_OT_primitive_plane_add);
74         WM_operatortype_append(MESH_OT_primitive_cube_add);
75         WM_operatortype_append(MESH_OT_primitive_circle_add);
76         WM_operatortype_append(MESH_OT_primitive_cylinder_add);
77         WM_operatortype_append(MESH_OT_primitive_cone_add);
78         WM_operatortype_append(MESH_OT_primitive_grid_add);
79         WM_operatortype_append(MESH_OT_primitive_monkey_add);
80         WM_operatortype_append(MESH_OT_primitive_uv_sphere_add);
81         WM_operatortype_append(MESH_OT_primitive_ico_sphere_add);
82         WM_operatortype_append(MESH_OT_duplicate);
83         WM_operatortype_append(MESH_OT_remove_doubles);
84         WM_operatortype_append(MESH_OT_spin);
85         WM_operatortype_append(MESH_OT_screw);
86
87         WM_operatortype_append(MESH_OT_extrude_region);
88         WM_operatortype_append(MESH_OT_extrude_faces_indiv);
89         WM_operatortype_append(MESH_OT_extrude_edges_indiv);
90         WM_operatortype_append(MESH_OT_extrude_verts_indiv);
91
92         WM_operatortype_append(MESH_OT_split);
93         WM_operatortype_append(MESH_OT_extrude_repeat);
94         WM_operatortype_append(MESH_OT_edge_rotate);
95         WM_operatortype_append(MESH_OT_select_vertex_path);
96         WM_operatortype_append(MESH_OT_loop_to_region);
97         WM_operatortype_append(MESH_OT_region_to_loop);
98         WM_operatortype_append(MESH_OT_select_axis);
99         
100         WM_operatortype_append(MESH_OT_uvs_rotate);
101         WM_operatortype_append(MESH_OT_uvs_reverse);
102         WM_operatortype_append(MESH_OT_colors_rotate);
103         WM_operatortype_append(MESH_OT_colors_reverse);
104         
105         WM_operatortype_append(MESH_OT_fill);
106         WM_operatortype_append(MESH_OT_beautify_fill);
107         WM_operatortype_append(MESH_OT_quads_convert_to_tris);
108         WM_operatortype_append(MESH_OT_tris_convert_to_quads);
109         WM_operatortype_append(MESH_OT_dissolve);
110         WM_operatortype_append(MESH_OT_dissolve_limited);
111         WM_operatortype_append(MESH_OT_faces_shade_smooth);
112         WM_operatortype_append(MESH_OT_faces_shade_flat);
113         WM_operatortype_append(MESH_OT_sort_elements);
114 #ifdef WITH_FREESTYLE
115         WM_operatortype_append(MESH_OT_mark_freestyle_face);
116 #endif
117
118         WM_operatortype_append(MESH_OT_delete);
119         WM_operatortype_append(MESH_OT_edge_collapse);
120         WM_operatortype_append(MESH_OT_edge_collapse_loop);
121
122         WM_operatortype_append(MESH_OT_separate);
123         WM_operatortype_append(MESH_OT_dupli_extrude_cursor);
124         WM_operatortype_append(MESH_OT_loop_select);
125         WM_operatortype_append(MESH_OT_edge_face_add);
126         WM_operatortype_append(MESH_OT_select_shortest_path);
127         WM_operatortype_append(MESH_OT_select_similar);
128         WM_operatortype_append(MESH_OT_select_mode);
129         WM_operatortype_append(MESH_OT_loop_multi_select);
130         WM_operatortype_append(MESH_OT_mark_seam);
131         WM_operatortype_append(MESH_OT_mark_sharp);
132 #ifdef WITH_FREESTYLE
133         WM_operatortype_append(MESH_OT_mark_freestyle_edge);
134 #endif
135         WM_operatortype_append(MESH_OT_vertices_smooth);
136         WM_operatortype_append(MESH_OT_vertices_smooth_laplacian);
137         WM_operatortype_append(MESH_OT_noise);
138         WM_operatortype_append(MESH_OT_flip_normals);
139         WM_operatortype_append(MESH_OT_rip);
140         WM_operatortype_append(MESH_OT_blend_from_shape);
141         WM_operatortype_append(MESH_OT_shape_propagate_to_all);
142         
143         WM_operatortype_append(MESH_OT_uv_texture_add);
144         WM_operatortype_append(MESH_OT_uv_texture_remove);
145         WM_operatortype_append(MESH_OT_vertex_color_add);
146         WM_operatortype_append(MESH_OT_vertex_color_remove);
147         WM_operatortype_append(MESH_OT_customdata_clear_mask);
148         WM_operatortype_append(MESH_OT_customdata_clear_skin);
149         WM_operatortype_append(MESH_OT_drop_named_image);
150
151         WM_operatortype_append(MESH_OT_edgering_select);
152         WM_operatortype_append(MESH_OT_loopcut);
153
154         WM_operatortype_append(MESH_OT_solidify);
155         WM_operatortype_append(MESH_OT_select_nth);
156         WM_operatortype_append(MESH_OT_vert_connect);
157         WM_operatortype_append(MESH_OT_vert_slide);
158         WM_operatortype_append(MESH_OT_knife_tool);
159
160         WM_operatortype_append(MESH_OT_bevel);
161
162         WM_operatortype_append(MESH_OT_select_next_loop);
163
164         WM_operatortype_append(MESH_OT_bridge_edge_loops);
165         WM_operatortype_append(MESH_OT_inset);
166         WM_operatortype_append(MESH_OT_wireframe);
167         WM_operatortype_append(MESH_OT_edge_split);
168
169 #ifdef WITH_BULLET
170         WM_operatortype_append(MESH_OT_convex_hull);
171 #endif
172
173         WM_operatortype_append(MESH_OT_symmetrize);
174
175 #ifdef WITH_GAMEENGINE
176         WM_operatortype_append(MESH_OT_navmesh_make);
177         WM_operatortype_append(MESH_OT_navmesh_face_copy);
178         WM_operatortype_append(MESH_OT_navmesh_face_add);
179         WM_operatortype_append(MESH_OT_navmesh_reset);
180         WM_operatortype_append(MESH_OT_navmesh_clear);
181 #endif
182 }
183
184 #if 0 /* UNUSED, remove? */
185 static int ED_operator_editmesh_face_select(bContext *C)
186 {
187         Object *obedit = CTX_data_edit_object(C);
188         if (obedit && obedit->type == OB_MESH) {
189                 BMEditMesh *em = BMEdit_FromObject(obedit);
190                 if (em && em->selectmode & SCE_SELECT_FACE) {
191                         return 1;
192                 }
193         }
194         return 0;
195 }
196 #endif
197
198 void ED_operatormacros_mesh(void)
199 {
200         wmOperatorType *ot;
201         wmOperatorTypeMacro *otmacro;
202         
203         ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", "Cut mesh loop and slide it",
204                                           OPTYPE_UNDO | OPTYPE_REGISTER);
205         WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
206         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
207         RNA_struct_idprops_unset(otmacro->ptr, "release_confirm");
208
209         ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", "Duplicate mesh and move",
210                                           OPTYPE_UNDO | OPTYPE_REGISTER);
211         WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
212         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
213         RNA_enum_set(otmacro->ptr, "proportional", 0);
214         RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
215
216         ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", "Rip polygons and move the result",
217                                           OPTYPE_UNDO | OPTYPE_REGISTER);
218         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
219         RNA_boolean_set(otmacro->ptr, "use_fill", FALSE);
220         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
221         RNA_enum_set(otmacro->ptr, "proportional", 0);
222         RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
223
224         /* annoying we can't pass 'use_fill' through the macro */
225         ot = WM_operatortype_append_macro("MESH_OT_rip_move_fill", "Rip Fill", "Rip-fill polygons and move the result",
226                                           OPTYPE_UNDO | OPTYPE_REGISTER);
227         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
228         RNA_boolean_set(otmacro->ptr, "use_fill", TRUE);
229         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
230         RNA_enum_set(otmacro->ptr, "proportional", 0);
231         RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
232
233         ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move",
234                                           "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
235         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
236         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
237         RNA_enum_set(otmacro->ptr, "proportional", 0);
238         RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
239
240         ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move",
241                                           "Extrude faces and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
242         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");
243         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
244         RNA_enum_set(otmacro->ptr, "proportional", 0);
245         RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
246
247         ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move",
248                                           "Extrude edges and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
249         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
250         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
251         RNA_enum_set(otmacro->ptr, "proportional", 0);
252         RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
253
254         ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move",
255                                           "Extrude vertices and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
256         otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv");
257         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
258         RNA_enum_set(otmacro->ptr, "proportional", 0);
259         RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
260 }
261
262 /* note mesh keymap also for other space? */
263 void ED_keymap_mesh(wmKeyConfig *keyconf)
264 {       
265         wmKeyMap *keymap;
266         wmKeyMapItem *kmi;
267         int i;
268         
269         keymap = WM_keymap_find(keyconf, "Mesh", 0, 0);
270         keymap->poll = ED_operator_editmesh;
271         
272         WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0);
273         WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL, 0);
274         WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0);
275
276         /* selecting */
277         /* standard mouse selection goes via space_view3d */
278         kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
279         RNA_boolean_set(kmi->ptr, "extend", FALSE);
280         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
281         RNA_boolean_set(kmi->ptr, "toggle", FALSE);
282         kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0);
283         RNA_boolean_set(kmi->ptr, "extend", FALSE);
284         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
285         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
286
287         kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0);
288         RNA_boolean_set(kmi->ptr, "extend", FALSE);
289         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
290         RNA_boolean_set(kmi->ptr, "toggle", FALSE);
291         kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT | KM_CTRL, 0);
292         RNA_boolean_set(kmi->ptr, "extend", FALSE);
293         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
294         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
295
296         WM_keymap_add_item(keymap, "MESH_OT_select_shortest_path", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
297
298         kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", AKEY, KM_PRESS, 0, 0);
299         RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
300         kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
301         RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
302
303         WM_keymap_add_item(keymap, "MESH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
304         WM_keymap_add_item(keymap, "MESH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
305         WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
306         
307         WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
308         kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
309         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
310         kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0);
311         RNA_boolean_set(kmi->ptr, "deselect", TRUE);
312         
313         WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
314
315         WM_keymap_add_item(keymap, "MESH_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
316         
317         /* selection mode */
318         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0);
319         
320         /* hide */
321         kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0);
322         RNA_boolean_set(kmi->ptr, "unselected", FALSE);
323         kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
324         RNA_boolean_set(kmi->ptr, "unselected", TRUE);
325         WM_keymap_add_item(keymap, "MESH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
326
327         /* tools */
328         kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0);
329         RNA_boolean_set(kmi->ptr, "inside", FALSE);
330         kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
331         RNA_boolean_set(kmi->ptr, "inside", TRUE);
332         
333         WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */
334         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, KM_ALT, 0);
335         
336         WM_keymap_add_item(keymap, "TRANSFORM_OT_edge_crease", EKEY, KM_PRESS, KM_SHIFT, 0);
337         
338         WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0);
339         
340         WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0);
341         WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
342
343         kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0);
344         RNA_boolean_set(kmi->ptr, "use_beauty", TRUE);
345         kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
346         RNA_boolean_set(kmi->ptr, "use_beauty", FALSE);
347
348         WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0);
349
350         WM_keymap_add_item(keymap, "MESH_OT_rip_move", VKEY, KM_PRESS, 0, 0);
351         WM_keymap_add_item(keymap, "MESH_OT_rip_move_fill", VKEY, KM_PRESS, KM_ALT, 0);
352
353         WM_keymap_add_item(keymap, "MESH_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
354
355         WM_keymap_add_item(keymap, "TRANSFORM_OT_shrink_fatten", SKEY, KM_PRESS, KM_ALT, 0);
356
357         /* add/remove */
358         WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0);
359 //      WM_keymap_add_item(keymap, "MESH_OT_skin", FKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); /* python, removed */
360         WM_keymap_add_item(keymap, "MESH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
361         
362         WM_keymap_add_menu(keymap, "INFO_MT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0);
363         
364         WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, 0, 0);
365         WM_keymap_add_item(keymap, "MESH_OT_split", YKEY, KM_PRESS, 0, 0);
366         WM_keymap_add_item(keymap, "MESH_OT_vert_connect", JKEY, KM_PRESS, 0, 0);
367
368         /* Vertex Slide */
369         WM_keymap_add_item(keymap, "MESH_OT_vert_slide", VKEY, KM_PRESS, KM_SHIFT, 0);
370         /* use KM_CLICK because same key is used for tweaks */
371         kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0);
372         RNA_boolean_set(kmi->ptr, "rotate_source", TRUE);
373         kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_SHIFT | KM_CTRL, 0);
374         RNA_boolean_set(kmi->ptr, "rotate_source", FALSE);
375
376         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", XKEY, KM_PRESS, 0, 0);
377         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", DELKEY, KM_PRESS, 0, 0);
378         
379         kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0);
380         RNA_boolean_set(kmi->ptr, "use_occlude_geometry", TRUE);
381         RNA_boolean_set(kmi->ptr, "only_selected",          FALSE);
382
383         kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0);
384         RNA_boolean_set(kmi->ptr, "use_occlude_geometry", FALSE);
385         RNA_boolean_set(kmi->ptr, "only_selected",          TRUE);
386         
387         WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
388
389         /* menus */
390         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_specials", WKEY, KM_PRESS, 0, 0);
391         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_faces", FKEY, KM_PRESS, KM_CTRL, 0);
392         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_edges", EKEY, KM_PRESS, KM_CTRL, 0);
393         WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_vertices", VKEY, KM_PRESS, KM_CTRL, 0);
394         WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
395         WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0);
396         WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0);
397         
398         /* useful stuff from object-mode */
399         for (i = 0; i <= 5; i++) {
400                 kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0);
401                 RNA_int_set(kmi->ptr, "level", i);
402         }
403         
404         ED_keymap_proportional_cycle(keyconf, keymap);
405         ED_keymap_proportional_editmode(keyconf, keymap, TRUE);
406
407         knifetool_modal_keymap(keyconf);
408 }
409