Blender V5.3
editmesh_loopcut.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2007 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "DNA_mesh_types.h"
10#include "DNA_object_types.h"
11
12#include "MEM_guardedalloc.h"
13
14#include "BLI_math_vector_c.hh"
15#include "BLI_string_utf8.hh"
16
17#include "BLT_translation.hh"
18
19#include "BKE_context.hh"
20#include "BKE_editmesh.hh"
21#include "BKE_layer.hh"
22#include "BKE_modifier.hh"
23#include "BKE_report.hh"
24#include "BKE_screen.hh"
25#include "BKE_unit.hh"
26
27#include "UI_interface.hh"
28
29#include "ED_mesh.hh"
30#include "ED_numinput.hh"
31#include "ED_screen.hh"
32#include "ED_space_api.hh"
33#include "ED_view3d.hh"
34
35#include "RNA_access.hh"
36#include "RNA_define.hh"
37#include "RNA_enum_types.hh"
38
39#include "WM_api.hh"
40#include "WM_types.hh"
41
42#include "DEG_depsgraph.hh"
44
45#include "mesh_intern.hh" /* own include */
46
47namespace blender {
48
49#define SUBD_SMOOTH_MAX 4.0f
50#define SUBD_CUTS_MAX 500
51
52/* ringsel operator */
53
59
60/* struct for properties used while drawing */
62 ARegion *region; /* region that ringsel was activated in */
63 void *draw_handle; /* for drawing preview loop */
64
66
68
69 Depsgraph *depsgraph;
70
72
74
75 /* These values switch objects based on the object under the cursor. */
80
82
83 bool extend;
84 bool do_cut;
85
86 float cuts; /* cuts as float so smooth mouse pan works in small increments */
88};
89
90/* modal loop selection drawing callback */
91static void ringsel_draw(const bContext * /*C*/, ARegion * /*region*/, void *arg)
92{
93 RingSelOpData *lcd = static_cast<RingSelOpData *>(arg);
94 if (lcd->ob != nullptr) {
95 EDBM_preselect_edgering_draw(lcd->presel_edgering, lcd->ob->object_to_world().ptr());
96 }
97}
98
100{
101 if (!lcd->eed) {
102 return;
103 }
104
105 if (!lcd->extend) {
106 for (Base *base : lcd->bases) {
107 Object *ob_iter = base->object;
112 }
113 }
114
116 BMEdge *eed_start = lcd->eed;
117 BMWalker walker;
118 BMEdge *eed;
119 BMW_init(&walker,
120 bm,
128
129 for (eed = static_cast<BMEdge *>(BMW_begin(&walker, eed_start)); eed;
130 eed = static_cast<BMEdge *>(BMW_step(&walker)))
131 {
132 BM_edge_select_set(bm, eed, true);
133 }
134 BMW_end(&walker);
135}
136
137static void ringsel_find_edge(RingSelOpData *lcd, const int previewlines)
138{
139 if (lcd->eed) {
140 MeshCoordsCache *gcache = &lcd->geom_cache[lcd->base_index];
141 if (gcache->is_init == false) {
142 Scene *scene_eval = DEG_get_evaluated(lcd->vc.depsgraph, lcd->vc.scene);
143 Object *ob_eval = DEG_get_evaluated(lcd->vc.depsgraph, lcd->ob);
145 lcd->vc.depsgraph, scene_eval, ob_eval, gcache->allocated_vert_positions);
146 gcache->is_init = true;
147 }
150 lcd->presel_edgering, bm, lcd->eed, previewlines, gcache->vert_positions);
151 }
152 else {
154 }
155}
156
158{
159 RingSelOpData *lcd = static_cast<RingSelOpData *>(op->customdata);
160 const int cuts = RNA_int_get(op->ptr, "number_cuts");
161 const float smoothness = RNA_float_get(op->ptr, "smoothness");
162 const int smooth_falloff = RNA_enum_get(op->ptr, "falloff");
163#ifdef BMW_EDGERING_NGON
164 const bool use_only_quads = false;
165#else
166 const bool use_only_quads = false;
167#endif
168
169 if (lcd->eed) {
170 BMEditMesh *em = lcd->em;
172 BMVert *v_eed_orig[2] = {lcd->eed->v1, lcd->eed->v2};
173
174 edgering_select(lcd);
175
176 if (lcd->do_cut) {
177 const bool is_macro = (op->opm != nullptr);
178 /* a single edge (rare, but better support) */
179 const bool is_edge_wire = BM_edge_is_wire(lcd->eed);
180 const bool is_single = is_edge_wire || !BM_edge_is_any_face_len_test(lcd->eed, 4);
181 const int seltype = is_edge_wire ? SUBDIV_SELECT_INNER :
182 is_single ? SUBDIV_SELECT_NONE :
184
185 /* Enable grid-fill, so that intersecting loop-cut works as one would expect.
186 * Note though that it will break edge-slide in this specific case.
187 * See #31939. */
190 smoothness,
191 smooth_falloff,
192 true,
193 0.0f,
194 0.0f,
195 cuts,
196 seltype,
198 0,
199 true,
200 use_only_quads,
201 0);
202
203 /* When used in a macro the tessellation will be recalculated anyway,
204 * this is needed here because modifiers depend on updated tessellation, see #45920 */
205 EDBMUpdate_Params params{};
206 params.calc_looptris = true;
207 params.calc_normals = false;
208 params.is_destructive = true;
209 EDBM_update(id_cast<Mesh *>(lcd->ob->data), &params);
210
211 if (is_single) {
212 /* de-select endpoints */
213 BM_vert_select_set(bm, v_eed_orig[0], false);
214 BM_vert_select_set(bm, v_eed_orig[1], false);
215
217 }
218 /* We can't slide multiple edges in vertex select mode, force edge select mode. Do this for
219 * all meshes in multi-object editmode so their selectmode is in sync for following
220 * operators. */
221 else if (is_macro && (cuts > 1) && (em->selectmode & SCE_SELECT_VERTEX)) {
223 }
224 /* Force edge slide to edge select mode in face select mode. Do this for all meshes in
225 * multi-object editmode so their selectmode is in sync for following operators. */
227 /* pass, the change will flush selection */
228 }
229 else {
230 /* else flush explicitly */
232 }
233 }
234 else {
235 /* XXX Is this piece of code ever used now? Simple loop select is now
236 * in editmesh_select.cc (around line 1000)... */
237 /* sets as active, useful for other tools */
238 if (em->selectmode & SCE_SELECT_VERTEX) {
239 /* low priority TODO: get vertex close to mouse. */
241 }
242 if (em->selectmode & SCE_SELECT_EDGE) {
244 }
245
247
250 }
251
253 }
254}
255
256/* called when modal loop selection is done... */
257static void ringsel_exit(bContext * /*C*/, wmOperator *op)
258{
259 RingSelOpData *lcd = static_cast<RingSelOpData *>(op->customdata);
260
261 /* Type can be null in background mode. */
262 if (lcd->region->runtime->type) {
263 /* deactivate the extra drawing stuff in 3D-View */
265 }
266
268
270
271 MEM_delete(lcd);
272 op->customdata = nullptr;
273}
274
275/* called when modal loop selection gets set up... */
276static int ringsel_init(bContext *C, wmOperator *op, bool do_cut)
277{
278 Scene *scene = CTX_data_scene(C);
279
280 /* alloc new customdata */
281 RingSelOpData *lcd = MEM_new<RingSelOpData>(__func__);
282 op->customdata = lcd;
283 lcd->vc = em_setup_viewcontext(C);
284
286
287 /* assign the drawing handle for drawing preview line... */
288 lcd->region = CTX_wm_region(C);
289 /* Type can be null in background mode. */
290 if (lcd->region->runtime->type) {
293 }
295 /* Initialize once the cursor is over a mesh. */
296 lcd->ob = nullptr;
297 lcd->em = nullptr;
298 lcd->extend = do_cut ? false : RNA_boolean_get(op->ptr, "extend");
299 lcd->do_cut = do_cut;
300 lcd->cuts = RNA_int_get(op->ptr, "number_cuts");
301 lcd->smoothness = RNA_float_get(op->ptr, "smoothness");
302
303 initNumInput(&lcd->num);
304 lcd->num.idx_max = 1;
306 /* No specific flags for smoothness. */
307 lcd->num.unit_sys = scene->unit.system;
308 lcd->num.unit_type[0] = B_UNIT_NONE;
309 lcd->num.unit_type[1] = B_UNIT_NONE;
310
312
313 return 1;
314}
315
317{
318 /* this is just a wrapper around exit() */
319 ringsel_exit(C, op);
320}
321
323 uint base_index,
324 BMEdge *e,
325 const int previewlines)
326{
327 if (e != lcd->eed) {
328 lcd->eed = e;
329 lcd->ob = lcd->vc.obedit;
330 lcd->base_index = base_index;
331 lcd->em = lcd->vc.em;
332 ringsel_find_edge(lcd, previewlines);
333 }
334 else if (e == nullptr) {
335 lcd->ob = nullptr;
336 lcd->em = nullptr;
337 lcd->base_index = UINT_MAX;
338 }
339}
340
341static void loopcut_mouse_move(RingSelOpData *lcd, const int previewlines)
342{
343 struct {
344 Object *ob;
345 BMEdge *eed;
346 float dist;
347 int base_index;
348 } best{};
349 best.dist = ED_view3d_select_dist_px();
350
351 uint base_index;
353 &lcd->vc, &best.dist, nullptr, false, false, nullptr, lcd->bases, &base_index);
354
355 if (eed_test) {
356 best.ob = lcd->bases[base_index]->object;
357 best.eed = eed_test;
358 best.base_index = base_index;
359 }
360
361 if (best.eed) {
363 }
364
365 loopcut_update_edge(lcd, best.base_index, best.eed, previewlines);
366}
367
368/* called by both init() and exec() */
370{
371 /* Check whether both `rv3d` and `event` is present, this way we allow the loopcut operator to
372 * run non-interactively no matter whether the graphical UI is present or not (e.g. from scripts
373 * with UI running, or entirely in the background with `blender -b`). */
375 const bool is_interactive = (rv3d != nullptr) && (event != nullptr);
376
377 /* Use for redo - intentionally wrap int to uint. */
378 struct {
379 uint base_index;
380 uint e_index;
381 } exec_data{};
382 exec_data.base_index = uint(RNA_int_get(op->ptr, "object_index"));
383 exec_data.e_index = uint(RNA_int_get(op->ptr, "edge_index"));
384
385 const Main *bmain = CTX_data_main(C);
386 const Scene *scene = CTX_data_scene(C);
387 ViewLayer *view_layer = CTX_data_view_layer(C);
388
390 *bmain, scene, view_layer, CTX_wm_view3d(C));
391
392 if (is_interactive) {
393 for (Base *base : bases) {
394 Object *ob_iter = base->object;
397 {
399 op->reports, RPT_WARNING, "Loop cut does not work well on deformed edit mesh display");
400 break;
401 }
402 }
403 }
404
405 if (is_interactive) {
407 }
408
409 /* for re-execution, check edge index is in range before we setup ringsel */
410 bool ok = true;
411 if (is_interactive == false) {
412 if (exec_data.base_index >= bases.size()) {
413 ok = false;
414 }
415 else {
416 Object *ob_iter = bases[exec_data.base_index]->object;
418 if (exec_data.e_index >= bm->totedge) {
419 ok = false;
420 }
421 }
422 }
423
424 if (!ok || !ringsel_init(C, op, true)) {
425 return OPERATOR_CANCELLED;
426 }
427
428 /* add a modal handler for this operator - handles loop selection */
429 if (is_interactive) {
432 }
433
434 RingSelOpData *lcd = static_cast<RingSelOpData *>(op->customdata);
435
436 lcd->bases = std::move(bases);
437 lcd->geom_cache.reinitialize(lcd->bases.size());
438
439 if (is_interactive) {
440 copy_v2_v2_int(lcd->vc.mval, event->mval);
441 loopcut_mouse_move(lcd, is_interactive ? 1 : 0);
442 }
443 else {
444
445 Object *ob_iter = lcd->bases[exec_data.base_index]->object;
447
449
450 BMEdge *e;
452 e = BM_edge_at_index(bm, exec_data.e_index);
453 loopcut_update_edge(lcd, exec_data.base_index, e, 0);
454 }
455
456#ifdef USE_LOOPSLIDE_HACK
457 /* for use in macro so we can restore, HACK */
458 {
459 ToolSettings *settings = scene->toolsettings;
460 const bool mesh_select_mode[3] = {
461 (settings->selectmode & SCE_SELECT_VERTEX) != 0,
462 (settings->selectmode & SCE_SELECT_EDGE) != 0,
463 (settings->selectmode & SCE_SELECT_FACE) != 0,
464 };
465
466 RNA_boolean_set_array(op->ptr, "mesh_select_mode_init", mesh_select_mode);
467 }
468#endif
469
470 if (is_interactive) {
471 char buf[UI_MAX_DRAW_STR];
472 char str_rep[NUM_STR_REP_LEN * 2];
473 if (hasNumInput(&lcd->num)) {
474 outputNumInput(&lcd->num, str_rep, scene->unit);
475 }
476 else {
477 BLI_snprintf_utf8(str_rep, NUM_STR_REP_LEN, "%d", int(lcd->cuts));
479 }
480 SNPRINTF_UTF8(buf, IFACE_("Cuts: %s, Smoothness: %s"), str_rep, str_rep + NUM_STR_REP_LEN);
482
483 WorkspaceStatus status(C);
484 status.item(IFACE_("Confirm"), ICON_MOUSE_LMB);
485 status.item(IFACE_("Cancel"), ICON_MOUSE_RMB);
486 status.item(IFACE_("Select Ring"), ICON_MOUSE_MOVE);
487 status.item("", ICON_MOUSE_MMB);
488 status.item(IFACE_("Number of Cuts"), ICON_EVENT_PAGEUP, ICON_EVENT_PAGEDOWN);
489 status.item(IFACE_("Smoothness"), ICON_EVENT_ALT, ICON_MOUSE_MMB);
491 }
492
493 ringsel_finish(C, op);
494 ringsel_exit(C, op);
495 return OPERATOR_FINISHED;
496}
497
499{
500 /* When accessed as a tool, get the active edge from the pre-selection gizmo. */
501 {
502 ARegion *region = CTX_wm_region(C);
503 wmGizmoMap *gzmap = region->runtime->gizmo_map;
504 wmGizmoGroup *gzgroup = gzmap ? WM_gizmomap_group_find(gzmap,
505 "VIEW3D_GGT_mesh_preselect_edgering") :
506 nullptr;
507 if ((gzgroup != nullptr) && gzgroup->gizmos.first_) {
508 wmGizmo *gz = gzgroup->gizmos.first();
509 const int object_index = RNA_int_get(gz->ptr, "object_index");
510 const int edge_index = RNA_int_get(gz->ptr, "edge_index");
511
512 if (object_index != -1 && edge_index != -1) {
513 RNA_int_set(op->ptr, "object_index", object_index);
514 RNA_int_set(op->ptr, "edge_index", edge_index);
515 return loopcut_init(C, op, nullptr);
516 }
517 return OPERATOR_CANCELLED;
518 }
519 }
520
521 return loopcut_init(C, op, event);
522}
523
525{
526 return loopcut_init(C, op, nullptr);
527}
528
530{
531 /* finish */
533 ED_workspace_status_text(C, nullptr);
535
536 if (lcd->eed) {
537 /* set for redo */
540 RNA_int_set(op->ptr, "object_index", lcd->base_index);
541 RNA_int_set(op->ptr, "edge_index", BM_elem_index_get(lcd->eed));
542
543 /* execute */
544 ringsel_finish(C, op);
545 ringsel_exit(C, op);
546 }
547 else {
548 ringcut_cancel(C, op);
549 return OPERATOR_CANCELLED;
550 }
551
552 return OPERATOR_FINISHED;
553}
554
556{
557 if (event->type == NDOF_MOTION) {
559 }
560
561 RingSelOpData *lcd = static_cast<RingSelOpData *>(op->customdata);
562 float cuts = lcd->cuts;
563 float smoothness = lcd->smoothness;
564 bool show_cuts = false;
565 const bool has_numinput = hasNumInput(&lcd->num);
566
567 lcd->vc = em_setup_viewcontext(C);
568 lcd->region = lcd->vc.region;
569
571
572 /* using the keyboard to input the number of cuts */
573 /* Modal numinput active, try to handle numeric inputs first... */
574 if (event->val == KM_PRESS && has_numinput && handleNumInput(C, &lcd->num, event)) {
575 float values[2] = {cuts, smoothness};
576 applyNumInput(&lcd->num, values);
577 cuts = values[0];
578 smoothness = values[1];
579 }
580 else {
581 bool handled = false;
582 switch (event->type) {
583 case EVT_RETKEY:
584 case EVT_PADENTER:
585 case LEFTMOUSE: /* confirm */ /* XXX hardcoded */
586 if (event->val == KM_PRESS) {
587 return loopcut_finish(lcd, C, op);
588 }
589
591 handled = true;
592 break;
593 case RIGHTMOUSE: /* abort */ /* XXX hardcoded */
595 ringsel_exit(C, op);
596 ED_workspace_status_text(C, nullptr);
598
599 return OPERATOR_CANCELLED;
600 case EVT_ESCKEY:
601 if (event->val == KM_RELEASE) {
602 /* cancel */
604 ED_workspace_status_text(C, nullptr);
606
607 ringcut_cancel(C, op);
608 return OPERATOR_CANCELLED;
609 }
610
612 handled = true;
613 break;
614 case MOUSEPAN:
615 if ((event->modifier & KM_ALT) == 0) {
616 cuts += 0.02f * (event->xy[1] - event->prev_xy[1]);
617 if (cuts < 1 && lcd->cuts >= 1) {
618 cuts = 1;
619 }
620 }
621 else {
622 smoothness += 0.002f * (event->xy[1] - event->prev_xy[1]);
623 }
624 handled = true;
625 break;
626 case EVT_PADPLUSKEY:
627 case EVT_PAGEUPKEY:
628 case WHEELUPMOUSE: /* change number of cuts */
629 if (event->val == KM_RELEASE) {
630 break;
631 }
632 if ((event->modifier & KM_ALT) == 0) {
633 cuts += 1;
634 }
635 else {
636 smoothness += 0.05f;
637 }
638 handled = true;
639 break;
640 case EVT_PADMINUS:
641 case EVT_PAGEDOWNKEY:
642 case WHEELDOWNMOUSE: /* change number of cuts */
643 if (event->val == KM_RELEASE) {
644 break;
645 }
646 if ((event->modifier & KM_ALT) == 0) {
647 cuts = max_ff(cuts - 1, 1);
648 }
649 else {
650 smoothness -= 0.05f;
651 }
652 handled = true;
653 break;
654 case MOUSEMOVE: {
655/* mouse moved somewhere to select another loop */
656
657/* This is normally disabled for all modal operators.
658 * This is an exception since mouse movement doesn't relate to numeric input.
659 *
660 * If numeric input changes we'll need to add this back see: D2973 */
661#if 0
662 if (!has_numinput)
663#endif
664 {
665 lcd->vc.mval[0] = event->mval[0];
666 lcd->vc.mval[1] = event->mval[1];
667 loopcut_mouse_move(lcd, int(lcd->cuts));
668
670 handled = true;
671 }
672 break;
673 }
674 default: {
675 break;
676 }
677 }
678
679 /* Modal numinput inactive, try to handle numeric inputs last... */
680 if (!handled && event->val == KM_PRESS && handleNumInput(C, &lcd->num, event)) {
681 float values[2] = {cuts, smoothness};
682 applyNumInput(&lcd->num, values);
683 cuts = values[0];
684 smoothness = values[1];
685 }
686 }
687
688 if (cuts != lcd->cuts) {
689 /* allow zero so you can backspace and type in a value
690 * otherwise 1 as minimum would make more sense */
691 lcd->cuts = clamp_f(cuts, 0, SUBD_CUTS_MAX);
692 RNA_int_set(op->ptr, "number_cuts", int(lcd->cuts));
693 ringsel_find_edge(lcd, int(lcd->cuts));
694 show_cuts = true;
696 }
697
698 if (smoothness != lcd->smoothness) {
700 RNA_float_set(op->ptr, "smoothness", lcd->smoothness);
701 show_cuts = true;
703 }
704
705 if (show_cuts) {
706 Scene *sce = CTX_data_scene(C);
707 char buf[UI_MAX_DRAW_STR];
708 char str_rep[NUM_STR_REP_LEN * 2];
709 if (hasNumInput(&lcd->num)) {
710 outputNumInput(&lcd->num, str_rep, sce->unit);
711 }
712 else {
713 BLI_snprintf_utf8(str_rep, NUM_STR_REP_LEN, "%d", int(lcd->cuts));
714 BLI_snprintf_utf8(str_rep + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%.2f", smoothness);
715 }
716 SNPRINTF_UTF8(buf, IFACE_("Cuts: %s, Smoothness: %s"), str_rep, str_rep + NUM_STR_REP_LEN);
718 }
719
720 /* keep going until the user confirms */
722}
723
725{
726 PropertyRNA *prop;
727
728 /* description */
729 ot->name = "Loop Cut";
730 ot->idname = "MESH_OT_loopcut";
731 ot->description = "Add a new loop between existing loops";
732
733 /* callbacks */
735 ot->exec = loopcut_exec;
736 ot->modal = loopcut_modal;
738 /* Note the #RegionView3D is needed for interactive use, the operator must check this. */
740
741 /* flags */
743
744 /* properties */
745 prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, 1000000, "Number of Cuts", "", 1, 100);
746 /* avoid re-using last var because it can cause
747 * _very_ high poly meshes and annoy users (or worse crash) */
749
750 prop = RNA_def_float(ot->srna,
751 "smoothness",
752 0.0f,
753 -1e3f,
754 1e3f,
755 "Smoothness",
756 "Smoothness factor",
760
762
763 prop = RNA_def_property(ot->srna, "falloff", PROP_ENUM, PROP_NONE);
766 RNA_def_property_ui_text(prop, "Falloff", "Falloff type of the feather");
768 BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */
769
770 /* For redo only. */
771 prop = RNA_def_int(ot->srna, "object_index", -1, -1, INT_MAX, "Object Index", "", 0, INT_MAX);
774 prop = RNA_def_int(ot->srna, "edge_index", -1, -1, INT_MAX, "Edge Index", "", 0, INT_MAX);
776
777#ifdef USE_LOOPSLIDE_HACK
778 prop = RNA_def_boolean_array(ot->srna, "mesh_select_mode_init", 3, nullptr, "", "");
780#endif
781}
782
783} // namespace blender
#define SNPRINTF_UTF8(dst, format,...)
#define BLT_I18NCONTEXT_ID_CURVE_LEGACY
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_ID_MESH
Object is a sort of wrapper for general info.
#define NUM_STR_REP_LEN
#define REGION_DRAW_POST_VIEW
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_MAX_DRAW_STR
#define NC_GEOM
Definition WM_types.hh:406
#define ND_SELECT
Definition WM_types.hh:551
#define BM_elem_index_get(ele)
#define BM_select_history_store(bm, ele)
#define BMW_NIL_LAY
#define BMW_MASK_NOP
int64_t size() const
void item(std::string text, int icon1, int icon2=0)
Definition area.cc:1076
#define SUBD_SMOOTH_MAX
#define SUBD_CUTS_MAX
#define INT_MAX
#define UINT_MAX
Definition hash_md5.cc:46
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
void EDBM_flag_disable_all(BMesh *bm, char hflag)
static int ringsel_init(bContext *C, wmOperator *op, bool do_cut)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
ScrArea * CTX_wm_area(const bContext *C)
EditMesh_PreSelEdgeRing * EDBM_preselect_edgering_create()
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
BLI_INLINE bool BM_edge_is_wire(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
static void ringcut_cancel(bContext *C, wmOperator *op)
int RNA_enum_get(PointerRNA *ptr, const char *name)
@ BMW_FLAG_TEST_HIDDEN
@ RPT_WARNING
Definition BKE_report.hh:40
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
bool BM_edge_is_any_face_len_test(const BMEdge *e, const int len)
void EDBM_selectmode_flush(BMesh *bm, short selectmode)
static wmOperatorStatus loopcut_finish(RingSelOpData *lcd, bContext *C, wmOperator *op)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
Definition editmesh.cc:79
Span< float3 > BKE_editmesh_vert_coords_when_deformed(Depsgraph *depsgraph, Scene *scene, Object *obedit, Array< float3 > &r_alloc)
Definition editmesh.cc:214
unsigned int uint
Definition BKE_text.h:55
static wmOperatorStatus ringcut_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
Definition numinput.cc:344
BLI_INLINE BMEdge * BM_edge_at_index(BMesh *bm, const int index)
void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
void * BMW_begin(BMWalker *walker, void *start)
void BMW_init(BMWalker *walker, BMesh *bm, int type, short mask_vert, short mask_edge, short mask_face, BMWFlag flag, int layer, BMWDelimitFlag delimit)
Initialize Walker.
void EDBM_update(Mesh *mesh, const EDBMUpdate_Params *params)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
static void ringsel_finish(bContext *C, wmOperator *op)
Object * BKE_modifiers_is_deformed_by_armature(Object *ob)
int RNA_int_get(PointerRNA *ptr, const char *name)
bool hasNumInput(const NumInput *n)
Definition numinput.cc:188
void view3d_operator_needs_gpu(const bContext *C)
PropertyRNA * RNA_def_boolean_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const bool *default_value, const char *ui_name, const char *ui_description)
void MESH_OT_loopcut(wmOperatorType *ot)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
void EDBM_preselect_edgering_update_from_edge(EditMesh_PreSelEdgeRing *psel, BMesh *bm, BMEdge *eed_start, int previewlines, Span< float3 > vert_positions)
ViewLayer * CTX_data_view_layer(const bContext *C)
static void loopcut_update_edge(RingSelOpData *lcd, uint base_index, BMEdge *e, const int previewlines)
void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact)
void BM_mesh_esubdivide(BMesh *bm, char edge_hflag, float smooth, short smooth_falloff, bool use_smooth_even, float fractal, float along_normal, int numcuts, int seltype, int cornertype, short use_single_edge, short use_grid_fill, short use_only_quads, int seed)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
bool EDBM_selectmode_disable_multi(bContext *C, short selectmode_disable, short selectmode_fallback)
bool ED_operator_editmesh(bContext *C)
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
void EDBM_preselect_edgering_clear(EditMesh_PreSelEdgeRing *psel)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
static void edgering_select(RingSelOpData *lcd)
static wmOperatorStatus loopcut_exec(bContext *C, wmOperator *op)
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
void BMW_end(BMWalker *walker)
End Walker.
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void initNumInput(NumInput *n)
Definition numinput.cc:85
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
const EnumPropertyItem rna_enum_proportional_falloff_curve_only_items[]
Definition rna_scene.cc:119
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:975
RegionView3D * CTX_wm_region_view3d(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void BM_vert_select_set(BMesh *bm, BMVert *v, const bool select)
Select Vert.
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:207
void RNA_boolean_set_array(PointerRNA *ptr, const char *name, const bool *values)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
static void loopcut_mouse_move(RingSelOpData *lcd, const int previewlines)
static void ringsel_find_edge(RingSelOpData *lcd, const int previewlines)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
ViewContext em_setup_viewcontext(bContext *C)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void EDBM_selectmode_flush_ex(BMesh *bm, short selectmode)
Main * CTX_data_main(const bContext *C)
MINLINE float max_ff(float a, float b)
void EDBM_preselect_edgering_destroy(EditMesh_PreSelEdgeRing *psel)
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:104
BMEdge * EDBM_edge_find_nearest_ex(ViewContext *vc, float *dist_px_manhattan, float *r_dist_center, bool use_select_bias, bool use_cycle, BMEdge **r_eed_zbuf, Span< Base * > bases, uint *r_base_index)
void WM_operatortype_props_advanced_begin(wmOperatorType *ot)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
void * BMW_step(BMWalker *walker)
Step Walker.
wmGizmoGroup * WM_gizmomap_group_find(wmGizmoMap *gzmap, const char *idname)
@ KM_RELEASE
Definition WM_types.hh:325
static void ringsel_exit(bContext *, wmOperator *op)
bool EDBM_uvselect_clear(BMesh *bm)
Scene * CTX_data_scene(const bContext *C)
static void ringsel_draw(const bContext *, ARegion *, void *arg)
void EDBM_preselect_edgering_draw(EditMesh_PreSelEdgeRing *psel, const float matrix[4][4])
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_BLOCKING
Definition WM_types.hh:192
static wmOperatorStatus loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
float ED_view3d_select_dist_px()
Vector< Base * > BKE_view_layer_array_from_bases_in_edit_mode(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
@ B_UNIT_NONE
Definition BKE_unit.hh:165
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1153
float RNA_float_get(PointerRNA *ptr, const char *name)
View3D * CTX_wm_view3d(const bContext *C)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
@ BMW_DELIMIT_EDGE_RING_NGONS
@ SUBDIV_SELECT_LOOPCUT
MINLINE float clamp_f(float value, float min, float max)
Object * BKE_modifiers_is_deformed_by_lattice(Object *ob)
static wmOperatorStatus loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
@ NUM_NO_NEGATIVE
@ NUM_NO_FRACTION
void BM_edge_select_set(BMesh *bm, BMEdge *e, const bool select)
Select Edge.
bke::ARegionRuntime * runtime
struct Object * object
Array< float3 > allocated_vert_positions
int unit_type[NUM_MAX_ELEMENTS]
short val_flag[NUM_MAX_ELEMENTS]
Array< MeshCoordsCache > geom_cache
EditMesh_PreSelEdgeRing * presel_edgering
struct UnitSettings unit
struct ToolSettings * toolsettings
BMEditMesh * em
Definition ED_view3d.hh:87
Depsgraph * depsgraph
Definition ED_view3d.hh:78
struct ARegionType * type
wmEventType type
Definition WM_types.hh:817
wmEventModifierFlag modifier
Definition WM_types.hh:834
ListBaseT< wmGizmo > gizmos
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
struct ReportList * reports