Knife Tool: add wait_for_event option

This commit is contained in:
Campbell Barton 2017-10-17 11:50:59 +11:00
parent 67e0a44e61
commit d0f4d0df2a
1 changed files with 20 additions and 0 deletions

View File

@ -271,6 +271,8 @@ static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f);
static void knifetool_free_bmbvh(KnifeTool_OpData *kcd);
static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event);
static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *kcd)
{
char header[UI_MAX_DRAW_STR];
@ -2662,6 +2664,7 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
const bool only_select = RNA_boolean_get(op->ptr, "only_selected");
const bool cut_through = !RNA_boolean_get(op->ptr, "use_occlude_geometry");
const bool wait_for_input = RNA_boolean_get(op->ptr, "wait_for_input");
KnifeTool_OpData *kcd;
@ -2689,6 +2692,18 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event)
knifetool_update_mval_i(kcd, event->mval);
if (wait_for_input == false) {
/* Avoid copy-paste logic. */
wmEvent event_modal = {
.prevval = KM_NOTHING,
.type = EVT_MODAL_MAP,
.val = KNF_MODAL_ADD_CUT,
};
int ret = knifetool_modal(C, op, &event_modal);
BLI_assert(ret == OPERATOR_RUNNING_MODAL);
UNUSED_VARS_NDEBUG(ret);
}
knife_update_header(C, op, kcd);
return OPERATOR_RUNNING_MODAL;
@ -2955,8 +2970,13 @@ void MESH_OT_knife_tool(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* properties */
PropertyRNA *prop;
RNA_def_boolean(ot->srna, "use_occlude_geometry", true, "Occlude Geometry", "Only cut the front most geometry");
RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected", "Only cut selected geometry");
prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}