diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-25 05:11:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-25 05:11:16 +0400 |
commit | 00e3aa529edfbd7b5693b15d9fb1d5e0c52ee336 (patch) | |
tree | 26f9324fc19772f6180d4aaee63b16d36b706024 /source | |
parent | ceb3225db77c5a86b8cb8cce555251c1dffdd033 (diff) |
patch [#34763] Center the View to the ZDepth Position under the Mouse Cursor
from Ralf Holzemer (cheleb)
use Fkey in object mode (since its a mode-less fly).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 36 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 2 |
3 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 9d9dd0535ff..8b21364a1cc 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2665,6 +2665,42 @@ void VIEW3D_OT_view_center_cursor(wmOperatorType *ot) ot->flag = 0; } +static int viewcenter_pick_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +{ + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + + if (rv3d) { + float new_ofs[3]; + + view3d_operator_needs_opengl(C); + + if (ED_view3d_autodist(scene, ar, v3d, event->mval, new_ofs, false)) { + negate_v3(new_ofs); + view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, NULL, NULL); + } + } + + return OPERATOR_FINISHED; +} + +void VIEW3D_OT_view_center_pick(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Center View to Mouse"; + ot->description = "Center the view to the ZDepth Position under the Mouse Cursor"; + ot->idname = "VIEW3D_OT_view_center_pick"; + + /* api callbacks */ + ot->invoke = viewcenter_pick_invoke; + ot->poll = ED_operator_view3d_active; + + /* flags */ + ot->flag = 0; +} + static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was view3d_home() in 2.4x */ { Scene *scene = CTX_data_scene(C); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 11cd0fdb1d7..3e79696f209 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -86,6 +86,7 @@ void VIEW3D_OT_view_selected(struct wmOperatorType *ot); void VIEW3D_OT_view_lock_clear(struct wmOperatorType *ot); void VIEW3D_OT_view_lock_to_active(struct wmOperatorType *ot); void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot); +void VIEW3D_OT_view_center_pick(struct wmOperatorType *ot); void VIEW3D_OT_view_center_camera(struct wmOperatorType *ot); void VIEW3D_OT_view_pan(struct wmOperatorType *ot); void VIEW3D_OT_view_persportho(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index e567ebda4b7..8f267522e5b 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -146,6 +146,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_view_lock_clear); WM_operatortype_append(VIEW3D_OT_view_lock_to_active); WM_operatortype_append(VIEW3D_OT_view_center_cursor); + WM_operatortype_append(VIEW3D_OT_view_center_pick); WM_operatortype_append(VIEW3D_OT_view_center_camera); WM_operatortype_append(VIEW3D_OT_select); WM_operatortype_append(VIEW3D_OT_select_border); @@ -245,6 +246,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_camera", HOMEKEY, KM_PRESS, 0, 0); /* only with camera view */ WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_cursor", HOMEKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_pick", FKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "center", FALSE); /* only without camera view */ |