Blender  V3.3
mesh_ops.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
8 #include "DNA_scene_types.h"
9 
10 #include "RNA_access.h"
11 
12 #include "WM_api.h"
13 #include "WM_types.h"
14 
15 #include "ED_mesh.h"
16 #include "ED_screen.h"
17 
18 #include "mesh_intern.h" /* own include */
19 
20 /**************************** registration **********************************/
21 
23 {
54 
56 
61 
67 
75 
80 
98 #ifdef WITH_FREESTYLE
99  WM_operatortype_append(MESH_OT_mark_freestyle_face);
100 #endif
101 
105 
117 #if defined(WITH_FREESTYLE)
118  WM_operatortype_append(MESH_OT_mark_freestyle_edge);
119 #endif
127 
128  /* editmesh_polybuild */
134 
146 
149 
159 
161 
171 
172 #ifdef WITH_BULLET
174 #endif
175 
179 
183 
192 }
193 
194 #if 0 /* UNUSED, remove? */
195 static int ED_operator_editmesh_face_select(bContext *C)
196 {
197  Object *obedit = CTX_data_edit_object(C);
198  if (obedit && obedit->type == OB_MESH) {
199  BMEditMesh *em = BKE_editmesh_from_object(obedit);
200  if (em && em->selectmode & SCE_SELECT_FACE) {
201  return 1;
202  }
203  }
204  return 0;
205 }
206 #endif
207 
209 {
211  wmOperatorTypeMacro *otmacro;
212 
213  ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide",
214  "Loop Cut and Slide",
215  "Cut mesh loop and slide it",
217  WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
218  WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
219 
220  ot = WM_operatortype_append_macro("MESH_OT_offset_edge_loops_slide",
221  "Offset Edge Slide",
222  "Offset edge loop slide",
224  WM_operatortype_macro_define(ot, "MESH_OT_offset_edge_loops");
225  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
226  RNA_boolean_set(otmacro->ptr, "single_side", true);
227 
228  ot = WM_operatortype_append_macro("MESH_OT_duplicate_move",
229  "Add Duplicate",
230  "Duplicate mesh and move",
232  WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
233  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
234  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
235  RNA_boolean_set(otmacro->ptr, "mirror", false);
236 
237  ot = WM_operatortype_append_macro("MESH_OT_rip_move",
238  "Rip",
239  "Rip polygons and move the result",
241  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
242  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
243  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
244  RNA_boolean_set(otmacro->ptr, "mirror", false);
245 
246  ot = WM_operatortype_append_macro("MESH_OT_rip_edge_move",
247  "Extend Vertices",
248  "Extend vertices and move the result",
250  WM_operatortype_macro_define(ot, "MESH_OT_rip_edge");
251  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
252  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
253  RNA_boolean_set(otmacro->ptr, "mirror", false);
254 
255  ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move",
256  "Extrude Region and Move",
257  "Extrude region and move result",
259  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
260  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
261  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
262  RNA_boolean_set(otmacro->ptr, "mirror", false);
263 
265  "MESH_OT_extrude_manifold",
266  "Extrude Manifold",
267  "Extrude, dissolves edges whose faces form a flat surface and intersect new edges",
269  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
270  RNA_boolean_set(otmacro->ptr, "use_dissolve_ortho_edges", true);
271  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
272  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
273  RNA_boolean_set(otmacro->ptr, "mirror", false);
274  RNA_boolean_set(otmacro->ptr, "use_automerge_and_split", true);
275 
276  ot = WM_operatortype_append_macro("MESH_OT_extrude_context_move",
277  "Extrude Region and Move",
278  "Extrude region together along the average normal",
280  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_context");
281  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
282  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
283  RNA_boolean_set(otmacro->ptr, "mirror", false);
284 
285  ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten",
286  "Extrude Region and Shrink/Fatten",
287  "Extrude region together along local normals",
289  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
290  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
291  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
292  RNA_boolean_set(otmacro->ptr, "mirror", false);
293 
294  ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move",
295  "Extrude Individual Faces and Move",
296  "Extrude each individual face separately along local normals",
298  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");
299  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
300  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
301  RNA_boolean_set(otmacro->ptr, "mirror", false);
302 
303  ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move",
304  "Extrude Only Edges and Move",
305  "Extrude edges and move result",
307  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
308  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
309  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
310  RNA_boolean_set(otmacro->ptr, "mirror", false);
311 
312  ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move",
313  "Extrude Only Vertices and Move",
314  "Extrude vertices and move result",
316  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv");
317  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
318  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
319  RNA_boolean_set(otmacro->ptr, "mirror", false);
320 
321  ot = WM_operatortype_append_macro("MESH_OT_polybuild_face_at_cursor_move",
322  "Face at Cursor Move",
323  NULL,
325  WM_operatortype_macro_define(ot, "MESH_OT_polybuild_face_at_cursor");
326  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
327  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
328  RNA_boolean_set(otmacro->ptr, "mirror", false);
329 
330  ot = WM_operatortype_append_macro("MESH_OT_polybuild_split_at_cursor_move",
331  "Split at Cursor Move",
332  NULL,
334  WM_operatortype_macro_define(ot, "MESH_OT_polybuild_split_at_cursor");
335  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
336  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
337  RNA_boolean_set(otmacro->ptr, "mirror", false);
338 
339  ot = WM_operatortype_append_macro("MESH_OT_polybuild_transform_at_cursor_move",
340  "Transform at Cursor Move",
341  NULL,
343  WM_operatortype_macro_define(ot, "MESH_OT_polybuild_transform_at_cursor");
344  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
345  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
346  RNA_boolean_set(otmacro->ptr, "mirror", false);
347 
348  ot = WM_operatortype_append_macro("MESH_OT_polybuild_extrude_at_cursor_move",
349  "Extrude at Cursor Move",
350  NULL,
352  WM_operatortype_macro_define(ot, "MESH_OT_polybuild_transform_at_cursor");
353  otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
354  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
355  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
356  RNA_boolean_set(otmacro->ptr, "mirror", false);
357 }
358 
360 {
361  wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Mesh", 0, 0);
362  keymap->poll = ED_operator_editmesh;
363 
364  knifetool_modal_keymap(keyconf);
366  bevel_modal_keymap(keyconf);
367 }
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1370
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
Definition: editmesh.c:58
@ OB_MESH
#define SCE_SELECT_FACE
bool ED_operator_editmesh(struct bContext *C)
Definition: screen_ops.c:433
#define C
Definition: RandGen.cpp:25
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
void MESH_OT_primitive_plane_add(wmOperatorType *ot)
Definition: editmesh_add.c:138
void MESH_OT_primitive_cylinder_add(wmOperatorType *ot)
Definition: editmesh_add.c:352
void MESH_OT_primitive_cone_add(wmOperatorType *ot)
Definition: editmesh_add.c:428
void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
Definition: editmesh_add.c:639
void MESH_OT_primitive_monkey_add(wmOperatorType *ot)
Definition: editmesh_add.c:574
void MESH_OT_primitive_cube_add(wmOperatorType *ot)
Definition: editmesh_add.c:201
void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot)
Definition: editmesh_add.c:706
void MESH_OT_primitive_grid_add(wmOperatorType *ot)
Definition: editmesh_add.c:501
void MESH_OT_primitive_circle_add(wmOperatorType *ot)
Definition: editmesh_add.c:278
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.cc:892
void MESH_OT_customdata_skin_add(wmOperatorType *ot)
Definition: mesh_data.cc:945
void MESH_OT_vertex_color_add(wmOperatorType *ot)
Definition: mesh_data.cc:731
void MESH_OT_uv_texture_remove(wmOperatorType *ot)
Definition: mesh_data.cc:685
void MESH_OT_customdata_skin_clear(wmOperatorType *ot)
Definition: mesh_data.cc:970
void MESH_OT_vertex_color_remove(wmOperatorType *ot)
Definition: mesh_data.cc:758
void MESH_OT_sculpt_vertex_color_remove(wmOperatorType *ot)
Definition: mesh_data.cc:814
void MESH_OT_sculpt_vertex_color_add(wmOperatorType *ot)
Definition: mesh_data.cc:787
void MESH_OT_uv_texture_add(wmOperatorType *ot)
Definition: mesh_data.cc:652
void MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
Definition: mesh_data.cc:1029
void MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot)
Definition: mesh_data.cc:1058
void MESH_OT_convex_hull(struct wmOperatorType *ot)
void ED_operatortypes_mesh(void)
Definition: mesh_ops.c:22
void ED_keymap_mesh(wmKeyConfig *keyconf)
Definition: mesh_ops.c:359
void ED_operatormacros_mesh(void)
Definition: mesh_ops.c:208
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:4874
short selectmode
Definition: BKE_editmesh.h:52
bool(* poll)(struct bContext *)
wmOperatorType * ot
Definition: wm_files.c:3479
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 *))