Blender  V2.93
mesh_ops.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "DNA_scene_types.h"
25 
26 #include "RNA_access.h"
27 
28 #include "WM_api.h"
29 #include "WM_types.h"
30 
31 #include "ED_mesh.h"
32 #include "ED_screen.h"
33 
34 #include "mesh_intern.h" /* own include */
35 
36 /**************************** registration **********************************/
37 
39 {
70 
72 
77 
83 
91 
96 
114 #ifdef WITH_FREESTYLE
115  WM_operatortype_append(MESH_OT_mark_freestyle_face);
116 #endif
117 
121 
133 #if defined(WITH_FREESTYLE)
134  WM_operatortype_append(MESH_OT_mark_freestyle_edge);
135 #endif
143 
144  /* editmesh_polybuild */
150 
162 
165 
175 
177 
187 
188 #ifdef WITH_BULLET
190 #endif
191 
195 
199 
208 }
209 
210 #if 0 /* UNUSED, remove? */
211 static int ED_operator_editmesh_face_select(bContext *C)
212 {
213  Object *obedit = CTX_data_edit_object(C);
214  if (obedit && obedit->type == OB_MESH) {
215  BMEditMesh *em = BKE_editmesh_from_object(obedit);
216  if (em && em->selectmode & SCE_SELECT_FACE) {
217  return 1;
218  }
219  }
220  return 0;
221 }
222 #endif
223 
225 {
227  wmOperatorTypeMacro *otmacro;
228 
229  ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide",
230  "Loop Cut and Slide",
231  "Cut mesh loop and slide it",
233  WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
234  WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
235 
236  ot = WM_operatortype_append_macro("MESH_OT_offset_edge_loops_slide",
237  "Offset Edge Slide",
238  "Offset edge loop slide",
240  WM_operatortype_macro_define(ot, "MESH_OT_offset_edge_loops");
241  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
242  RNA_boolean_set(otmacro->ptr, "single_side", true);
243 
244  ot = WM_operatortype_append_macro("MESH_OT_duplicate_move",
245  "Add Duplicate",
246  "Duplicate mesh and move",
248  WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
249  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
250  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
251  RNA_boolean_set(otmacro->ptr, "mirror", false);
252 
253  ot = WM_operatortype_append_macro("MESH_OT_rip_move",
254  "Rip",
255  "Rip polygons and move the result",
257  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
258  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
259  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
260  RNA_boolean_set(otmacro->ptr, "mirror", false);
261 
262  ot = WM_operatortype_append_macro("MESH_OT_rip_edge_move",
263  "Extend Vertices",
264  "Extend vertices and move the result",
266  WM_operatortype_macro_define(ot, "MESH_OT_rip_edge");
267  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
268  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
269  RNA_boolean_set(otmacro->ptr, "mirror", false);
270 
271  ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move",
272  "Extrude Region and Move",
273  "Extrude region and move result",
275  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
276  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
277  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
278  RNA_boolean_set(otmacro->ptr, "mirror", false);
279 
281  "MESH_OT_extrude_manifold",
282  "Extrude Manifold",
283  "Extrude, dissolves edges whose faces form a flat surface and intersect new edges",
285  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
286  RNA_boolean_set(otmacro->ptr, "use_dissolve_ortho_edges", true);
287  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
288  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
289  RNA_boolean_set(otmacro->ptr, "mirror", false);
290  RNA_boolean_set(otmacro->ptr, "use_automerge_and_split", true);
291 
292  ot = WM_operatortype_append_macro("MESH_OT_extrude_context_move",
293  "Extrude Region and Move",
294  "Extrude region together along the average normal",
296  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_context");
297  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
298  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
299  RNA_boolean_set(otmacro->ptr, "mirror", false);
300 
301  ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten",
302  "Extrude Region and Shrink/Fatten",
303  "Extrude region together along local normals",
305  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
306  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
307  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
308  RNA_boolean_set(otmacro->ptr, "mirror", false);
309 
310  ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move",
311  "Extrude Individual Faces and Move",
312  "Extrude each individual face separately along local normals",
314  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");
315  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
316  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
317  RNA_boolean_set(otmacro->ptr, "mirror", false);
318 
319  ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move",
320  "Extrude Only Edges and Move",
321  "Extrude edges and move result",
323  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
324  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
325  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
326  RNA_boolean_set(otmacro->ptr, "mirror", false);
327 
328  ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move",
329  "Extrude Only Vertices and Move",
330  "Extrude vertices and move result",
332  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv");
333  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
334  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
335  RNA_boolean_set(otmacro->ptr, "mirror", false);
336 
337  ot = WM_operatortype_append_macro("MESH_OT_polybuild_face_at_cursor_move",
338  "Face at Cursor Move",
339  "",
341  WM_operatortype_macro_define(ot, "MESH_OT_polybuild_face_at_cursor");
342  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
343  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
344  RNA_boolean_set(otmacro->ptr, "mirror", false);
345 
346  ot = WM_operatortype_append_macro("MESH_OT_polybuild_split_at_cursor_move",
347  "Split at Cursor Move",
348  "",
350  WM_operatortype_macro_define(ot, "MESH_OT_polybuild_split_at_cursor");
351  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
352  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
353  RNA_boolean_set(otmacro->ptr, "mirror", false);
354 
355  ot = WM_operatortype_append_macro("MESH_OT_polybuild_transform_at_cursor_move",
356  "Transform at Cursor Move",
357  "",
359  WM_operatortype_macro_define(ot, "MESH_OT_polybuild_transform_at_cursor");
360  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
361  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
362  RNA_boolean_set(otmacro->ptr, "mirror", false);
363 
364  ot = WM_operatortype_append_macro("MESH_OT_polybuild_extrude_at_cursor_move",
365  "Extrude at Cursor Move",
366  "",
368  WM_operatortype_macro_define(ot, "MESH_OT_polybuild_transform_at_cursor");
369  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
370  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
371  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
372  RNA_boolean_set(otmacro->ptr, "mirror", false);
373 }
374 
375 /* note mesh keymap also for other space? */
377 {
378  wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Mesh", 0, 0);
379  keymap->poll = ED_operator_editmesh;
380 
381  knifetool_modal_keymap(keyconf);
383  bevel_modal_keymap(keyconf);
384 }
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1296
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
Definition: editmesh.c:85
@ OB_MESH
#define SCE_SELECT_FACE
bool ED_operator_editmesh(struct bContext *C)
Definition: screen_ops.c:404
#define C
Definition: RandGen.cpp:39
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
void MESH_OT_primitive_plane_add(wmOperatorType *ot)
Definition: editmesh_add.c:153
void MESH_OT_primitive_cylinder_add(wmOperatorType *ot)
Definition: editmesh_add.c:367
void MESH_OT_primitive_cone_add(wmOperatorType *ot)
Definition: editmesh_add.c:443
void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
Definition: editmesh_add.c:654
void MESH_OT_primitive_monkey_add(wmOperatorType *ot)
Definition: editmesh_add.c:589
void MESH_OT_primitive_cube_add(wmOperatorType *ot)
Definition: editmesh_add.c:216
void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot)
Definition: editmesh_add.c:721
void MESH_OT_primitive_grid_add(wmOperatorType *ot)
Definition: editmesh_add.c:516
void MESH_OT_primitive_circle_add(wmOperatorType *ot)
Definition: editmesh_add.c:293
void MESH_OT_primitive_cube_add_gizmo(wmOperatorType *ot)
wmKeyMap * bevel_modal_keymap(wmKeyConfig *keyconf)
void MESH_OT_bevel(wmOperatorType *ot)
void MESH_OT_bisect(struct wmOperatorType *ot)
void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot)
void MESH_OT_extrude_context(wmOperatorType *ot)
void MESH_OT_extrude_faces_indiv(wmOperatorType *ot)
void MESH_OT_extrude_region(wmOperatorType *ot)
void MESH_OT_extrude_edges_indiv(wmOperatorType *ot)
void MESH_OT_extrude_repeat(wmOperatorType *ot)
void MESH_OT_extrude_verts_indiv(wmOperatorType *ot)
void MESH_OT_screw(wmOperatorType *ot)
void MESH_OT_spin(wmOperatorType *ot)
void MESH_OT_inset(wmOperatorType *ot)
void MESH_OT_intersect_boolean(struct wmOperatorType *ot)
void MESH_OT_face_split_by_edges(struct wmOperatorType *ot)
void MESH_OT_intersect(struct wmOperatorType *ot)
wmKeyMap * knifetool_modal_keymap(wmKeyConfig *keyconf)
void MESH_OT_knife_tool(wmOperatorType *ot)
void MESH_OT_knife_project(wmOperatorType *ot)
void MESH_OT_loopcut(wmOperatorType *ot)
void MESH_OT_paint_mask_extract(wmOperatorType *ot)
void MESH_OT_paint_mask_slice(wmOperatorType *ot)
void MESH_OT_face_set_extract(wmOperatorType *ot)
void MESH_OT_shortest_path_select(wmOperatorType *ot)
void MESH_OT_shortest_path_pick(wmOperatorType *ot)
void MESH_OT_polybuild_transform_at_cursor(wmOperatorType *ot)
void MESH_OT_polybuild_face_at_cursor(wmOperatorType *ot)
void MESH_OT_polybuild_delete_at_cursor(wmOperatorType *ot)
void MESH_OT_polybuild_dissolve_at_cursor(wmOperatorType *ot)
void MESH_OT_polybuild_split_at_cursor(wmOperatorType *ot)
void MESH_OT_rip(wmOperatorType *ot)
void MESH_OT_rip_edge(wmOperatorType *ot)
void MESH_OT_select_less(wmOperatorType *ot)
void MESH_OT_loop_to_region(wmOperatorType *ot)
void MESH_OT_select_mode(wmOperatorType *ot)
void MESH_OT_select_similar_region(wmOperatorType *ot)
void MESH_OT_select_linked_pick(wmOperatorType *ot)
void MESH_OT_select_random(wmOperatorType *ot)
void MESH_OT_select_nth(wmOperatorType *ot)
void MESH_OT_loop_multi_select(wmOperatorType *ot)
void MESH_OT_select_loose(wmOperatorType *ot)
void MESH_OT_edgering_select(wmOperatorType *ot)
void MESH_OT_select_face_by_sides(wmOperatorType *ot)
void MESH_OT_select_axis(wmOperatorType *ot)
void MESH_OT_select_mirror(wmOperatorType *ot)
void MESH_OT_faces_select_linked_flat(wmOperatorType *ot)
void MESH_OT_edges_select_sharp(wmOperatorType *ot)
void MESH_OT_select_interior_faces(wmOperatorType *ot)
void MESH_OT_select_linked(wmOperatorType *ot)
void MESH_OT_select_all(wmOperatorType *ot)
void MESH_OT_select_more(wmOperatorType *ot)
void MESH_OT_region_to_loop(wmOperatorType *ot)
void MESH_OT_loop_select(wmOperatorType *ot)
void MESH_OT_select_ungrouped(wmOperatorType *ot)
void MESH_OT_select_non_manifold(wmOperatorType *ot)
void MESH_OT_select_similar(wmOperatorType *ot)
void MESH_OT_poke(wmOperatorType *ot)
void MESH_OT_wireframe(wmOperatorType *ot)
void MESH_OT_hide(wmOperatorType *ot)
void MESH_OT_shape_propagate_to_all(wmOperatorType *ot)
void MESH_OT_uvs_reverse(wmOperatorType *ot)
void MESH_OT_faces_shade_flat(wmOperatorType *ot)
void MESH_OT_edge_rotate(wmOperatorType *ot)
void MESH_OT_edge_split(wmOperatorType *ot)
void MESH_OT_delete(wmOperatorType *ot)
void MESH_OT_point_normals(struct wmOperatorType *ot)
wmKeyMap * point_normals_modal_keymap(wmKeyConfig *keyconf)
void MESH_OT_beautify_fill(wmOperatorType *ot)
void MESH_OT_colors_rotate(wmOperatorType *ot)
void MESH_OT_quads_convert_to_tris(wmOperatorType *ot)
void MESH_OT_vert_connect(wmOperatorType *ot)
void MESH_OT_vertices_smooth(wmOperatorType *ot)
void MESH_OT_face_make_planar(wmOperatorType *ot)
void MESH_OT_dissolve_edges(wmOperatorType *ot)
void MESH_OT_uvs_rotate(wmOperatorType *ot)
void MESH_OT_delete_loose(wmOperatorType *ot)
void MESH_OT_fill(wmOperatorType *ot)
void MESH_OT_mark_seam(wmOperatorType *ot)
void MESH_OT_remove_doubles(wmOperatorType *ot)
void MESH_OT_offset_edge_loops(wmOperatorType *ot)
void MESH_OT_merge_normals(struct wmOperatorType *ot)
void MESH_OT_subdivide_edgering(wmOperatorType *ot)
void MESH_OT_separate(wmOperatorType *ot)
void MESH_OT_dissolve_limited(wmOperatorType *ot)
void MESH_OT_dissolve_degenerate(wmOperatorType *ot)
void MESH_OT_blend_from_shape(wmOperatorType *ot)
void MESH_OT_fill_grid(wmOperatorType *ot)
void MESH_OT_vert_connect_nonplanar(wmOperatorType *ot)
void MESH_OT_decimate(wmOperatorType *ot)
void MESH_OT_dissolve_mode(wmOperatorType *ot)
void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
void MESH_OT_subdivide(wmOperatorType *ot)
void MESH_OT_unsubdivide(wmOperatorType *ot)
void MESH_OT_symmetry_snap(struct wmOperatorType *ot)
void MESH_OT_duplicate(wmOperatorType *ot)
void MESH_OT_normals_make_consistent(wmOperatorType *ot)
void MESH_OT_tris_convert_to_quads(wmOperatorType *ot)
void MESH_OT_flip_normals(wmOperatorType *ot)
void MESH_OT_mark_sharp(wmOperatorType *ot)
void MESH_OT_vert_connect_path(wmOperatorType *ot)
void MESH_OT_reveal(wmOperatorType *ot)
void MESH_OT_delete_edgeloop(wmOperatorType *ot)
void MESH_OT_normals_tools(struct wmOperatorType *ot)
void MESH_OT_merge(wmOperatorType *ot)
void MESH_OT_sort_elements(wmOperatorType *ot)
void MESH_OT_fill_holes(wmOperatorType *ot)
void MESH_OT_mod_weighted_strength(struct wmOperatorType *ot)
void MESH_OT_solidify(wmOperatorType *ot)
void MESH_OT_smooth_normals(struct wmOperatorType *ot)
void MESH_OT_vert_connect_concave(wmOperatorType *ot)
void MESH_OT_symmetrize(struct wmOperatorType *ot)
void MESH_OT_faces_shade_smooth(wmOperatorType *ot)
void MESH_OT_colors_reverse(wmOperatorType *ot)
void MESH_OT_split_normals(struct wmOperatorType *ot)
void MESH_OT_set_normals_from_faces(struct wmOperatorType *ot)
void MESH_OT_dissolve_faces(wmOperatorType *ot)
void MESH_OT_edge_face_add(wmOperatorType *ot)
void MESH_OT_edge_collapse(wmOperatorType *ot)
void MESH_OT_vertices_smooth_laplacian(wmOperatorType *ot)
void MESH_OT_dissolve_verts(wmOperatorType *ot)
void MESH_OT_average_normals(struct wmOperatorType *ot)
void MESH_OT_split(wmOperatorType *ot)
void MESH_OT_customdata_mask_clear(wmOperatorType *ot)
Definition: mesh_data.c:842
void MESH_OT_customdata_skin_add(wmOperatorType *ot)
Definition: mesh_data.c:894
void MESH_OT_vertex_color_add(wmOperatorType *ot)
Definition: mesh_data.c:681
void MESH_OT_uv_texture_remove(wmOperatorType *ot)
Definition: mesh_data.c:652
void MESH_OT_customdata_skin_clear(wmOperatorType *ot)
Definition: mesh_data.c:919
void MESH_OT_vertex_color_remove(wmOperatorType *ot)
Definition: mesh_data.c:708
void MESH_OT_sculpt_vertex_color_remove(wmOperatorType *ot)
Definition: mesh_data.c:764
void MESH_OT_sculpt_vertex_color_add(wmOperatorType *ot)
Definition: mesh_data.c:737
void MESH_OT_uv_texture_add(wmOperatorType *ot)
Definition: mesh_data.c:619
void MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
Definition: mesh_data.c:992
void MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot)
Definition: mesh_data.c:1021
void MESH_OT_convex_hull(struct wmOperatorType *ot)
void ED_operatortypes_mesh(void)
Definition: mesh_ops.c:38
void ED_keymap_mesh(wmKeyConfig *keyconf)
Definition: mesh_ops.c:376
void ED_operatormacros_mesh(void)
Definition: mesh_ops.c:224
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:6272
short selectmode
Definition: BKE_editmesh.h:72
bool(* poll)(struct bContext *)
wmOperatorType * ot
Definition: wm_files.c:3156
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852
wmOperatorType * WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)
wmOperatorTypeMacro * WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))