Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2009 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * 00022 * Contributor(s): Blender Foundation 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #include <stdlib.h> 00033 #include <math.h> 00034 00035 00036 #include "DNA_object_types.h" 00037 #include "DNA_scene_types.h" 00038 00039 #include "BLI_math.h" 00040 #include "BLI_blenlib.h" 00041 #include "BLI_editVert.h" 00042 00043 #include "BKE_context.h" 00044 00045 #include "RNA_access.h" 00046 00047 #include "WM_api.h" 00048 #include "WM_types.h" 00049 00050 #include "ED_object.h" 00051 #include "ED_mesh.h" 00052 #include "ED_screen.h" 00053 #include "ED_view3d.h" 00054 00055 00056 #include "mesh_intern.h" 00057 00058 /**************************** registration **********************************/ 00059 00060 void ED_operatortypes_mesh(void) 00061 { 00062 WM_operatortype_append(MESH_OT_select_all); 00063 WM_operatortype_append(MESH_OT_select_more); 00064 WM_operatortype_append(MESH_OT_select_less); 00065 WM_operatortype_append(MESH_OT_select_non_manifold); 00066 WM_operatortype_append(MESH_OT_select_linked); 00067 WM_operatortype_append(MESH_OT_select_linked_pick); 00068 WM_operatortype_append(MESH_OT_select_random); 00069 WM_operatortype_append(MESH_OT_hide); 00070 WM_operatortype_append(MESH_OT_reveal); 00071 WM_operatortype_append(MESH_OT_select_by_number_vertices); 00072 WM_operatortype_append(MESH_OT_select_mirror); 00073 WM_operatortype_append(MESH_OT_normals_make_consistent); 00074 WM_operatortype_append(MESH_OT_merge); 00075 WM_operatortype_append(MESH_OT_subdivide); 00076 WM_operatortype_append(MESH_OT_faces_select_linked_flat); 00077 WM_operatortype_append(MESH_OT_edges_select_sharp); 00078 WM_operatortype_append(MESH_OT_primitive_plane_add); 00079 WM_operatortype_append(MESH_OT_primitive_cube_add); 00080 WM_operatortype_append(MESH_OT_primitive_circle_add); 00081 WM_operatortype_append(MESH_OT_primitive_cylinder_add); 00082 WM_operatortype_append(MESH_OT_primitive_cone_add); 00083 WM_operatortype_append(MESH_OT_primitive_grid_add); 00084 WM_operatortype_append(MESH_OT_primitive_monkey_add); 00085 WM_operatortype_append(MESH_OT_primitive_uv_sphere_add); 00086 WM_operatortype_append(MESH_OT_primitive_ico_sphere_add); 00087 WM_operatortype_append(MESH_OT_fgon_clear); 00088 WM_operatortype_append(MESH_OT_fgon_make); 00089 WM_operatortype_append(MESH_OT_duplicate); 00090 WM_operatortype_append(MESH_OT_remove_doubles); 00091 WM_operatortype_append(MESH_OT_vertices_sort); 00092 WM_operatortype_append(MESH_OT_vertices_randomize); 00093 WM_operatortype_append(MESH_OT_extrude); 00094 WM_operatortype_append(MESH_OT_spin); 00095 WM_operatortype_append(MESH_OT_screw); 00096 00097 WM_operatortype_append(MESH_OT_split); 00098 WM_operatortype_append(MESH_OT_extrude_repeat); 00099 WM_operatortype_append(MESH_OT_edge_rotate); 00100 WM_operatortype_append(MESH_OT_select_vertex_path); 00101 WM_operatortype_append(MESH_OT_loop_to_region); 00102 WM_operatortype_append(MESH_OT_region_to_loop); 00103 WM_operatortype_append(MESH_OT_select_axis); 00104 00105 WM_operatortype_append(MESH_OT_uvs_rotate); 00106 WM_operatortype_append(MESH_OT_uvs_mirror); 00107 WM_operatortype_append(MESH_OT_colors_rotate); 00108 WM_operatortype_append(MESH_OT_colors_mirror); 00109 00110 WM_operatortype_append(MESH_OT_fill); 00111 WM_operatortype_append(MESH_OT_beautify_fill); 00112 WM_operatortype_append(MESH_OT_quads_convert_to_tris); 00113 WM_operatortype_append(MESH_OT_tris_convert_to_quads); 00114 WM_operatortype_append(MESH_OT_edge_flip); 00115 WM_operatortype_append(MESH_OT_faces_shade_smooth); 00116 WM_operatortype_append(MESH_OT_faces_shade_flat); 00117 WM_operatortype_append(MESH_OT_sort_faces); 00118 00119 WM_operatortype_append(MESH_OT_delete); 00120 00121 WM_operatortype_append(MESH_OT_separate); 00122 WM_operatortype_append(MESH_OT_dupli_extrude_cursor); 00123 WM_operatortype_append(MESH_OT_loop_select); 00124 WM_operatortype_append(MESH_OT_edge_face_add); 00125 WM_operatortype_append(MESH_OT_select_shortest_path); 00126 WM_operatortype_append(MESH_OT_select_similar); 00127 WM_operatortype_append(MESH_OT_loop_multi_select); 00128 WM_operatortype_append(MESH_OT_mark_seam); 00129 WM_operatortype_append(MESH_OT_mark_sharp); 00130 WM_operatortype_append(MESH_OT_vertices_smooth); 00131 WM_operatortype_append(MESH_OT_noise); 00132 WM_operatortype_append(MESH_OT_flip_normals); 00133 WM_operatortype_append(MESH_OT_knife_cut); 00134 WM_operatortype_append(MESH_OT_rip); 00135 WM_operatortype_append(MESH_OT_blend_from_shape); 00136 WM_operatortype_append(MESH_OT_shape_propagate_to_all); 00137 00138 WM_operatortype_append(MESH_OT_uv_texture_add); 00139 WM_operatortype_append(MESH_OT_uv_texture_remove); 00140 WM_operatortype_append(MESH_OT_vertex_color_add); 00141 WM_operatortype_append(MESH_OT_vertex_color_remove); 00142 WM_operatortype_append(MESH_OT_sticky_add); 00143 WM_operatortype_append(MESH_OT_sticky_remove); 00144 WM_operatortype_append(MESH_OT_drop_named_image); 00145 00146 WM_operatortype_append(MESH_OT_edgering_select); 00147 WM_operatortype_append(MESH_OT_loopcut); 00148 00149 WM_operatortype_append(MESH_OT_solidify); 00150 WM_operatortype_append(MESH_OT_select_nth); 00151 00152 #ifdef WITH_GAMEENGINE 00153 WM_operatortype_append(MESH_OT_navmesh_make); 00154 WM_operatortype_append(MESH_OT_navmesh_face_copy); 00155 WM_operatortype_append(MESH_OT_navmesh_face_add); 00156 WM_operatortype_append(MESH_OT_navmesh_reset); 00157 WM_operatortype_append(MESH_OT_navmesh_clear); 00158 #endif 00159 } 00160 00161 #if 0 /* UNUSED, remove? */ 00162 static int ED_operator_editmesh_face_select(bContext *C) 00163 { 00164 Object *obedit= CTX_data_edit_object(C); 00165 if(obedit && obedit->type==OB_MESH) { 00166 EditMesh *em = ((Mesh *)obedit->data)->edit_mesh; 00167 if (em && em->selectmode & SCE_SELECT_FACE) { 00168 return 1; 00169 } 00170 } 00171 return 0; 00172 } 00173 #endif 00174 00175 void ED_operatormacros_mesh(void) 00176 { 00177 wmOperatorType *ot; 00178 wmOperatorTypeMacro *otmacro; 00179 00180 ot= WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", OPTYPE_UNDO|OPTYPE_REGISTER); 00181 ot->description = "Cut mesh loop and slide it"; 00182 WM_operatortype_macro_define(ot, "MESH_OT_loopcut"); 00183 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide"); 00184 RNA_struct_idprops_unset(otmacro->ptr, "release_confirm"); 00185 00186 ot= WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); 00187 ot->description = "Duplicate mesh and move"; 00188 WM_operatortype_macro_define(ot, "MESH_OT_duplicate"); 00189 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); 00190 RNA_enum_set(otmacro->ptr, "proportional", 0); 00191 RNA_boolean_set(otmacro->ptr, "mirror", FALSE); 00192 00193 ot= WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", OPTYPE_UNDO|OPTYPE_REGISTER); 00194 ot->description = "Rip polygons and move the result"; 00195 WM_operatortype_macro_define(ot, "MESH_OT_rip"); 00196 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); 00197 RNA_enum_set(otmacro->ptr, "proportional", 0); 00198 RNA_boolean_set(otmacro->ptr, "mirror", FALSE); 00199 00200 ot= WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", OPTYPE_UNDO|OPTYPE_REGISTER); 00201 ot->description = "Extrude region and move result"; 00202 otmacro= WM_operatortype_macro_define(ot, "MESH_OT_extrude"); 00203 RNA_enum_set(otmacro->ptr, "type", 1); 00204 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); 00205 RNA_enum_set(otmacro->ptr, "proportional", 0); 00206 RNA_boolean_set(otmacro->ptr, "mirror", FALSE); 00207 00208 ot= WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", OPTYPE_UNDO|OPTYPE_REGISTER); 00209 ot->description = "Extrude faces and move result"; 00210 otmacro= WM_operatortype_macro_define(ot, "MESH_OT_extrude"); 00211 RNA_enum_set(otmacro->ptr, "type", 2); 00212 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten"); 00213 RNA_enum_set(otmacro->ptr, "proportional", 0); 00214 RNA_boolean_set(otmacro->ptr, "mirror", FALSE); 00215 00216 ot= WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", OPTYPE_UNDO|OPTYPE_REGISTER); 00217 ot->description = "Extrude edges and move result"; 00218 otmacro= WM_operatortype_macro_define(ot, "MESH_OT_extrude"); 00219 RNA_enum_set(otmacro->ptr, "type", 3); 00220 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); 00221 RNA_enum_set(otmacro->ptr, "proportional", 0); 00222 RNA_boolean_set(otmacro->ptr, "mirror", FALSE); 00223 00224 ot= WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", OPTYPE_UNDO|OPTYPE_REGISTER); 00225 ot->description = "Extrude vertices and move result"; 00226 otmacro= WM_operatortype_macro_define(ot, "MESH_OT_extrude"); 00227 RNA_enum_set(otmacro->ptr, "type", 4); 00228 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); 00229 RNA_enum_set(otmacro->ptr, "proportional", 0); 00230 RNA_boolean_set(otmacro->ptr, "mirror", FALSE); 00231 } 00232 00233 /* note mesh keymap also for other space? */ 00234 void ED_keymap_mesh(wmKeyConfig *keyconf) 00235 { 00236 wmKeyMap *keymap; 00237 wmKeyMapItem *kmi; 00238 int i; 00239 00240 keymap= WM_keymap_find(keyconf, "Mesh", 0, 0); 00241 keymap->poll= ED_operator_editmesh; 00242 00243 WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0); 00244 00245 /* selecting */ 00246 /* standard mouse selection goes via space_view3d */ 00247 kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); 00248 RNA_boolean_set(kmi->ptr, "extend", FALSE); 00249 kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0); 00250 RNA_boolean_set(kmi->ptr, "extend", TRUE); 00251 00252 kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_ALT|KM_CTRL, 0); 00253 RNA_boolean_set(kmi->ptr, "extend", FALSE); 00254 kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT|KM_CTRL, 0); 00255 RNA_boolean_set(kmi->ptr, "extend", TRUE); 00256 00257 WM_keymap_add_item(keymap, "MESH_OT_select_shortest_path", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); 00258 00259 kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", AKEY, KM_PRESS, 0, 0); 00260 RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); 00261 kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); 00262 RNA_enum_set(kmi->ptr, "action", SEL_INVERT); 00263 00264 WM_keymap_add_item(keymap, "MESH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); 00265 WM_keymap_add_item(keymap, "MESH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); 00266 WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0); 00267 00268 WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); 00269 kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0); 00270 RNA_boolean_set(kmi->ptr, "deselect", FALSE); 00271 kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0); 00272 RNA_boolean_set(kmi->ptr, "deselect", TRUE); 00273 00274 WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0); 00275 00276 WM_keymap_add_item(keymap, "MESH_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); 00277 00278 /* selection mode */ 00279 WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0); 00280 00281 /* hide */ 00282 kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0); 00283 RNA_boolean_set(kmi->ptr, "unselected", FALSE); 00284 kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0); 00285 RNA_boolean_set(kmi->ptr, "unselected", TRUE); 00286 WM_keymap_add_item(keymap, "MESH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); 00287 00288 /* tools */ 00289 kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0); 00290 RNA_boolean_set(kmi->ptr, "inside", FALSE); 00291 kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); 00292 RNA_boolean_set(kmi->ptr, "inside", TRUE); 00293 00294 WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */ 00295 WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, KM_ALT, 0); 00296 00297 WM_keymap_add_item(keymap, "TRANSFORM_OT_edge_crease", EKEY, KM_PRESS, KM_SHIFT, 0); 00298 00299 WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0); 00300 00301 WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0); 00302 WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0); 00303 WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0); 00304 WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0); 00305 WM_keymap_add_item(keymap, "MESH_OT_edge_flip", FKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); 00306 00307 WM_keymap_add_item(keymap, "MESH_OT_rip_move",VKEY, KM_PRESS, 0, 0); 00308 WM_keymap_add_item(keymap, "MESH_OT_merge", MKEY, KM_PRESS, KM_ALT, 0); 00309 00310 WM_keymap_add_item(keymap, "TRANSFORM_OT_shrink_fatten", SKEY, KM_PRESS, KM_ALT, 0); 00311 00312 /* add/remove */ 00313 WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0); 00314 // WM_keymap_add_item(keymap, "MESH_OT_skin", FKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); /* python, removed */ 00315 WM_keymap_add_item(keymap, "MESH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); 00316 00317 WM_keymap_add_menu(keymap, "INFO_MT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0); 00318 00319 WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, 0, 0); 00320 WM_keymap_add_item(keymap, "MESH_OT_split", YKEY, KM_PRESS, 0, 0); 00321 00322 /* use KM_CLICK because same key is used for tweaks */ 00323 kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); 00324 RNA_boolean_set(kmi->ptr, "rotate_source", TRUE); 00325 kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_SHIFT|KM_CTRL, 0); 00326 RNA_boolean_set(kmi->ptr, "rotate_source", FALSE); 00327 00328 WM_keymap_add_item(keymap, "MESH_OT_delete", XKEY, KM_PRESS, 0, 0); 00329 WM_keymap_add_item(keymap, "MESH_OT_delete", DELKEY, KM_PRESS, 0, 0); 00330 00331 WM_keymap_add_item(keymap, "MESH_OT_knife_cut", LEFTMOUSE, KM_PRESS, 0, KKEY); 00332 RNA_enum_set(WM_keymap_add_item(keymap, "MESH_OT_knife_cut", LEFTMOUSE, KM_PRESS, KM_SHIFT, KKEY)->ptr, "type", 2/*KNIFE_MIDPOINT*/); 00333 00334 WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); 00335 00336 /* menus */ 00337 WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_specials", WKEY, KM_PRESS, 0, 0); 00338 WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_faces", FKEY, KM_PRESS, KM_CTRL, 0); 00339 WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_edges", EKEY, KM_PRESS, KM_CTRL, 0); 00340 WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_vertices", VKEY, KM_PRESS, KM_CTRL, 0); 00341 WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0); 00342 WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0); 00343 WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0); 00344 00345 /* useful stuff from object-mode */ 00346 for (i=0; i<=5; i++) { 00347 kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0); 00348 RNA_int_set(kmi->ptr, "level", i); 00349 } 00350 00351 ED_object_generic_keymap(keyconf, keymap, 3); 00352 } 00353