From 71fd0f7b7b0a136511949e25a185d90f5738749e Mon Sep 17 00:00:00 2001 From: Cian Jinks Date: Tue, 26 Oct 2021 20:29:01 +0100 Subject: Fix: Knife measurements broken when a cut point is in space Knife angle measurements were mis-aligned if a cut point was in space. Specifically, the arc drawing would not match with the cut line. Fixed by removing a correction for kcd->prev.cage. This correction was originally added for panning with measurements to work. In hindsight it is not needed and only introduces issues like this. --- source/blender/editors/mesh/editmesh_knife.c | 42 ++++++++-------------------- 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index d073f5f2ba4..826a9ce2b6b 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -184,8 +184,6 @@ typedef struct KnifeMeasureData { float cage[3]; float mval[2]; bool is_stored; - float corr_prev_cage[3]; /* "knife_start_cut" updates prev.cage breaking angle calculations, - * store correct version. */ } KnifeMeasureData; typedef struct KnifeUndoFrame { @@ -496,7 +494,7 @@ static void knifetool_draw_visible_distances(const KnifeTool_OpData *kcd) const int distance_precision = 4; /* Calculate distance and convert to string. */ - const float cut_len = len_v3v3(kcd->mdata.corr_prev_cage, kcd->curr.cage); + const float cut_len = len_v3v3(kcd->prev.cage, kcd->curr.cage); UnitSettings *unit = &kcd->scene->unit; if (unit->system == USER_UNIT_NONE) { @@ -703,7 +701,7 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd) else { tempkfv = tempkfe->v2; } - angle = angle_v3v3v3(kcd->mdata.corr_prev_cage, kcd->curr.cage, tempkfv->cageco); + angle = angle_v3v3v3(kcd->prev.cage, kcd->curr.cage, tempkfv->cageco); if (angle < min_angle) { min_angle = angle; kfe = tempkfe; @@ -717,7 +715,7 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd) ED_view3d_project_float_global(kcd->region, end, end_ss, V3D_PROJ_TEST_NOP); knifetool_draw_angle(kcd, - kcd->mdata.corr_prev_cage, + kcd->prev.cage, kcd->curr.cage, end, kcd->prev.mval, @@ -730,11 +728,11 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd) kfe = kcd->curr.edge; /* Check for most recent cut (if cage is part of previous cut). */ - if (!compare_v3v3(kfe->v1->cageco, kcd->mdata.corr_prev_cage, KNIFE_FLT_EPSBIG) && - !compare_v3v3(kfe->v2->cageco, kcd->mdata.corr_prev_cage, KNIFE_FLT_EPSBIG)) { + if (!compare_v3v3(kfe->v1->cageco, kcd->prev.cage, KNIFE_FLT_EPSBIG) && + !compare_v3v3(kfe->v2->cageco, kcd->prev.cage, KNIFE_FLT_EPSBIG)) { /* Determine acute angle. */ - float angle1 = angle_v3v3v3(kcd->mdata.corr_prev_cage, kcd->curr.cage, kfe->v1->cageco); - float angle2 = angle_v3v3v3(kcd->mdata.corr_prev_cage, kcd->curr.cage, kfe->v2->cageco); + float angle1 = angle_v3v3v3(kcd->prev.cage, kcd->curr.cage, kfe->v1->cageco); + float angle2 = angle_v3v3v3(kcd->prev.cage, kcd->curr.cage, kfe->v2->cageco); float angle; float *end; @@ -751,14 +749,8 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd) float end_ss[2]; ED_view3d_project_float_global(kcd->region, end, end_ss, V3D_PROJ_TEST_NOP); - knifetool_draw_angle(kcd, - kcd->mdata.corr_prev_cage, - kcd->curr.cage, - end, - kcd->prev.mval, - kcd->curr.mval, - end_ss, - angle); + knifetool_draw_angle( + kcd, kcd->prev.cage, kcd->curr.cage, end, kcd->prev.mval, kcd->curr.mval, end_ss, angle); } } @@ -852,10 +844,10 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd) kcd, kcd->curr.cage, kcd->prev.cage, end, kcd->curr.mval, kcd->prev.mval, end_ss, angle); } else if (kcd->mdata.is_stored && !kcd->prev.is_space) { - float angle = angle_v3v3v3(kcd->curr.cage, kcd->mdata.corr_prev_cage, kcd->mdata.cage); + float angle = angle_v3v3v3(kcd->curr.cage, kcd->prev.cage, kcd->mdata.cage); knifetool_draw_angle(kcd, kcd->curr.cage, - kcd->mdata.corr_prev_cage, + kcd->prev.cage, kcd->mdata.cage, kcd->curr.mval, kcd->prev.mval, @@ -2396,7 +2388,7 @@ static void knife_add_cut(KnifeTool_OpData *kcd) } /* Save values for angle drawing calculations. */ - copy_v3_v3(kcd->mdata.cage, kcd->mdata.corr_prev_cage); + copy_v3_v3(kcd->mdata.cage, kcd->prev.cage); copy_v2_v2(kcd->mdata.mval, kcd->prev.mval); kcd->mdata.is_stored = true; @@ -4525,16 +4517,6 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) kcd->init = kcd->curr; } - /* Preserve correct prev.cage for angle drawing calculations. */ - if (kcd->prev.edge == NULL && kcd->prev.vert == NULL) { - /* "knife_start_cut" moves prev.cage so needs to be recalculated. */ - /* Only occurs if prev was started on a face. */ - knifetool_recast_cageco(kcd, kcd->prev.mval, kcd->mdata.corr_prev_cage); - } - else { - copy_v3_v3(kcd->mdata.corr_prev_cage, kcd->prev.cage); - } - /* Freehand drawing is incompatible with cut-through. */ if (kcd->cut_through == false) { kcd->is_drag_hold = true; -- cgit v1.2.3