diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-14 18:46:59 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-14 18:46:59 +0400 |
commit | d92e32e4e784491941e028b12fbfa236fa1843a8 (patch) | |
tree | e67ef8daa578746bbfacaa8fb1afbaf819667b43 /source/blender | |
parent | 93d7e3b44282ddd9c4d1ec2fc143c71c58210cd5 (diff) |
use floats for knife tool internal mouse coord.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index cac8bdb3727..f822b398003 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -137,7 +137,8 @@ typedef struct KnifePosData { typedef struct KnifeTool_OpData { ARegion *ar; /* region that knifetool was activated in */ void *draw_handle; /* for drawing preview loop */ - ViewContext vc; + ViewContext vc; /* note: _don't_ use 'mval', instead use the one we define below */ + float mval[2]; /* mouse value with snapping applied */ //bContext *C; Object *ob; @@ -245,8 +246,7 @@ static void knife_pos_data_clear(KnifePosData *kpd) kpd->vert = NULL; kpd->edge = NULL; kpd->bmface = NULL; - kpd->mval[0] = 0.0f; - kpd->mval[1] = 0.0f; + zero_v2(kpd->mval); } static ListBase *knife_empty_list(KnifeTool_OpData *kcd) @@ -1747,7 +1747,7 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo return NULL; } -/* update both kcd->curr.mval and kcd->vc.mval to snap to required angle */ +/* update both kcd->curr.mval and kcd->mval to snap to required angle */ static void knife_snap_angle(KnifeTool_OpData *kcd) { float dx, dy; @@ -1784,16 +1784,14 @@ static void knife_snap_angle(KnifeTool_OpData *kcd) kcd->curr.mval[0] = kcd->prev.mval[0]; } - kcd->vc.mval[0] = round_ftoi(kcd->curr.mval[0]); - kcd->vc.mval[1] = round_ftoi(kcd->curr.mval[1]); + copy_v2_v2(kcd->mval, kcd->curr.mval); } /* update active knife edge/vert pointers */ static int knife_update_active(KnifeTool_OpData *kcd) { knife_pos_data_clear(&kcd->curr); - kcd->curr.mval[0] = (float)kcd->vc.mval[0]; - kcd->curr.mval[1] = (float)kcd->vc.mval[1]; + copy_v2_v2(kcd->curr.mval, kcd->mval); if (kcd->angle_snapping != ANGLE_FREE && kcd->mode == MODE_DRAGGING) knife_snap_angle(kcd); @@ -2936,17 +2934,22 @@ static void cage_mapped_verts_callback(void *userData, int index, const float co } } -static void knifetool_update_mval(KnifeTool_OpData *kcd, const int mval_i[2]) +static void knifetool_update_mval(KnifeTool_OpData *kcd, const float mval[2]) { knife_recalc_projmat(kcd); - kcd->vc.mval[0] = mval_i[0]; - kcd->vc.mval[1] = mval_i[1]; + copy_v2_v2(kcd->mval, mval); if (knife_update_active(kcd)) { ED_region_tag_redraw(kcd->ar); } } +static void knifetool_update_mval_i(KnifeTool_OpData *kcd, const int mval_i[2]) +{ + float mval[2] = {UNPACK2(mval_i)}; + knifetool_update_mval(kcd, mval); +} + /* called when modal loop selection gets set up... */ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd, const bool only_select, const bool cut_through) @@ -3038,8 +3041,7 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event) WM_cursor_modal(CTX_wm_window(C), BC_KNIFECURSOR); WM_event_add_modal_handler(C, op); - kcd = op->customdata; - knifetool_update_mval(kcd, event->mval); + knifetool_update_mval_i(kcd, event->mval); knife_update_header(C, kcd); @@ -3232,7 +3234,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) case MOUSEMOVE: /* mouse moved somewhere to select another loop */ if (kcd->mode != MODE_PANNING) { - knifetool_update_mval(kcd, event->mval); + knifetool_update_mval_i(kcd, event->mval); } break; @@ -3242,7 +3244,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) if (do_refresh) { /* we don't really need to update mval, * but this happens to be the best way to refresh at the moment */ - knifetool_update_mval(kcd, event->mval); + knifetool_update_mval_i(kcd, event->mval); } /* keep going until the user confirms */ |