69 if (use_zoom_to_mouse) {
87 this->
v3d =
static_cast<View3D *
>(this->
area->spacedata.first);
103 this->
init.view_axis_roll =
rv3d->view_axis_roll;
121 this->
rv3d->camdx = this->
init.camdx;
122 this->
rv3d->camdy = this->
init.camdy;
144 this->
rv3d->camzoom = this->
init.camzoom;
164 this->
rv3d->persp = this->
init.persp;
166 this->
rv3d->view_axis_roll = this->
init.view_axis_roll;
180 const float dyn_ofs_override[3],
201 if (dyn_ofs_override) {
208 if (use_depth_last) {
212 float fallback_depth_pt[3];
231 const float dyn_ofs_override[3],
232 const bool use_cursor_init)
240 if (!use_cursor_init) {
244 bool calc_rv3d_dist =
true;
245#ifdef WITH_INPUT_NDOF
247 &ViewOpsType_ndof_orbit,
248 &ViewOpsType_ndof_orbit_zoom,
249 &ViewOpsType_ndof_pan,
250 &ViewOpsType_ndof_all))
252 calc_rv3d_dist =
false;
296 if (
rv3d->is_persp) {
305 upvec[0] = upvec[1] = 0;
306 upvec[2] =
rv3d->dist;
325 const float mval_region_mid[2] = {
float(
region->winx) / 2.0f,
348 this->
init.persp_with_auto_persp_applied =
rv3d->persp;
351 this->
init.event_type =
event->type;
355 if (use_cursor_init) {
379 if (
rv3d->persmat[2][1] < 0.0f) {
399 if (this->
init.dial) {
401 this->
init.dial =
nullptr;
477 this->keymap_items = keymap_tmp.
items;
488 keymap_tmp.
items = this->keymap_items;
494 MEM_CXX_CLASS_ALLOC_FUNCS(
"ViewOpsData_Utility")
510 switch (event->
val) {
530 if (nav_type_new == vod->
nav_type) {
562 const float dyn_ofs_override[3])
568 bool use_cursor_init =
false;
573 vod->
init_navigation(
C, event, nav_type, dyn_ofs_override, use_cursor_init);
587 C, vod, event, op->
ptr, nav_type,
nullptr);
634 if (nav_type_prev != vod->
nav_type) {
670 prop =
RNA_def_int(
ot->srna,
"mx", 0, 0, INT_MAX,
"Region Position X",
"", 0, INT_MAX);
672 prop =
RNA_def_int(
ot->srna,
"my", 0, 0, INT_MAX,
"Region Position Y",
"", 0, INT_MAX);
676 RNA_def_int(
ot->srna,
"delta", 0, INT_MIN, INT_MAX,
"Delta",
"", INT_MIN, INT_MAX);
681 ot->srna,
"use_all_regions",
false,
"All Regions",
"View selected for all regions");
703 const float aspect[2] = {size_min /
size[0], size_min /
size[1]};
708 const float d =
len_v2(r_dir);
720 const float ofs_old[3],
721 const float viewquat_old[4],
722 const float viewquat_new[4],
723 const float dyn_ofs[3])
737 const float viewquat_old[4],
738 const float viewquat_new[4],
739 const float dyn_ofs[3])
774 float view_z_init[3] = {0.0f, 0.0f, 1.0f};
778 float view_z_curr[3] = {0.0f, 0.0f, 1.0f};
782 const float angle_cos =
max_ff(0.0f,
dot_v3v3(view_z_init, view_z_curr));
784 if (
LIKELY(angle_cos < 1.0f)) {
785 const float dot_ofs_curr =
dot_v3v3(view_z_curr, ofs);
786 const float dot_ofs_next =
dot_v3v3(view_z_curr, dyn_ofs);
787 const float ofs_delta = dot_ofs_next - dot_ofs_curr;
788 if (
LIKELY(ofs_delta != 0.0f)) {
839 else if (ob_act &&
ELEM(ob_act->
mode,
854 for (
int i = 0;
i < 4;
i++) {
872 const Object *ob_eval = base_eval->object;
879 add_v3_v3(select_center, ob_eval->object_to_world().location());
885 mul_v3_fl(select_center, 1.0f /
float(total));
909 const bool use_cursor_init)
935 const float quat_[4],
939 const float *align_to_quat,
940 const int smooth_viewtx)
946 const short orig_persp = rv3d->
persp;
947 const char orig_view = rv3d->
view;
979 rv3d->
persp = perspo;
981 if (rv3d->
persp != orig_persp) {
1019 const float *dyn_ofs_pt =
nullptr;
1025 dyn_ofs_pt = dyn_ofs;
1042 const float event_ofs[2] = {
1092#ifdef WITH_INPUT_NDOF
1093 &ViewOpsType_ndof_orbit,
1094 &ViewOpsType_ndof_orbit_zoom,
1095 &ViewOpsType_ndof_pan,
1096 &ViewOpsType_ndof_all,
1100 const char *op_name = idname +
sizeof(
"VIEW3D_OT_");
1102 if (
STREQ(op_name, nav_type->idname +
sizeof(
"VIEW3D_OT_"))) {
1123 const float depth_loc_override[3])
1133 event_tmp.
type =
event->prev_type;
1134 event_tmp.
val =
event->prev_val;
1161 C, vod, event, kmi->ptr, nav_type, depth_loc_override);
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
ListBase * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
General operations, lookup, etc. for blender objects.
Object * BKE_object_pose_armature_get(Object *ob)
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_get(const Object *ob)
void BKE_paint_stroke_get_average(const Paint *paint, const Object *ob, float stroke[3])
Paint * BKE_paint_get_active_from_context(const bContext *C)
void BLI_dial_free(Dial *dial)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
MINLINE float square_f(float a)
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
void invert_qt_normalized(float q[4])
void mul_qt_v3(const float q[4], float r[3])
float normalize_qt_qt(float r[4], const float q[4])
void invert_qt_qt_normalized(float q1[4], const float q2[4])
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
void copy_qt_qt(float q[4], const float a[4])
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE void add_v2_v2(float r[2], const float a[2])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
ViewLayer * DEG_get_evaluated_view_layer(const Depsgraph *graph)
T * DEG_get_original(T *id)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
#define OB_MODE_ALL_PAINT
@ OB_MODE_VERTEX_GREASE_PENCIL
@ OB_MODE_PAINT_GREASE_PENCIL
@ OB_MODE_SCULPT_GREASE_PENCIL
@ OB_MODE_WEIGHT_GREASE_PENCIL
#define BASE_SELECTED(v3d, base)
@ NDOF_NAVIGATION_MODE_FLY
#define RV3D_VIEW_IS_AXIS(view)
#define RV3D_LOCK_FLAGS(rv3d)
@ V3D_AROUND_CENTER_MEDIAN
@ V3D_RUNTIME_OFS_LAST_CENTER_IS_VALID
@ RV3D_LOCK_ZOOM_AND_DOLLY
bool ED_operator_region_view3d_active(bContext *C)
void ED_region_tag_redraw(ARegion *region)
void ED_view3d_win_to_delta(const ARegion *region, const float xy_delta[2], float zfac, float r_out[3], bool precise=false)
bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d)
void ED_view3d_depth_override(Depsgraph *depsgraph, ARegion *region, View3D *v3d, Object *obact, eV3DDepthOverrideMode mode, bool use_overlay, ViewDepths **r_depths)
void ED_view3d_win_to_3d_int(const View3D *v3d, const ARegion *region, const float depth_pt[3], const int mval[2], float r_out[3])
void ED_view3d_autodist_last_clear(wmWindow *win)
void ED_view3d_win_to_3d(const View3D *v3d, const ARegion *region, const float depth_pt[3], const float mval[2], float r_out[3])
bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *region)
bool ED_view3d_offset_lock_check(const View3D *v3d, const RegionView3D *rv3d)
bool ED_view3d_autodist_last_check(wmWindow *win, const wmEvent *event)
void ED_view3d_autodist_last_set(wmWindow *win, const wmEvent *event, const float ofs[3], const bool has_depth)
void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], const float *dist, float *lens)
bool ED_view3d_autodist(ARegion *region, View3D *v3d, const int mval[2], float mouse_worldloc[3], const float fallback_depth_pt[3])
bool ED_view3d_has_depth_buffer_updated(const Depsgraph *depsgraph, const View3D *v3d)
bool ED_view3d_autodist_last_get(wmWindow *win, float r_ofs[3])
void ED_view3d_camera_lock_init_ex(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d, bool calc_dist)
bool ED_view3d_camera_view_pan(ARegion *region, const float event_ofs[2])
bool ED_view3d_camera_lock_undo_push(const char *str, const View3D *v3d, const RegionView3D *rv3d, bContext *C)
float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3])
bool ED_view3d_camera_lock_check(const View3D *v3d, const RegionView3D *rv3d)
void ED_view3d_win_to_vector(const ARegion *region, const float mval[2], float r_out[3])
void ED_view3d_update_viewmat(const Depsgraph *depsgraph, const Scene *scene, View3D *v3d, ARegion *region, const float viewmat[4][4], const float winmat[4][4], const rcti *rect, bool offscreen)
BPy_StructRNA * depsgraph
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
VecBase< float, 3 > float3
MINLINE void zero_v2_int(int r[2])
T midpoint(const T &a, const T &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
struct EditFont * editfont
blender::float2 textcurs[4]
ViewOpsData_Utility(bContext *C, const wmKeyMapItem *kmi_merge=nullptr)
const ViewOpsType * nav_type
char persp_with_auto_persp_applied
void end_navigation(bContext *C)
eViewOpsFlag viewops_flag
bool use_dyn_ofs_ortho_correction
blender::int2 event_xy_offset
struct ViewOpsData::@041211063176270354313167244105136234141004235041 curr
struct ViewOpsData::@244345216304223004112237167211144027240265370072 prev
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 ViewOpsData::@010113264246165170144271002355152266226235365232 init
wmOperatorStatus(* apply_fn)(bContext *C, ViewOpsData *vod, const eV3D_OpEvent event_code, const int xy[2])
wmOperatorStatus(* init_fn)(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr)
bool(* poll_fn)(bContext *C)
struct wmOperatorType * type
void view3d_boxview_sync(ScrArea *area, ARegion *region)
void view3d_navigate_cancel_fn(bContext *C, wmOperator *op)
static const ViewOpsType * view3d_navigation_type_from_idname(const char *idname)
wmOperatorStatus view3d_navigate_invoke_impl(bContext *C, wmOperator *op, const wmEvent *event, const ViewOpsType *nav_type)
void view3d_operator_properties_common(wmOperatorType *ot, const enum eV3D_OpPropFlag flag)
void viewops_data_free(bContext *C, ViewOpsData *vod)
ViewOpsData * viewops_data_create(bContext *C, const wmEvent *event, const ViewOpsType *nav_type, const bool use_cursor_init)
static void view3d_orbit_apply_dyn_ofs_ortho_correction(float ofs[3], const float viewquat_old[4], const float viewquat_new[4], const float dyn_ofs[3])
wmOperatorStatus view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event)
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])
bool view3d_rotation_poll(bContext *C)
bool view3d_location_poll(bContext *C)
static eViewOpsFlag navigate_pivot_get(bContext *C, Depsgraph *depsgraph, ARegion *region, View3D *v3d, const wmEvent *event, eViewOpsFlag viewops_flag, const float dyn_ofs_override[3], float r_pivot[3])
static eViewOpsFlag viewops_flag_from_prefs()
static wmOperatorStatus view3d_navigation_invoke_generic(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr, const ViewOpsType *nav_type, const float dyn_ofs_override[3])
bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
void viewmove_apply(ViewOpsData *vod, int x, int y)
void ED_view3d_navigation_free(bContext *C, ViewOpsData *vod)
void calctrackballvec(const rcti *rect, const int event_xy[2], float r_dir[3])
static eV3D_OpEvent view3d_navigate_event(ViewOpsData *vod, const wmEvent *event)
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)
static bool view3d_navigation_poll_impl(bContext *C, const char viewlock)
bool ED_view3d_navigation_do(bContext *C, ViewOpsData *vod, const wmEvent *event, const float depth_loc_override[3])
ViewOpsData * ED_view3d_navigation_init(bContext *C, const wmKeyMapItem *kmi_merge)
bool view3d_zoom_or_dolly_or_rotation_poll(bContext *C)
void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4])
bool view3d_zoom_or_dolly_poll(bContext *C)
const ViewOpsType ViewOpsType_zoom
void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
const ViewOpsType ViewOpsType_pan
@ VIEWOPS_FLAG_ORBIT_SELECT
@ VIEWOPS_FLAG_DEPTH_NAVIGATE
@ VIEWOPS_FLAG_ZOOM_TO_MOUSE
@ VIEWOPS_FLAG_PERSP_ENSURE
const ViewOpsType ViewOpsType_rotate
void calctrackballvec(const rcti *rect, const int event_xy[2], float r_dir[3])
@ V3D_OP_PROP_USE_MOUSE_INIT
@ V3D_OP_PROP_USE_ALL_REGIONS
const ViewOpsType ViewOpsType_move
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
@ VIEWROT_MODAL_SWITCH_ROTATE
@ VIEWROT_MODAL_AXIS_SNAP_ENABLE
@ VIEWROT_MODAL_SWITCH_MOVE
@ VIEWROT_MODAL_SWITCH_ZOOM
@ VIEWROT_MODAL_AXIS_SNAP_DISABLE
#define V3D_OP_TRACKBALLSIZE
void WM_operator_type_set(wmOperator *op, wmOperatorType *ot)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
bool WM_event_match(const wmEvent *winevent, const wmKeyMapItem *kmi)
#define ISKEYMODIFIER(event_type)
wmKeyMapItem * WM_keymap_add_item_copy(wmKeyMap *keymap, wmKeyMapItem *kmi_src)
void WM_keymap_clear(wmKeyMap *keymap)
wmKeyMap * WM_keymap_find_all(wmWindowManager *wm, const char *idname, int spaceid, int regionid)
void WM_keyconfig_update_suppress_begin()
void WM_keyconfig_update_suppress_end()
void WM_operator_properties_use_cursor_init(wmOperatorType *ot)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)