diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-23 18:58:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-23 18:58:23 +0400 |
commit | c96ab45324e83ff27229f71e43bb112cec14da3a (patch) | |
tree | 1d71304f7e7d34cb23d46eca026ad68009d587d1 /source/blender/editors/space_view3d/view3d_ruler.c | |
parent | a7f5f6caab59980a08c20a7932bd0e2d5a0d05d2 (diff) |
fix for issues with ruler
- disabling ruler snap wasn't setting the points depth back to its previous value before snapping.
- adding a new ruler uses the depth of the previous active ruler (fallback to view center as before)
- deleting the ruler now sets the prev/next ruler active.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_ruler.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ruler.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 49094cdb9c4..d6faa0b4221 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -156,6 +156,7 @@ typedef struct RulerInfo { int flag; int snap_flag; int state; + float drag_start_co[3]; /* --- */ ARegion *ar; @@ -675,6 +676,8 @@ static bool view3d_ruler_item_mousemove(bContext *C, RulerInfo *ruler_info, cons if (ruler_item) { float *co = ruler_item->co[ruler_item->co_index]; + /* restore the initial depth */ + copy_v3_v3(co, ruler_info->drag_start_co); view3d_ruler_item_project(ruler_info, co, mval); if (do_thickness && ruler_item->co_index != 1) { const float mval_fl[2] = {UNPACK2(mval)}; @@ -793,6 +796,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) (ruler_info->items.first == NULL)) { /* Create new line */ + RulerItem *ruler_item_prev = ruler_item_active_get(ruler_info); RulerItem *ruler_item; /* check if we want to drag an existing point or add a new one */ ruler_info->state = RULER_STATE_DRAG; @@ -800,7 +804,15 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) ruler_item = ruler_item_add(ruler_info); ruler_item_active_set(ruler_info, ruler_item); - negate_v3_v3(ruler_item->co[0], rv3d->ofs); + /* initial depth either previous ruler, view offset */ + if (ruler_item_prev) { + copy_v3_v3(ruler_info->drag_start_co, ruler_item_prev->co[ruler_item_prev->co_index]); + } + else { + negate_v3_v3(ruler_info->drag_start_co, rv3d->ofs); + } + + copy_v3_v3(ruler_item->co[0], ruler_info->drag_start_co); view3d_ruler_item_project(ruler_info, ruler_item->co[0], event->mval); copy_v3_v3(ruler_item->co[2], ruler_item->co[0]); @@ -849,6 +861,10 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) ruler_item_active_set(ruler_info, ruler_item_pick); ruler_item_pick->co_index = co_index; ruler_info->state = RULER_STATE_DRAG; + + /* store the initial depth */ + copy_v3_v3(ruler_info->drag_start_co, ruler_item_pick->co[ruler_item_pick->co_index]); + do_draw = true; } } @@ -911,8 +927,9 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) if (ruler_info->state == RULER_STATE_NORMAL) { RulerItem *ruler_item = ruler_item_active_get(ruler_info); if (ruler_item) { + RulerItem *ruler_item_other = ruler_item->prev ? ruler_item->prev : ruler_item->next; ruler_item_remove(ruler_info, ruler_item); - ruler_info->item_active = -1; + ruler_item_active_set(ruler_info, ruler_item_other); do_draw = true; } } |