52#include <fmt/format.h>
128 {0,
nullptr, 0,
nullptr,
nullptr},
182#ifdef WITH_INPUT_NDOF
184 wmNDOFMotionData *ndof;
222#ifdef WITH_INPUT_NDOF
236 xoff = int(viewborder.
xmin);
237 yoff = int(viewborder.
ymin);
322 puts(
"\n-- fly begin --");
335 "Cannot navigate a camera from an external library or non-editable override");
363#ifdef NDOF_FLY_DRAW_TOOMUCH
372#ifdef WITH_INPUT_NDOF
387 if (
fabsf(upvec[2]) < 0.1f) {
431#ifdef WITH_INPUT_NDOF
433 flyApply_ndof(
C, fly,
true);
443 puts(
"\n-- fly end --");
459#ifdef WITH_INPUT_NDOF
482#ifdef WITH_INPUT_NDOF
488 const wmNDOFMotionData *incoming_ndof =
static_cast<const wmNDOFMotionData *
>(
490 switch (incoming_ndof->progress) {
493# ifdef NDOF_FLY_DEBUG
494 puts(
"start keeping track of 3D mouse position");
500# ifdef NDOF_FLY_DEBUG
504 if (fly->ndof ==
nullptr) {
506 fly->ndof =
static_cast<wmNDOFMotionData *
>(
MEM_dupallocN(incoming_ndof));
510 memcpy(fly->ndof, incoming_ndof,
sizeof(wmNDOFMotionData));
516# ifdef NDOF_FLY_DEBUG
517 puts(
"stop keeping track of 3D mouse position");
537 switch (event->
val) {
551 if (fac > 0.0f && fly->
speed < 0.0f) {
554 else if (fac < 0.0f && fly->speed > 0.0f) {
564 double time_currwheel;
568 if (fly->
axis == -1) {
578 time_wheel = 1.0f + (10.0f - (20.0f *
min_ff(time_wheel, 0.5f)));
580 if (fly->
speed < 0.0f) {
589 double time_currwheel;
593 if (fly->
axis == -1) {
602 time_wheel = 1.0f + (10.0f - (20.0f *
min_ff(time_wheel, 0.5f)));
604 if (fly->
speed > 0.0f) {
622 if (fly->
axis == 2 && fly->
speed < 0.0f) {
629 if (fly->
speed < 0.0f) {
632 else if (fly->
axis == 2) {
640 if (fly->
axis == 2 && fly->
speed > 0.0f) {
644 if (fly->
speed > 0.0f) {
647 else if (fly->
axis == 2) {
656 if (fly->
axis == 0 && fly->
speed < 0.0f) {
660 if (fly->
speed < 0.0f) {
663 else if (fly->
axis == 0) {
672 if (fly->
axis == 0 && fly->
speed > 0.0f) {
676 if (fly->
speed > 0.0f) {
679 else if (fly->
axis == 0) {
688 if (fly->
axis == 1 && fly->
speed < 0.0f) {
692 if (fly->
speed < 0.0f) {
695 else if (fly->
axis == 1) {
703 if (fly->
axis == 1 && fly->
speed > 0.0f) {
707 if (fly->
speed > 0.0f) {
710 else if (fly->
axis == 1) {
759 const bool do_rotate,
760 const bool do_translate,
761 const bool is_confirm)
765 const bool use_autokey = is_confirm || fly->
anim_playing;
771#define FLY_ROTATE_FAC 10.0f
772#define FLY_ZUP_CORRECT_FAC 0.1f
773#define FLY_ZUP_CORRECT_ACCEL 0.05f
774#define FLY_SMOOTH_FAC 20.0f
781 float dvec[3] = {0, 0, 0};
789 static uint iteration = 1;
790 printf(
"fly timer %d\n", iteration++);
803 if (moffset[0] > xmargin) {
804 moffset[0] -= xmargin;
806 else if (moffset[0] < -xmargin) {
807 moffset[0] += xmargin;
813 if (moffset[1] > ymargin) {
814 moffset[1] -= ymargin;
816 else if (moffset[1] < -ymargin) {
817 moffset[1] += ymargin;
830 moffset[0] *=
fabsf(moffset[0]);
835 moffset[1] *=
fabsf(moffset[1]);
842 bool changed_viewquat =
false;
849 float time_redraw_clamped;
850#ifdef NDOF_FLY_DRAW_TOOMUCH
857 time_redraw_clamped =
min_ff(0.05f, time_redraw);
864 fly->
speed = fly->
speed * (1.0f - time_redraw_clamped);
871 copy_v3_fl3(dvec_tmp, -moffset[0], -moffset[1], 0.0f);
894 changed_viewquat =
true;
912 if (upvec[2] < 0.0f) {
913 moffset[0] = -moffset[0];
928 changed_viewquat =
true;
944 if (
fabsf(upvec[2]) > 0.00001f) {
945 roll = upvec[2] * 5.0f;
955 changed_viewquat =
true;
972 if (
fabsf(upvec[2]) > 0.00001f) {
973 roll = upvec[2] * -5.0f;
980 tmp_quat, upvec, roll * time_redraw_clamped * fly->
xlock_momentum * 0.1f);
982 changed_viewquat =
true;
992 if (fly->
axis == -1) {
1001 dvec_tmp[fly->
axis] = 1.0f;
1007 if (fly->
speed < 0.0f) {
1021 if (changed_viewquat) {
1032 ((moffset[0] || moffset[1]) && !fly->
pan_view));
1033 const bool do_translate = (fly->
speed != 0.0f || fly->
pan_view);
1047#ifdef WITH_INPUT_NDOF
1051 bool has_translate, has_rotate;
1053 view3d_ndof_fly(*fly->ndof,
1061 if (has_translate || has_rotate) {
1108 status.item(fmt::format(
"{} ({:.2f})",
IFACE_(
"Acceleration"), fly->
speed), ICON_NONE);
1148 bool do_draw =
false;
1160#ifdef WITH_INPUT_NDOF
1163 flyApply_ndof(
C, fly,
false);
1205 ot->name =
"Fly Navigation";
1206 ot->description =
"Interactively fly around the scene";
1207 ot->idname =
"VIEW3D_OT_fly";
Depsgraph * CTX_data_expect_evaluated_depsgraph(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(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)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
void BKE_report(ReportList *reports, eReportType type, const char *message)
MINLINE float min_ff(float a, float b)
void mul_m3_v3(const float M[3][3], float r[3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
float normalize_qt(float q[4])
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
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 copy_v3_fl3(float v[3], float x, float y, float z)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void negate_v3(float r[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Platform independent time functions.
double BLI_time_now_seconds(void)
Object is a sort of wrapper for general info.
#define RV3D_LOCK_FLAGS(rv3d)
@ RV3D_LOCK_ANY_TRANSFORM
bool ED_operator_region_view3d_active(bContext *C)
bScreen * ED_screen_animation_playing(const wmWindowManager *wm)
void ED_workspace_status_text(bContext *C, const char *str)
void ED_region_tag_redraw(ARegion *region)
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
#define REGION_DRAW_POST_PIXEL
void ED_undo_push(bContext *C, const char *str)
bool ED_undo_is_memfile_compatible(const bContext *C)
bool ED_view3d_offset_lock_check(const View3D *v3d, const RegionView3D *rv3d)
bool ED_view3d_camera_lock_undo_push(const char *str, const View3D *v3d, const RegionView3D *rv3d, bContext *C)
void ED_view3d_calc_camera_border(const Scene *scene, const Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const RegionView3D *rv3d, bool no_shift, rctf *r_viewborder)
@ GPU_SHADER_3D_UNIFORM_COLOR
Read Guarded memory(de)allocation.
void * MEM_callocN(size_t len, const char *str)
void * MEM_dupallocN(const void *vmemh)
void MEM_freeN(void *vmemh)
ARegionRuntimeHandle * runtime
View3DCameraControl * v3d_camera_control
struct ReportList * reports
struct wmOperatorType * type
View3DCameraControl * ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d)
Object * ED_view3d_cameracontrol_object_get(View3DCameraControl *vctrl)
void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl, const bool use_autokey, bContext *C, const bool do_rotate, const bool do_translate)
void ED_view3d_cameracontrol_release(View3DCameraControl *vctrl, const bool restore)
#define FLY_ZUP_CORRECT_ACCEL
static void flyEvent(FlyInfo *fly, const wmEvent *event)
@ FLY_AXISLOCK_STATE_ACTIVE
@ FLY_AXISLOCK_STATE_IDLE
static void fly_draw_status(bContext *C, wmOperator *op)
static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm)
void fly_modal_keymap(wmKeyConfig *keyconf)
static void drawFlyPixel(const bContext *, ARegion *, void *arg)
static wmOperatorStatus fly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus flyEnd(bContext *C, FlyInfo *fly)
static wmOperatorStatus fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
#define FLY_ZUP_CORRECT_FAC
static void fly_cancel(bContext *C, wmOperator *op)
static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent *event)
void VIEW3D_OT_fly(wmOperatorType *ot)
@ FLY_MODAL_PRECISION_ENABLE
@ FLY_MODAL_FREELOOK_DISABLE
@ FLY_MODAL_FREELOOK_ENABLE
@ FLY_MODAL_PRECISION_DISABLE
static void flyMoveCamera(bContext *C, FlyInfo *fly, const bool do_rotate, const bool do_translate, const bool is_confirm)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
void WM_cursor_warp(wmWindow *win, int x, int y)
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const wmEventType event_type, const double time_step)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)