Merge branch 'blender2.8' into soc-2018-bevel
[blender.git] / source / blender / editors / mesh / mesh_ops.c
index 60200313b8c1d27a4e6967dac05275836b38f42b..546c000d726fb87556050391112e46d6363dce0a 100644 (file)
@@ -4,7 +4,7 @@
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. 
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
  * The Original Code is Copyright (C) 2009 Blender Foundation.
  * All rights reserved.
  *
- * 
+ *
  * Contributor(s): Blender Foundation
  *
  * ***** END GPL LICENSE BLOCK *****
@@ -98,12 +98,12 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_loop_to_region);
        WM_operatortype_append(MESH_OT_region_to_loop);
        WM_operatortype_append(MESH_OT_select_axis);
-       
+
        WM_operatortype_append(MESH_OT_uvs_rotate);
        WM_operatortype_append(MESH_OT_uvs_reverse);
        WM_operatortype_append(MESH_OT_colors_rotate);
        WM_operatortype_append(MESH_OT_colors_reverse);
-       
+
        WM_operatortype_append(MESH_OT_fill);
        WM_operatortype_append(MESH_OT_fill_grid);
        WM_operatortype_append(MESH_OT_fill_holes);
@@ -229,7 +229,7 @@ void ED_operatormacros_mesh(void)
 {
        wmOperatorType *ot;
        wmOperatorTypeMacro *otmacro;
-       
+
        ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", "Cut mesh loop and slide it",
                                          OPTYPE_UNDO | OPTYPE_REGISTER);
        WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
@@ -326,14 +326,14 @@ void ED_operatormacros_mesh(void)
 
 /* note mesh keymap also for other space? */
 void ED_keymap_mesh(wmKeyConfig *keyconf)
-{      
+{
        wmKeyMap *keymap;
        wmKeyMapItem *kmi;
        int i;
-       
+
        keymap = WM_keymap_find(keyconf, "Mesh", 0, 0);
        keymap->poll = ED_operator_editmesh;
-       
+
        WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "MESH_OT_offset_edge_loops_slide", RKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0);
@@ -344,6 +344,24 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
        RNA_boolean_set(kmi->ptr, "vertex_only", true);
 
        /* selecting */
+
+       kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, 0, 0);
+       RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX);
+       kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, 0, 0);
+       RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE);
+       kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, 0, 0);
+       RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE);
+
+       kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX);
+       RNA_boolean_set(kmi->ptr, "use_extend", true);
+       kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE);
+       RNA_boolean_set(kmi->ptr, "use_extend", true);
+       kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE);
+       RNA_boolean_set(kmi->ptr, "use_extend", true);
+
        /* standard mouse selection goes via space_view3d */
        kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
        RNA_boolean_set(kmi->ptr, "extend", false);
@@ -381,20 +399,17 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "MESH_OT_select_prev_item", PADMINUS, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
 
        WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
-       
+
        WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
        kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
        RNA_boolean_set(kmi->ptr, "deselect", false);
        kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0);
        RNA_boolean_set(kmi->ptr, "deselect", true);
-       
+
        WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
 
        WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
-       
-       /* selection mode */
-       WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0);
-       
+
        /* hide */
        kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0);
        RNA_boolean_set(kmi->ptr, "unselected", false);
@@ -407,14 +422,14 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
        RNA_boolean_set(kmi->ptr, "inside", false);
        kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
        RNA_boolean_set(kmi->ptr, "inside", true);
-       
+
        WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */
        WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, KM_ALT, 0);
-       
+
        WM_keymap_add_item(keymap, "TRANSFORM_OT_edge_crease", EKEY, KM_PRESS, KM_SHIFT, 0);
-       
+
        WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0);
-       
+
        WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0);
        WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
 
@@ -448,9 +463,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0);
 //     WM_keymap_add_item(keymap, "MESH_OT_skin", FKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); /* python, removed */
        WM_keymap_add_item(keymap, "MESH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
-       
+
        WM_keymap_add_menu(keymap, "INFO_MT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-       
+
        WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MESH_OT_split", YKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MESH_OT_vert_connect_path", JKEY, KM_PRESS, 0, 0);
@@ -470,7 +485,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", XKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", DELKEY, KM_PRESS, KM_CTRL, 0);
-       
+
        kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0);
        RNA_boolean_set(kmi->ptr, "use_occlude_geometry", true);
        RNA_boolean_set(kmi->ptr, "only_selected",          false);
@@ -478,7 +493,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
        kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0);
        RNA_boolean_set(kmi->ptr, "use_occlude_geometry", false);
        RNA_boolean_set(kmi->ptr, "only_selected",          true);
-       
+
        WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
 
        /* menus */
@@ -489,13 +504,13 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
        WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0);
        WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0);
-       
+
        /* useful stuff from object-mode */
        for (i = 0; i <= 5; i++) {
                kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0);
                RNA_int_set(kmi->ptr, "level", i);
        }
-       
+
        ED_keymap_proportional_cycle(keyconf, keymap);
        ED_keymap_proportional_editmode(keyconf, keymap, true);