diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-08-21 12:02:28 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-08-21 12:05:07 +0300 |
commit | 79ecfc99fd75f897a6140639474a7b0e5910a9ff (patch) | |
tree | a0256e83713f4d866e10a43e87c2ebf84d998f6a /source/blender/editors/mesh/editmesh_loopcut.c | |
parent | f7162d214ec31daf886acf3618fa9aa567c7521d (diff) |
Tool System: loopcut preview & activate on click
The loop cut tool now works as expected for the tool-system,
where hovering previews the loop and clicking activates.
This uses a new gizmo type to pre-select the edge.
Diffstat (limited to 'source/blender/editors/mesh/editmesh_loopcut.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_loopcut.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 727b595bbe0..4fc57224580 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -436,6 +436,25 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event) static int ringcut_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + /* When accessed as a tool, get the active edge from the preselection gizmo. */ + { + ARegion *ar = CTX_wm_region(C); + wmGizmoMap *gzmap = ar->gizmo_map; + wmGizmoGroup *gzgroup = gzmap ? WM_gizmomap_group_find(gzmap, "VIEW3D_GGT_mesh_preselect_edgering") : NULL; + if (gzgroup != NULL) { + wmGizmo *gz = gzgroup->gizmos.first; + const int object_index = RNA_int_get(gz->ptr, "object_index"); + const int edge_index = RNA_int_get(gz->ptr, "edge_index"); + + if (object_index != -1 && edge_index != -1) { + RNA_int_set(op->ptr, "object_index", object_index); + RNA_int_set(op->ptr, "edge_index", edge_index); + return loopcut_init(C, op, NULL); + } + return OPERATOR_CANCELLED; + } + } + return loopcut_init(C, op, event); } |