67 if (use_zoom_to_mouse) {
85 this->
v3d =
static_cast<View3D *
>(this->area->spacedata.first);
178 const float dyn_ofs_override[3],
195 if (dyn_ofs_override) {
202 if (use_depth_last) {
206 float fallback_depth_pt[3];
224 const float dyn_ofs_override[3],
225 const bool use_cursor_init)
231 if (!use_cursor_init) {
235 bool calc_rv3d_dist =
true;
236#ifdef WITH_INPUT_NDOF
238 &ViewOpsType_ndof_orbit,
239 &ViewOpsType_ndof_orbit_zoom,
240 &ViewOpsType_ndof_pan,
241 &ViewOpsType_ndof_all))
243 calc_rv3d_dist =
false;
294 upvec[0] = upvec[1] = 0;
314 const float mval_region_mid[2] = {
float(region->winx) / 2.0f,
float(region->winy) / 2.0f};
338 this->
init.event_type =
event->type;
342 if (use_cursor_init) {
443 if (kmi_merge->oskey == 1 ||
ELEM(kmi_merge->type,
EVT_OSKEY)) {
453 this->keymap_items = keymap_tmp.
items;
470#ifdef WITH_CXX_GUARDEDALLOC
471 MEM_CXX_CLASS_ALLOC_FUNCS(
"ViewOpsData_Utility")
488 switch (event->
val) {
508 if (nav_type_new == vod->
nav_type) {
540 const float dyn_ofs_override[3])
546 bool use_cursor_init =
false;
551 vod->
init_navigation(C, event, nav_type, dyn_ofs_override, use_cursor_init);
604 if (nav_type_prev != vod->
nav_type) {
640 prop =
RNA_def_int(
ot->
srna,
"mx", 0, 0, INT_MAX,
"Region Position X",
"", 0, INT_MAX);
642 prop =
RNA_def_int(
ot->
srna,
"my", 0, 0, INT_MAX,
"Region Position Y",
"", 0, INT_MAX);
646 RNA_def_int(
ot->
srna,
"delta", 0, INT_MIN, INT_MAX,
"Delta",
"", INT_MIN, INT_MAX);
651 ot->
srna,
"use_all_regions",
false,
"All Regions",
"View selected for all regions");
672 const float size_min =
min_ff(size[0], size[1]);
673 const float aspect[2] = {size_min / size[0], size_min / size[1]};
676 r_dir[0] = (event_xy[0] -
BLI_rcti_cent_x(rect)) / ((size[0] * aspect[0]) / 2.0);
677 r_dir[1] = (event_xy[1] -
BLI_rcti_cent_y(rect)) / ((size[1] * aspect[1]) / 2.0);
678 const float d =
len_v2(r_dir);
690 const float ofs_old[3],
691 const float viewquat_old[4],
692 const float viewquat_new[4],
693 const float dyn_ofs[3])
707 const float viewquat_old[4],
708 const float viewquat_new[4],
709 const float dyn_ofs[3])
744 float view_z_init[3] = {0.0f, 0.0f, 1.0f};
748 float view_z_curr[3] = {0.0f, 0.0f, 1.0f};
752 const float angle_cos =
max_ff(0.0f,
dot_v3v3(view_z_init, view_z_curr));
754 if (
LIKELY(angle_cos < 1.0f)) {
755 const float dot_ofs_curr =
dot_v3v3(view_z_curr, ofs);
756 const float dot_ofs_next =
dot_v3v3(view_z_curr, dyn_ofs);
757 const float ofs_delta = dot_ofs_next - dot_ofs_curr;
758 if (
LIKELY(ofs_delta != 0.0f)) {
810 for (
int i = 0; i < 4; i++) {
828 const Object *ob_eval = base_eval->object;
835 add_v3_v3(select_center, ob_eval->object_to_world().location());
841 mul_v3_fl(select_center, 1.0f /
float(total));
859 const bool use_cursor_init)
888 const float quat_[4],
892 const float *align_to_quat,
893 const int smooth_viewtx)
899 const short orig_persp = rv3d->
persp;
900 const char orig_view = rv3d->
view;
932 rv3d->
persp = perspo;
934 if (rv3d->
persp != orig_persp) {
973 const float *dyn_ofs_pt =
nullptr;
979 dyn_ofs_pt = dyn_ofs;
996 const float event_ofs[2] = {
1046#ifdef WITH_INPUT_NDOF
1047 &ViewOpsType_ndof_orbit,
1048 &ViewOpsType_ndof_orbit_zoom,
1049 &ViewOpsType_ndof_pan,
1050 &ViewOpsType_ndof_all,
1054 const char *op_name = idname +
sizeof(
"VIEW3D_OT_");
1056 if (
STREQ(op_name, nav_type->idname +
sizeof(
"VIEW3D_OT_"))) {
1077 const float depth_loc_override[3])
1087 event_tmp.
type =
event->prev_type;
1088 event_tmp.
val =
event->prev_val;
1115 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 Scene *scene, const Object *ob, float stroke[3])
#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 add_v2_v2v2_int(int r[2], const int a[2], const int b[2])
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 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)
Object * DEG_get_original_object(Object *object)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
#define OB_MODE_ALL_PAINT
#define BASE_SELECTED(v3d, base)
#define RV3D_VIEW_IS_AXIS(view)
#define RV3D_LOCK_FLAGS(rv3d)
@ V3D_AROUND_CENTER_MEDIAN
@ RV3D_LOCK_ZOOM_AND_DOLLY
bool ED_operator_region_view3d_active(bContext *C)
void ED_region_tag_redraw(ARegion *region)
bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d)
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_depth_override(Depsgraph *depsgraph, ARegion *region, View3D *v3d, Object *obact, eV3DDepthOverrideMode mode, ViewDepths **r_depths)
void ED_view3d_win_to_delta(const ARegion *region, const float xy_delta[2], float zfac, float r_out[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)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
const Depsgraph * depsgraph
draw_view in_light_buf[] float
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
ViewOpsData_Utility(bContext *C, const wmKeyMapItem *kmi_merge=nullptr)
const ViewOpsType * nav_type
struct ViewOpsData::@543 init
char persp_with_auto_persp_applied
void end_navigation(bContext *C)
eViewOpsFlag viewops_flag
bool use_dyn_ofs_ortho_correction
struct ViewOpsData::@544 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::@545 curr
int(* init_fn)(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr)
bool(* poll_fn)(bContext *C)
int(* apply_fn)(bContext *C, ViewOpsData *vod, const eV3D_OpEvent event_code, const int xy[2])
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)
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])
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()
bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
int view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event)
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)
static int view3d_navigation_invoke_generic(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr, const ViewOpsType *nav_type, const float dyn_ofs_override[3])
int view3d_navigate_invoke_impl(bContext *C, wmOperator *op, const wmEvent *event, const ViewOpsType *nav_type)
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
@ VIEWROT_MODAL_SWITCH_ROTATE
@ VIEWROT_MODAL_AXIS_SNAP_ENABLE
@ VIEWROT_MODAL_SWITCH_MOVE
@ VIEWROT_MODAL_SWITCH_ZOOM
@ VIEWROT_MODAL_AXIS_SNAP_DISABLE
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)
#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)