Blender V5.3
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"
16#include "BLI_enum_flags.hh"
18
20
21namespace blender {
22
27#define V3D_OP_TRACKBALLSIZE (1.1f)
28
29struct ARegion;
30struct Depsgraph;
31struct Dial;
32struct RegionView3D;
33struct Scene;
34struct ScrArea;
35struct View3D;
36struct ViewOpsData;
37struct bContext;
38struct Object;
39struct PointerRNA;
40struct rcti;
41struct wmEvent;
42struct wmKeyConfig;
43struct wmOperator;
44struct wmOperatorType;
45struct wmTimer;
46struct wmWindow;
47struct wmWindowManager;
48struct ViewLayer;
49
50enum eRegionView3D_View : char;
52enum eRegionView3D_Persp : char;
53
61
69
70/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
71enum {
72 VIEW_MODAL_CANCEL = 0, /* used for all view operations */
73 VIEW_MODAL_CONFIRM = 1, /* used for all view operations */
79};
80
99
102 const char *idname;
103 bool (*poll_fn)(bContext *C);
105 ViewOpsData *vod,
106 const wmEvent *event,
107 PointerRNA *ptr);
109 ViewOpsData *vod,
110 const eV3D_OpEvent event_code,
111 const int xy[2]);
112};
113
122 Depsgraph *depsgraph;
123
126
128 struct {
129
131
132 float ofs[3]; /* DOLLY, MOVE, ROTATE and ZOOM. */
133 float ofs_lock[2]; /* MOVE. */
134 float camdx, camdy; /* MOVE and ZOOM. */
135 float camzoom; /* ZOOM. */
136 float camroll; /* ROLL. */
137 bool cam_flip_x; /* FLIP X. */
138 float dist; /* ROTATE and ZOOM. */
139 float quat[4]; /* ROLL and ROTATE. */
140 eRegionView3D_Persp persp; /* ROTATE. */
141 eRegionView3D_View view; /* ROTATE. */
143
149
151
154 /* Offset used when "use_cursor_init" is false to simulate pressing in the middle of the
155 * region. */
158 int event_type;
159
161 float zfac;
162
164 float trackvec[3];
166 float mousevec[3];
167
169 Dial *dial;
171
173 struct {
174 int event_xy[2];
176 double time;
178
180 struct {
184 float viewquat[4];
186
189
190 float reverse;
191 bool axis_snap; /* view rotate only */
192
194 float dyn_ofs[3];
196
205
206 void init_context(bContext *C);
207 void state_backup();
208 void state_restore();
210 const wmEvent *event,
211 const ViewOpsType *nav_type,
212 const float dyn_ofs_override[3] = nullptr,
213 const bool use_cursor_init = false);
215
216 MEM_CXX_CLASS_ALLOC_FUNCS("ViewOpsData")
217};
218
219/* view3d_navigate.cc */
220
225
227 wmOperator *op,
228 const wmEvent *event,
229 const ViewOpsType *nav_type);
232
233void calctrackballvec(const rcti *rect, const int event_xy[2], float r_dir[3]);
234void viewmove_apply(ViewOpsData *vod, int x, int y);
235void view3d_orbit_apply_dyn_ofs(float r_ofs[3],
236 const float ofs_old[3],
237 const float viewquat_old[4],
238 const float viewquat_new[4],
239 const float dyn_ofs[3]);
240void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4]);
241bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]);
242
258float view3d_horizon_correct_quat(float quat[4],
259 const float horizon_plane[3],
260 bool horizon_plane_no_flip,
261 const float axis_fallback[3],
262 float angle_target,
263 float factor);
264
276float view3d_horizon_correct_quat_ease_out(float quat[4],
277 const float horizon_plane[3],
278 bool horizon_plane_no_flip,
279 float factor);
280
282
287
292 const wmEvent *event,
293 const ViewOpsType *nav_type,
294 const bool use_cursor_init);
299 View3D *v3d,
300 ARegion *region,
301 const float quat_[4],
303 eRegionView3D_ViewAxisRoll view_axis_roll,
304 eRegionView3D_Persp perspo,
305 const float *align_to_quat,
306 const int smooth_viewtx);
307
308/* view3d_navigate_dolly.cc */
309
312
314
315/* view3d_navigate_fly.cc */
316
317void fly_modal_keymap(wmKeyConfig *keyconf);
318void view3d_keymap(wmKeyConfig *keyconf);
320
321/* view3d_navigate_move.cc */
322
325
326extern const ViewOpsType ViewOpsType_move;
327
328/* view3d_navigate_ndof.cc */
329
330#ifdef WITH_INPUT_NDOF
331struct wmNDOFMotionData;
335void view3d_ndof_fly(const wmNDOFMotionData &ndof,
336 View3D *v3d,
337 RegionView3D *rv3d,
338 bool use_precision,
339 short protectflag,
340 bool *r_has_translate,
341 bool *r_has_rotate);
342void VIEW3D_OT_ndof_orbit(wmOperatorType *ot);
343void VIEW3D_OT_ndof_orbit_zoom(wmOperatorType *ot);
344void VIEW3D_OT_ndof_pan(wmOperatorType *ot);
345void VIEW3D_OT_ndof_all(wmOperatorType *ot);
346
347extern const ViewOpsType ViewOpsType_ndof_orbit;
348extern const ViewOpsType ViewOpsType_ndof_orbit_zoom;
349extern const ViewOpsType ViewOpsType_ndof_pan;
350extern const ViewOpsType ViewOpsType_ndof_all;
351#endif /* WITH_INPUT_NDOF */
352
353/* view3d_navigate_roll.cc */
354
356
357extern const ViewOpsType ViewOpsType_roll;
358
359/* view3d_navigate_rotate.cc */
360
363
365
366/* view3d_navigate_smoothview.cc */
367
375 const float *ofs, *quat, *dist, *lens;
376
378 const float *dyn_ofs;
379
381 const char *undo_str;
387};
388
392void ED_view3d_smooth_view_ex(const Depsgraph *depsgraph,
394 wmWindow *win,
395 ScrArea *area,
396 View3D *v3d,
397 ARegion *region,
398 int smooth_viewtx,
399 const V3D_SmoothParams *sview);
400
402 bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview);
403
416 const ScrArea *area,
417 const char *undo_str,
418 bool undo_grouped);
419
425
432void ED_view3d_smooth_view_force_finish_no_camera_lock(const Depsgraph *depsgraph,
434 wmWindow *win,
435 const Scene *scene,
436 View3D *v3d,
437 ARegion *region);
438
440
441/* view3d_navigate_view_all.cc */
442
449std::optional<Bounds<float3>> view3d_calc_minmax_visible(
450 Depsgraph *depsgraph, ScrArea *area, ARegion *region, bool use_all_regions, bool clip_bounds);
458std::optional<Bounds<float3>> view3d_calc_minmax_selected(Depsgraph *depsgraph,
459 ScrArea *area,
460 ARegion *region,
461 bool use_all_regions,
462 bool clip_bounds,
463 bool *r_do_zoom);
464
468bool view3d_calc_point_in_selected_bounds(Depsgraph *depsgraph,
469 struct ViewLayer *view_layer_eval,
470 const View3D *v3d,
471 const float3 &point,
472 const float scale_margin);
473
476
477/* view3d_navigate_view_axis.cc */
478
480
481/* view3d_navigate_view_camera.cc */
482
484
485/* view3d_navigate_view_center_cursor.cc */
486
488
489/* view3d_navigate_view_center_pick.cc */
490
492
493/* view3d_navigate_view_orbit.cc */
494
496
497extern const ViewOpsType ViewOpsType_orbit;
498
499/* view3d_navigate_view_pan.cc */
500
502
503extern const ViewOpsType ViewOpsType_pan;
504
505/* view3d_navigate_walk.cc */
506
507void walk_modal_keymap(wmKeyConfig *keyconf);
509
510/* view3d_navigate_zoom.cc */
511
514
515extern const ViewOpsType ViewOpsType_zoom;
516
517/* view3d_navigate_zoom_border.cc */
518
520
521} // namespace blender
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
Definition scene.h:133
ENUM_OPERATORS(Layer::Flags)
BMesh Iterators.
void VIEW3D_OT_view_axis(wmOperatorType *ot)
void VIEW3D_OT_view_selected(wmOperatorType *ot)
const ViewOpsType ViewOpsType_roll
void viewdolly_modal_keymap(wmKeyConfig *keyconf)
ViewOpsType ViewOpsType_dolly
void VIEW3D_OT_view_orbit(wmOperatorType *ot)
void VIEW3D_OT_smoothview(wmOperatorType *ot)
void VIEW3D_OT_zoom_border(wmOperatorType *ot)
void viewops_data_free(bContext *C, ViewOpsData *vod)
void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4])
void viewrotate_modal_keymap(wmKeyConfig *keyconf)
void viewmove_modal_keymap(wmKeyConfig *keyconf)
void view3d_operator_properties_common(wmOperatorType *ot, const enum eV3D_OpPropFlag flag)
ViewOpsData * viewops_data_create(bContext *C, const wmEvent *event, const ViewOpsType *nav_type, const bool use_cursor_init)
void VIEW3D_OT_view_all(wmOperatorType *ot)
void VIEW3D_OT_move(wmOperatorType *ot)
void ED_view3d_smooth_view_undo_end(bContext *C, const ScrArea *area, const char *undo_str, bool undo_grouped)
const ViewOpsType ViewOpsType_orbit
void VIEW3D_OT_rotate(wmOperatorType *ot)
void VIEW3D_OT_view_camera(wmOperatorType *ot)
bool view3d_zoom_or_dolly_or_rotation_poll(bContext *C)
const ViewOpsType ViewOpsType_pan
void VIEW3D_OT_zoom(wmOperatorType *ot)
const ViewOpsType ViewOpsType_move
VecBase< int32_t, 2 > int2
wmOperatorStatus view3d_navigate_invoke_impl(bContext *C, wmOperator *op, const wmEvent *event, const ViewOpsType *nav_type)
void axis_set_view(bContext *C, View3D *v3d, ARegion *region, const float quat_[4], eRegionView3D_View view, eRegionView3D_ViewAxisRoll view_axis_roll, eRegionView3D_Persp perspo, const float *align_to_quat, const int smooth_viewtx)
bool view3d_location_poll(bContext *C)
void viewzoom_modal_keymap(wmKeyConfig *keyconf)
const ViewOpsType ViewOpsType_rotate
void view3d_keymap(wmKeyConfig *keyconf)
void VIEW3D_OT_dolly(wmOperatorType *ot)
void ED_view3d_smooth_view_force_finish_no_camera_lock(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, const Scene *scene, View3D *v3d, ARegion *region)
bool view3d_calc_point_in_selected_bounds(Depsgraph *depsgraph, struct ViewLayer *view_layer_eval, const View3D *v3d, const float3 &point, const float scale_margin)
@ VIEW_CONFIRM
Definition image_ops.cc:652
void VIEW3D_OT_view_center_pick(wmOperatorType *ot)
void calctrackballvec(const rcti *rect, const int event_xy[2], float r_dir[3])
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)
std::optional< Bounds< float3 > > view3d_calc_minmax_visible(Depsgraph *depsgraph, ScrArea *area, ARegion *region, bool use_all_regions, bool clip_bounds)
void VIEW3D_OT_fly(wmOperatorType *ot)
bool view3d_rotation_poll(bContext *C)
std::optional< Bounds< float3 > > view3d_calc_minmax_selected(Depsgraph *depsgraph, ScrArea *area, ARegion *region, bool use_all_regions, bool clip_bounds, bool *r_do_zoom)
@ VIEWOPS_FLAG_ZOOM_TO_MOUSE
@ VIEWOPS_FLAG_DEPTH_NAVIGATE
@ VIEWOPS_FLAG_INIT_ZFAC
@ VIEWOPS_FLAG_ORBIT_SELECT
@ VIEWOPS_FLAG_PERSP_ENSURE
void VIEW3D_OT_view_pan(wmOperatorType *ot)
bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
@ VIEWROT_MODAL_AXIS_SNAP_ENABLE
@ VIEWROT_MODAL_AXIS_SNAP_DISABLE
@ VIEWROT_MODAL_SWITCH_MOVE
@ VIEWROT_MODAL_SWITCH_ZOOM
@ VIEWROT_MODAL_SWITCH_ROTATE
void ED_view3d_smooth_view_undo_begin(bContext *C, const ScrArea *area)
void viewmove_apply(ViewOpsData *vod, int x, int y)
void view3d_navigate_cancel_fn(bContext *C, wmOperator *op)
bool view3d_zoom_or_dolly_poll(bContext *C)
const ViewOpsType ViewOpsType_zoom
void VIEW3D_OT_view_center_cursor(wmOperatorType *ot)
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
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])
@ V3D_OP_PROP_USE_ALL_REGIONS
@ V3D_OP_PROP_USE_MOUSE_INIT
void VIEW3D_OT_view_roll(wmOperatorType *ot)
void VIEW3D_OT_walk(wmOperatorType *ot)
void fly_modal_keymap(wmKeyConfig *keyconf)
VecBase< float, 3 > float3
void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
float view3d_horizon_correct_quat(float quat[4], const float horizon_plane[3], const bool horizon_plane_no_flip, const float axis_fallback[3], const float angle_target, const float factor)
float view3d_horizon_correct_quat_ease_out(float quat[4], const float horizon_plane[3], const bool horizon_plane_no_flip, const float factor)
void walk_modal_keymap(wmKeyConfig *keyconf)
wmOperatorStatus view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event)
eRegionView3D_Persp persp_with_auto_persp_applied
eRegionView3D_ViewAxisRoll view_axis_roll
const ViewOpsType * nav_type
struct blender::ViewOpsData::@013213354235237006300365026145043140112021271057 prev
void end_navigation(bContext *C)
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)
struct blender::ViewOpsData::@337054214024237015354033064215073157327063021373 curr
bool(*) poll_fn(bContext *C)
wmOperatorStatus(*) init_fn(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr)
wmOperatorStatus(*) apply_fn(bContext *C, ViewOpsData *vod, const eV3D_OpEvent event_code, const int xy[2])