Blender V5.0
view3d_navigate.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include <optional>
12
13#include "MEM_guardedalloc.h"
14
15#include "BLI_bounds_types.hh"
17#include "BLI_utildefines.h"
18
20
25#define V3D_OP_TRACKBALLSIZE (1.1f)
26
27struct ARegion;
28struct Depsgraph;
29struct Dial;
30struct RegionView3D;
31struct Scene;
32struct ScrArea;
33struct View3D;
34struct ViewOpsData;
35struct bContext;
36struct Object;
37struct PointerRNA;
38struct rcti;
39struct wmEvent;
40struct wmKeyConfig;
41struct wmOperator;
42struct wmOperatorType;
43struct wmTimer;
44struct wmWindow;
45struct wmWindowManager;
46struct ViewLayer;
47
55
63
64/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
65enum {
66 VIEW_MODAL_CANCEL = 0, /* used for all view operations */
67 VIEW_MODAL_CONFIRM = 1, /* used for all view operations */
73};
74
93
96 const char *idname;
97 bool (*poll_fn)(bContext *C);
99 ViewOpsData *vod,
100 const wmEvent *event,
101 PointerRNA *ptr);
103 ViewOpsData *vod,
104 const eV3D_OpEvent event_code,
105 const int xy[2]);
106};
107
116 Depsgraph *depsgraph;
117
120
122 struct {
123
125
126 float ofs[3]; /* DOLLY, MOVE, ROTATE and ZOOM. */
127 float ofs_lock[2]; /* MOVE. */
128 float camdx, camdy; /* MOVE and ZOOM. */
129 float camzoom; /* ZOOM. */
130 float dist; /* ROTATE and ZOOM. */
131 float quat[4]; /* ROLL and ROTATE. */
132 char persp; /* ROTATE. */
133 char view; /* ROTATE. */
134 char view_axis_roll; /* ROTATE. */
135
141
143
146 /* Offset used when "use_cursor_init" is false to simulate pressing in the middle of the
147 * region. */
151
153 float zfac;
154
156 float trackvec[3];
158 float mousevec[3];
159
163
165 struct {
166 int event_xy[2];
168 double time;
170
172 struct {
176 float viewquat[4];
178
181
182 float reverse;
183 bool axis_snap; /* view rotate only */
184
186 float dyn_ofs[3];
188
197
198 void init_context(bContext *C);
199 void state_backup();
200 void state_restore();
202 const wmEvent *event,
203 const ViewOpsType *nav_type,
204 const float dyn_ofs_override[3] = nullptr,
205 const bool use_cursor_init = false);
207
208 MEM_CXX_CLASS_ALLOC_FUNCS("ViewOpsData")
209};
210
211/* view3d_navigate.cc */
212
217
219 wmOperator *op,
220 const wmEvent *event,
221 const ViewOpsType *nav_type);
224
225void calctrackballvec(const rcti *rect, const int event_xy[2], float r_dir[3]);
226void viewmove_apply(ViewOpsData *vod, int x, int y);
227void view3d_orbit_apply_dyn_ofs(float r_ofs[3],
228 const float ofs_old[3],
229 const float viewquat_old[4],
230 const float viewquat_new[4],
231 const float dyn_ofs[3]);
232void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4]);
233bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]);
234
236
241
246 const wmEvent *event,
247 const ViewOpsType *nav_type,
248 const bool use_cursor_init);
253 View3D *v3d,
254 ARegion *region,
255 const float quat_[4],
256 char view,
257 char view_axis_roll,
258 int perspo,
259 const float *align_to_quat,
260 const int smooth_viewtx);
261
262/* view3d_navigate_dolly.cc */
263
266
268
269/* view3d_navigate_fly.cc */
270
271void fly_modal_keymap(wmKeyConfig *keyconf);
272void view3d_keymap(wmKeyConfig *keyconf);
274
275/* view3d_navigate_move.cc */
276
279
280extern const ViewOpsType ViewOpsType_move;
281
282/* view3d_navigate_ndof.cc */
283
284#ifdef WITH_INPUT_NDOF
285struct wmNDOFMotionData;
289void view3d_ndof_fly(const wmNDOFMotionData &ndof,
290 View3D *v3d,
291 RegionView3D *rv3d,
292 bool use_precision,
293 short protectflag,
294 bool *r_has_translate,
295 bool *r_has_rotate);
296void VIEW3D_OT_ndof_orbit(wmOperatorType *ot);
297void VIEW3D_OT_ndof_orbit_zoom(wmOperatorType *ot);
298void VIEW3D_OT_ndof_pan(wmOperatorType *ot);
299void VIEW3D_OT_ndof_all(wmOperatorType *ot);
300
301extern const ViewOpsType ViewOpsType_ndof_orbit;
302extern const ViewOpsType ViewOpsType_ndof_orbit_zoom;
303extern const ViewOpsType ViewOpsType_ndof_pan;
304extern const ViewOpsType ViewOpsType_ndof_all;
305#endif /* WITH_INPUT_NDOF */
306
307/* view3d_navigate_roll.cc */
308
310
311extern const ViewOpsType ViewOpsType_roll;
312
313/* view3d_navigate_rotate.cc */
314
317
319
320/* view3d_navigate_smoothview.cc */
321
329 const float *ofs, *quat, *dist, *lens;
330
332 const float *dyn_ofs;
333
335 const char *undo_str;
341};
342
346void ED_view3d_smooth_view_ex(const Depsgraph *depsgraph,
347 wmWindowManager *wm,
348 wmWindow *win,
349 ScrArea *area,
350 View3D *v3d,
351 ARegion *region,
352 int smooth_viewtx,
353 const V3D_SmoothParams *sview);
354
356 bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview);
357
370 const ScrArea *area,
371 const char *undo_str,
372 bool undo_grouped);
373
379
387 wmWindowManager *wm,
388 wmWindow *win,
389 const Scene *scene,
390 View3D *v3d,
391 ARegion *region);
392
394
395/* view3d_navigate_view_all.cc */
396
403std::optional<blender::Bounds<blender::float3>> view3d_calc_minmax_visible(
404 Depsgraph *depsgraph, ScrArea *area, ARegion *region, bool use_all_regions, bool clip_bounds);
412std::optional<blender::Bounds<blender::float3>> view3d_calc_minmax_selected(Depsgraph *depsgraph,
413 ScrArea *area,
414 ARegion *region,
415 bool use_all_regions,
416 bool clip_bounds,
417 bool *r_do_zoom);
418
423 struct ViewLayer *view_layer_eval,
424 const View3D *v3d,
425 const blender::float3 &point,
426 const float scale_margin);
427
430
431/* view3d_navigate_view_axis.cc */
432
434
435/* view3d_navigate_view_camera.cc */
436
438
439/* view3d_navigate_view_center_cursor.cc */
440
442
443/* view3d_navigate_view_center_pick.cc */
444
446
447/* view3d_navigate_view_orbit.cc */
448
450
451extern const ViewOpsType ViewOpsType_orbit;
452
453/* view3d_navigate_view_pan.cc */
454
456
457extern const ViewOpsType ViewOpsType_pan;
458
459/* view3d_navigate_walk.cc */
460
461void walk_modal_keymap(wmKeyConfig *keyconf);
463
464/* view3d_navigate_zoom.cc */
465
468
469extern const ViewOpsType ViewOpsType_zoom;
470
471/* view3d_navigate_zoom_border.cc */
472
#define ENUM_OPERATORS(_type, _max)
static AppView * view
Read Guarded memory(de)allocation.
#define C
Definition RandGen.cpp:29
BPy_StructRNA * depsgraph
@ VIEW_CONFIRM
Definition image_ops.cc:601
@ VIEW_PASS
Definition image_ops.cc:599
@ VIEW_APPLY
Definition image_ops.cc:600
VecBase< int32_t, 2 > int2
VecBase< float, 3 > float3
static void init(bNodeTree *, bNode *node)
const char * undo_str
const float * dyn_ofs
const ViewOpsType * nav_type
char persp_with_auto_persp_applied
void end_navigation(bContext *C)
eViewOpsFlag viewops_flag
bool use_dyn_ofs_ortho_correction
Depsgraph * depsgraph
blender::int2 event_xy
blender::int2 event_xy_offset
struct ViewOpsData::@041211063176270354313167244105136234141004235041 curr
struct ViewOpsData::@244345216304223004112237167211144027240265370072 prev
RegionView3D * rv3d
void init_navigation(bContext *C, const wmEvent *event, const ViewOpsType *nav_type, const float dyn_ofs_override[3]=nullptr, const bool use_cursor_init=false)
void init_context(bContext *C)
const char * idname
wmOperatorStatus(* apply_fn)(bContext *C, ViewOpsData *vod, const eV3D_OpEvent event_code, const int xy[2])
eViewOpsFlag flag
wmOperatorStatus(* init_fn)(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr)
bool(* poll_fn)(bContext *C)
void ED_view3d_smooth_view_undo_begin(bContext *C, const ScrArea *area)
void view3d_navigate_cancel_fn(bContext *C, wmOperator *op)
bool view3d_calc_point_in_selected_bounds(Depsgraph *depsgraph, struct ViewLayer *view_layer_eval, const View3D *v3d, const blender::float3 &point, const float scale_margin)
void viewmove_modal_keymap(wmKeyConfig *keyconf)
const ViewOpsType ViewOpsType_zoom
void view3d_keymap(wmKeyConfig *keyconf)
void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
void VIEW3D_OT_view_roll(wmOperatorType *ot)
void VIEW3D_OT_view_axis(wmOperatorType *ot)
wmOperatorStatus view3d_navigate_invoke_impl(bContext *C, wmOperator *op, const wmEvent *event, const ViewOpsType *nav_type)
const ViewOpsType ViewOpsType_pan
void ED_view3d_smooth_view_force_finish_no_camera_lock(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, const Scene *scene, View3D *v3d, ARegion *region)
void viewops_data_free(bContext *C, ViewOpsData *vod)
const ViewOpsType ViewOpsType_orbit
ViewOpsData * viewops_data_create(bContext *C, const wmEvent *event, const ViewOpsType *nav_type, const bool use_cursor_init)
void VIEW3D_OT_view_orbit(wmOperatorType *ot)
wmOperatorStatus view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event)
void fly_modal_keymap(wmKeyConfig *keyconf)
void view3d_orbit_apply_dyn_ofs(float r_ofs[3], const float ofs_old[3], const float viewquat_old[4], const float viewquat_new[4], const float dyn_ofs[3])
eViewOpsFlag
@ VIEWOPS_FLAG_NONE
@ VIEWOPS_FLAG_ORBIT_SELECT
@ VIEWOPS_FLAG_DEPTH_NAVIGATE
@ VIEWOPS_FLAG_INIT_ZFAC
@ VIEWOPS_FLAG_ZOOM_TO_MOUSE
@ VIEWOPS_FLAG_PERSP_ENSURE
void view3d_operator_properties_common(wmOperatorType *ot, const eV3D_OpPropFlag flag)
bool view3d_rotation_poll(bContext *C)
bool view3d_location_poll(bContext *C)
void ED_view3d_smooth_view_ex(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, ScrArea *area, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
void VIEW3D_OT_walk(wmOperatorType *ot)
void VIEW3D_OT_zoom_border(wmOperatorType *ot)
void VIEW3D_OT_rotate(wmOperatorType *ot)
const ViewOpsType ViewOpsType_rotate
eV3D_OpEvent
@ VIEW_CANCEL
ViewOpsType ViewOpsType_dolly
bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
const ViewOpsType ViewOpsType_roll
void viewmove_apply(ViewOpsData *vod, int x, int y)
void calctrackballvec(const rcti *rect, const int event_xy[2], float r_dir[3])
void VIEW3D_OT_view_pan(wmOperatorType *ot)
eV3D_OpPropFlag
@ V3D_OP_PROP_USE_MOUSE_INIT
@ V3D_OP_PROP_DELTA
@ V3D_OP_PROP_USE_ALL_REGIONS
@ V3D_OP_PROP_MOUSE_CO
void axis_set_view(bContext *C, View3D *v3d, ARegion *region, const float quat_[4], char view, char view_axis_roll, int perspo, const float *align_to_quat, const int smooth_viewtx)
void VIEW3D_OT_view_all(wmOperatorType *ot)
void viewzoom_modal_keymap(wmKeyConfig *keyconf)
std::optional< blender::Bounds< blender::float3 > > view3d_calc_minmax_selected(Depsgraph *depsgraph, ScrArea *area, ARegion *region, bool use_all_regions, bool clip_bounds, bool *r_do_zoom)
void VIEW3D_OT_view_selected(wmOperatorType *ot)
bool view3d_zoom_or_dolly_or_rotation_poll(bContext *C)
void viewrotate_modal_keymap(wmKeyConfig *keyconf)
void VIEW3D_OT_zoom(wmOperatorType *ot)
void VIEW3D_OT_view_camera(wmOperatorType *ot)
void viewdolly_modal_keymap(wmKeyConfig *keyconf)
const ViewOpsType ViewOpsType_move
void VIEW3D_OT_view_center_pick(wmOperatorType *ot)
void VIEW3D_OT_view_center_cursor(wmOperatorType *ot)
void walk_modal_keymap(wmKeyConfig *keyconf)
void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4])
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
@ VIEWROT_MODAL_SWITCH_ROTATE
@ VIEWROT_MODAL_AXIS_SNAP_ENABLE
@ VIEW_MODAL_CANCEL
@ VIEWROT_MODAL_SWITCH_MOVE
@ VIEW_MODAL_CONFIRM
@ VIEWROT_MODAL_SWITCH_ZOOM
@ VIEWROT_MODAL_AXIS_SNAP_DISABLE
void VIEW3D_OT_fly(wmOperatorType *ot)
std::optional< blender::Bounds< blender::float3 > > view3d_calc_minmax_visible(Depsgraph *depsgraph, ScrArea *area, ARegion *region, bool use_all_regions, bool clip_bounds)
void VIEW3D_OT_move(wmOperatorType *ot)
bool view3d_zoom_or_dolly_poll(bContext *C)
void VIEW3D_OT_smoothview(wmOperatorType *ot)
void ED_view3d_smooth_view_undo_end(bContext *C, const ScrArea *area, const char *undo_str, bool undo_grouped)
void VIEW3D_OT_dolly(wmOperatorType *ot)
int xy[2]
Definition wm_draw.cc:178
PointerRNA * ptr
Definition wm_files.cc:4238
wmOperatorType * ot
Definition wm_files.cc:4237
uint8_t flag
Definition wm_window.cc:145