Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCian Jinks <cjinks99@gmail.com>2021-08-10 17:33:57 +0300
committerCian Jinks <cjinks99@gmail.com>2021-08-10 17:33:57 +0300
commite3c8e879a96b547b2a805e460c63446bed224bde (patch)
tree0e79f4c7a5edaf98fb17d67dd883dcbf686066ec /source/blender/editors/mesh/editmesh_knife.c
parentcbbd1782e626e7738e4f27a2ce3f3fb5672da6b6 (diff)
parent05879f2c36e9e59ca62011aafb266a7b8dd64656 (diff)
Merge branch 'master' into soc-2021-knife-tools
Diffstat (limited to 'source/blender/editors/mesh/editmesh_knife.c')
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 37188af714b..e710bc14c65 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -3992,26 +3992,27 @@ static void knife_mouse_move(KnifeTool_OpData *kcd)
}
}
-/* Called when modal loop selection gets set up... */
+/* called when modal loop selection gets set up... */
static void knifetool_init(bContext *C,
+ ViewContext *vc,
KnifeTool_OpData *kcd,
const bool only_select,
const bool cut_through,
const float angle_snapping_increment,
const bool is_interactive)
{
- Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
+ kcd->vc = *vc;
+
+ Scene *scene = vc->scene;
+ Object *obedit = vc->obedit;
/* Assign the drawing handle for drawing preview line... */
kcd->scene = scene;
kcd->ob = obedit;
- kcd->region = CTX_wm_region(C);
+ kcd->region = vc->region;
invert_m4_m4_safe_ortho(kcd->ob_imat, kcd->ob->obmat);
- em_setup_viewcontext(C, &kcd->vc);
-
kcd->em = BKE_editmesh_from_object(kcd->ob);
kcd->bases = BKE_view_layer_array_from_bases_in_edit_mode(
@@ -4083,15 +4084,15 @@ static void knifetool_init(bContext *C,
kcd->num.unit_type[0] = B_UNIT_NONE;
}
-/* Called when modal loop selection is done... */
-static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd)
+/* called when modal loop selection is done... */
+static void knifetool_exit_ex(KnifeTool_OpData *kcd)
{
if (!kcd) {
return;
}
if (kcd->is_interactive) {
- WM_cursor_modal_restore(CTX_wm_window(C));
+ WM_cursor_modal_restore(kcd->vc.win);
/* Deactivate the extra drawing stuff in 3D-View. */
ED_region_draw_cb_exit(kcd->region->type, kcd->draw_handle);
@@ -4138,10 +4139,10 @@ static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd)
MEM_freeN(kcd);
}
-static void knifetool_exit(bContext *C, wmOperator *op)
+static void knifetool_exit(wmOperator *op)
{
KnifeTool_OpData *kcd = op->customdata;
- knifetool_exit_ex(C, kcd);
+ knifetool_exit_ex(kcd);
op->customdata = NULL;
}
@@ -4254,10 +4255,10 @@ static void knifetool_finish(wmOperator *op)
/** \name Operator (#MESH_OT_knife_tool)
* \{ */
-static void knifetool_cancel(bContext *C, wmOperator *op)
+static void knifetool_cancel(bContext *UNUSED(C), wmOperator *op)
{
- /* This is just a wrapper around exit(). */
- knifetool_exit(C, op);
+ /* this is just a wrapper around exit() */
+ knifetool_exit(op);
}
wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf)
@@ -4322,7 +4323,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
bool do_refresh = false;
if (!obedit || obedit->type != OB_MESH || BKE_editmesh_from_object(obedit) != kcd->em) {
- knifetool_exit(C, op);
+ knifetool_exit(op);
ED_workspace_status_text(C, NULL);
return OPERATOR_FINISHED;
}
@@ -4363,7 +4364,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* finish */
ED_region_tag_redraw(kcd->region);
- knifetool_exit(C, op);
+ knifetool_exit(op);
ED_workspace_status_text(C, NULL);
return OPERATOR_CANCELLED;
@@ -4372,7 +4373,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
ED_region_tag_redraw(kcd->region);
knifetool_finish(op);
- knifetool_exit(C, op);
+ knifetool_exit(op);
ED_workspace_status_text(C, NULL);
return OPERATOR_FINISHED;
@@ -4650,12 +4651,10 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const float angle_snapping_increment = RAD2DEGF(
RNA_float_get(op->ptr, "angle_snapping_increment"));
+ ViewContext vc;
KnifeTool_OpData *kcd;
- /* Alloc new customdata. */
- kcd = op->customdata = MEM_callocN(sizeof(KnifeTool_OpData), __func__);
-
- knifetool_init(C, kcd, only_select, cut_through, angle_snapping_increment, true);
+ em_setup_viewcontext(C, &vc);
if (only_select) {
Object *obedit;
@@ -4676,6 +4675,11 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
}
+ /* alloc new customdata */
+ kcd = op->customdata = MEM_callocN(sizeof(KnifeTool_OpData), __func__);
+
+ knifetool_init(C, &vc, kcd, only_select, cut_through, angle_snapping_increment, true);
+
op->flag |= OP_IS_MODAL_CURSOR_REGION;
/* Add a modal handler for this operator - handles loop selection. */
@@ -4769,7 +4773,7 @@ static bool edbm_mesh_knife_point_isect(LinkNode *polys, const float cent_ss[2])
/**
* \param use_tag: When set, tag all faces inside the polylines.
*/
-void EDBM_mesh_knife(bContext *C, LinkNode *polys, bool use_tag, bool cut_through)
+void EDBM_mesh_knife(bContext *C, ViewContext *vc, LinkNode *polys, bool use_tag, bool cut_through)
{
KnifeTool_OpData *kcd;
@@ -4781,7 +4785,7 @@ void EDBM_mesh_knife(bContext *C, LinkNode *polys, bool use_tag, bool cut_throug
kcd = MEM_callocN(sizeof(KnifeTool_OpData), __func__);
- knifetool_init(C, kcd, only_select, cut_through, angle_snapping_increment, is_interactive);
+ knifetool_init(C, vc, kcd, only_select, cut_through, angle_snapping_increment, is_interactive);
kcd->ignore_edge_snapping = true;
kcd->ignore_vert_snapping = true;
@@ -4912,7 +4916,7 @@ void EDBM_mesh_knife(bContext *C, LinkNode *polys, bool use_tag, bool cut_throug
#undef F_ISECT_SET_OUTSIDE
}
- knifetool_exit_ex(C, kcd);
+ knifetool_exit_ex(kcd);
kcd = NULL;
}
}