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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user