diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 2ae638b22e4..d2f53a20451 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4607,7 +4607,7 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2]) Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d = CTX_wm_region_view3d(C); + RegionView3D *rv3d = ar->regiondata; bool flip; bool depth_used = false; @@ -4642,9 +4642,28 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - float *fp = ED_view3d_cursor3d_get(scene, v3d); - ED_view3d_cursor3d_position(C, fp, mval); + float *fp_curr = ED_view3d_cursor3d_get(scene, v3d); + float fp_prev[3]; + + copy_v3_v3(fp_prev, fp_curr); + + ED_view3d_cursor3d_position(C, fp_curr, mval); + + /* offset the cursor lock to avoid jumping to new offset */ + if (v3d->ob_centre_cursor) { + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + + float co_curr[2], co_prev[2]; + + if ((ED_view3d_project_float_global(ar, fp_prev, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && + (ED_view3d_project_float_global(ar, fp_curr, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) + { + rv3d->ofs_lock[0] += (co_curr[0] - co_prev[0]) / (ar->winx * 0.5f); + rv3d->ofs_lock[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f); + } + } if (v3d && v3d->localvd) WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); @@ -4670,7 +4689,7 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot) /* api callbacks */ ot->invoke = view3d_cursor3d_invoke; - ot->poll = ED_operator_view3d_active; + ot->poll = ED_operator_region_view3d_active; /* flags */ // ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; |