Blender
V4.3
source
blender
editors
space_view3d
view3d_navigate_view_center_cursor.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
9
#include "
MEM_guardedalloc.h
"
10
11
#include "
BLI_math_vector.h
"
12
13
#include "
BKE_context.hh
"
14
15
#include "
WM_api.hh
"
16
17
#include "
view3d_intern.hh
"
18
19
#include "
view3d_navigate.hh
"
/* own include */
20
21
/* -------------------------------------------------------------------- */
25
static
int
viewcenter_cursor_exec
(
bContext
*C,
wmOperator
*op)
26
{
27
View3D
*v3d =
CTX_wm_view3d
(C);
28
RegionView3D
*rv3d =
CTX_wm_region_view3d
(C);
29
Scene
*scene =
CTX_data_scene
(C);
30
31
if
(rv3d) {
32
ARegion
*region =
CTX_wm_region
(C);
33
const
int
smooth_viewtx =
WM_operator_smooth_viewtx_get
(op);
34
35
ED_view3d_smooth_view_force_finish
(C, v3d, region);
36
37
/* non camera center */
38
float
new_ofs[3];
39
negate_v3_v3
(new_ofs, scene->cursor.location);
40
41
V3D_SmoothParams
sview = {
nullptr
};
42
sview.
ofs
= new_ofs;
43
sview.
undo_str
= op->
type
->
name
;
44
ED_view3d_smooth_view
(C, v3d, region, smooth_viewtx, &sview);
45
46
/* Smooth view does view-lock #RV3D_BOXVIEW copy. */
47
}
48
49
return
OPERATOR_FINISHED
;
50
}
51
52
void
VIEW3D_OT_view_center_cursor
(
wmOperatorType
*
ot
)
53
{
54
/* identifiers */
55
ot
->
name
=
"Center View to Cursor"
;
56
ot
->
description
=
"Center the view so that the cursor is in the middle of the view"
;
57
ot
->
idname
=
"VIEW3D_OT_view_center_cursor"
;
58
59
/* api callbacks */
60
ot
->
exec
=
viewcenter_cursor_exec
;
61
ot
->
poll
=
view3d_location_poll
;
62
63
/* flags */
64
ot
->
flag
= 0;
65
}
66
BKE_context.hh
CTX_data_scene
Scene * CTX_data_scene(const bContext *C)
Definition
blenkernel/intern/context.cc:1111
CTX_wm_region_view3d
RegionView3D * CTX_wm_region_view3d(const bContext *C)
Definition
blenkernel/intern/context.cc:806
CTX_wm_region
ARegion * CTX_wm_region(const bContext *C)
Definition
blenkernel/intern/context.cc:762
CTX_wm_view3d
View3D * CTX_wm_view3d(const bContext *C)
Definition
blenkernel/intern/context.cc:797
BLI_math_vector.h
negate_v3_v3
MINLINE void negate_v3_v3(float r[3], const float a[3])
Definition
math_vector_inline.c:778
OPERATOR_FINISHED
@ OPERATOR_FINISHED
Definition
DNA_windowmanager_types.h:661
MEM_guardedalloc.h
Read Guarded memory(de)allocation.
WM_api.hh
ARegion
Definition
DNA_screen_types.h:474
RegionView3D
Definition
DNA_view3d_types.h:32
Scene
Definition
DNA_scene_types.h:1988
V3D_SmoothParams
Definition
view3d_navigate.hh:309
V3D_SmoothParams::undo_str
const char * undo_str
Definition
view3d_navigate.hh:317
V3D_SmoothParams::ofs
const float * ofs
Definition
view3d_navigate.hh:311
View3D
Definition
DNA_view3d_types.h:279
bContext
Definition
blenkernel/intern/context.cc:61
wmOperatorType
Definition
WM_types.hh:988
wmOperatorType::name
const char * name
Definition
WM_types.hh:990
wmOperatorType::flag
short flag
Definition
WM_types.hh:1110
wmOperatorType::poll
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition
WM_types.hh:1042
wmOperatorType::idname
const char * idname
Definition
WM_types.hh:992
wmOperatorType::exec
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition
WM_types.hh:1006
wmOperatorType::description
const char * description
Definition
WM_types.hh:996
wmOperator
Definition
DNA_windowmanager_types.h:623
wmOperator::type
struct wmOperatorType * type
Definition
DNA_windowmanager_types.h:634
view3d_intern.hh
view3d_location_poll
bool view3d_location_poll(bContext *C)
Definition
view3d_navigate.cc:583
view3d_navigate.hh
ED_view3d_smooth_view
void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
Definition
view3d_navigate_smoothview.cc:385
ED_view3d_smooth_view_force_finish
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
Definition
view3d_navigate_smoothview.cc:564
VIEW3D_OT_view_center_cursor
void VIEW3D_OT_view_center_cursor(wmOperatorType *ot)
Definition
view3d_navigate_view_center_cursor.cc:52
viewcenter_cursor_exec
static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
Definition
view3d_navigate_view_center_cursor.cc:25
ot
wmOperatorType * ot
Definition
wm_files.cc:4125
WM_operator_smooth_viewtx_get
int WM_operator_smooth_viewtx_get(const wmOperator *op)
Definition
wm_operators.cc:1076
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0