55#include <fmt/format.h>
133 {0,
nullptr, 0,
nullptr,
nullptr},
187#ifdef WITH_INPUT_NDOF
189 wmNDOFMotionData *ndof;
227#ifdef WITH_INPUT_NDOF
248 xoff = int(viewborder.
xmin);
249 yoff = int(viewborder.
ymin);
334 puts(
"\n-- fly begin --");
347 "Cannot navigate a camera from an external library or non-editable override");
380#ifdef NDOF_FLY_DRAW_TOOMUCH
389#ifdef WITH_INPUT_NDOF
404 if (
fabsf(upvec[2]) < 0.1f) {
455#ifdef WITH_INPUT_NDOF
457 flyApply_ndof(
C, fly,
true);
467 puts(
"\n-- fly end --");
483#ifdef WITH_INPUT_NDOF
485 MEM_delete(fly->ndof);
506#ifdef WITH_INPUT_NDOF
512 const wmNDOFMotionData *incoming_ndof =
static_cast<const wmNDOFMotionData *
>(
514 switch (incoming_ndof->progress) {
517# ifdef NDOF_FLY_DEBUG
518 puts(
"start keeping track of 3D mouse position");
524# ifdef NDOF_FLY_DEBUG
528 if (fly->ndof ==
nullptr) {
530 fly->ndof = MEM_dupalloc(incoming_ndof);
534 memcpy(fly->ndof, incoming_ndof,
sizeof(wmNDOFMotionData));
540# ifdef NDOF_FLY_DEBUG
541 puts(
"stop keeping track of 3D mouse position");
544 MEM_delete(fly->ndof);
561 switch (event->
val) {
575 if (fac > 0.0f && fly->
speed < 0.0f) {
578 else if (fac < 0.0f && fly->speed > 0.0f) {
588 double time_currwheel;
592 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) {
613 double time_currwheel;
617 if (fly->
axis == -1) {
626 time_wheel = 1.0f + (10.0f - (20.0f *
min_ff(time_wheel, 0.5f)));
628 if (fly->
speed > 0.0f) {
646 if (fly->
axis == 2 && fly->
speed < 0.0f) {
653 if (fly->
speed < 0.0f) {
656 else if (fly->
axis == 2) {
664 if (fly->
axis == 2 && fly->
speed > 0.0f) {
668 if (fly->
speed > 0.0f) {
671 else if (fly->
axis == 2) {
680 if (fly->
axis == 0 && fly->
speed < 0.0f) {
684 if (fly->
speed < 0.0f) {
687 else if (fly->
axis == 0) {
696 if (fly->
axis == 0 && fly->
speed > 0.0f) {
700 if (fly->
speed > 0.0f) {
703 else if (fly->
axis == 0) {
712 if (fly->
axis == 1 && fly->
speed < 0.0f) {
716 if (fly->
speed < 0.0f) {
719 else if (fly->
axis == 1) {
727 if (fly->
axis == 1 && fly->
speed > 0.0f) {
731 if (fly->
speed > 0.0f) {
734 else if (fly->
axis == 1) {
783 const bool do_rotate,
784 const bool do_translate,
785 const bool is_confirm)
789 const bool use_autokey = is_confirm || fly->
anim_playing;
795#define FLY_ROTATE_FAC 10.0f
796#define FLY_ZUP_CORRECT_FAC 0.1f
797#define FLY_ZUP_CORRECT_ACCEL 0.05f
798#define FLY_SMOOTH_FAC 20.0f
805 float dvec[3] = {0, 0, 0};
813 static uint iteration = 1;
814 printf(
"fly timer %d\n", iteration++);
827 moffset[0] = -moffset[0];
828 moffset[1] = -moffset[1];
832 if (moffset[0] > xmargin) {
833 moffset[0] -= xmargin;
835 else if (moffset[0] < -xmargin) {
836 moffset[0] += xmargin;
842 if (moffset[1] > ymargin) {
843 moffset[1] -= ymargin;
845 else if (moffset[1] < -ymargin) {
846 moffset[1] += ymargin;
859 moffset[0] *=
fabsf(moffset[0]);
864 moffset[1] *=
fabsf(moffset[1]);
871 bool changed_viewquat =
false;
878 float time_redraw_clamped;
879#ifdef NDOF_FLY_DRAW_TOOMUCH
886 time_redraw_clamped =
min_ff(0.05f, time_redraw);
893 fly->
speed = fly->
speed * (1.0f - time_redraw_clamped);
900 copy_v3_fl3(dvec_tmp, -moffset[0], -moffset[1], 0.0f);
923 changed_viewquat =
true;
941 if (upvec[2] < 0.0f) {
942 moffset[0] = -moffset[0];
957 changed_viewquat =
true;
968 const float horizon_plane[3] = {0.0f, 0.0f, 1.0f};
969 const float factor = 5.0f * time_redraw_clamped * fly->
zlock_momentum *
975 changed_viewquat =
true;
992 if (
fabsf(upvec[2]) > 0.00001f) {
993 roll = upvec[2] * -5.0f;
1000 tmp_quat, upvec, roll * time_redraw_clamped * fly->
xlock_momentum * 0.1f);
1002 changed_viewquat =
true;
1012 if (fly->
axis == -1) {
1021 dvec_tmp[fly->
axis] = 1.0f;
1027 if (fly->
speed < 0.0f) {
1041 if (changed_viewquat) {
1052 ((moffset[0] || moffset[1]) && !fly->
pan_view));
1053 const bool do_translate = (fly->
speed != 0.0f || fly->
pan_view);
1067#ifdef WITH_INPUT_NDOF
1068static void flyApply_ndof(bContext *
C, FlyInfo *fly,
bool is_confirm)
1071 bool has_translate, has_rotate;
1073 view3d_ndof_fly(*fly->ndof,
1077 lock_ob ? lock_ob->protectflag : 0,
1081 if (has_translate || has_rotate) {
1128 status.
item(fmt::format(
"{} ({:.2f})",
IFACE_(
"Acceleration"), fly->
speed), ICON_NONE);
1168 bool do_draw =
false;
1180#ifdef WITH_INPUT_NDOF
1183 flyApply_ndof(
C, fly,
false);
1225 ot->
name =
"Fly Navigation";
1226 ot->
description =
"Interactively fly around the scene";
1227 ot->
idname =
"VIEW3D_OT_fly";
Camera data-block and utility functions.
Platform independent time functions.
Object is a sort of wrapper for general info.
#define RV3D_LOCK_FLAGS(rv3d)
#define REGION_DRAW_POST_PIXEL
Read Blender memory allocation and freeing.
void item(std::string text, int icon1, int icon2=0)
void opmodal(std::string text, const wmOperatorType *ot, int propvalue, bool inverted=false)
MINLINE float min_ff(float a, float b)
void mul_m3_v3(const float M[3][3], float r[3])
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
static wmOperatorStatus fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
bool ED_undo_is_memfile_compatible(const bContext *C)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
GPUVertFormat * immVertexFormat()
Object * ED_view3d_cameracontrol_object_get(View3DCameraControl *vctrl)
float normalize_qt(float q[4])
bool ED_view3d_camera_lock_undo_push(const char *str, const View3D *v3d, const RegionView3D *rv3d, bContext *C)
void immBegin(GPUPrimType, uint vertex_len)
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
wmWindow * CTX_wm_window(const bContext *C)
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm)
@ RV3D_LOCK_ANY_TRANSFORM
void ED_region_tag_redraw(ARegion *region)
MINLINE void mul_v3_fl(float r[3], float f)
static void fly_draw_status(bContext *C, wmOperator *op)
void ED_view3d_cameracontrol_release(View3DCameraControl *vctrl, const bool restore)
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void immVertex2f(uint attr_id, float x, float y)
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
bool BKE_constraint_has_influence(const struct bConstraint *con)
void BKE_report(ReportList *reports, eReportType type, const char *message)
View3DCameraControl * ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d)
@ FLY_MODAL_PRECISION_ENABLE
@ FLY_MODAL_FREELOOK_DISABLE
@ FLY_MODAL_FREELOOK_ENABLE
@ FLY_MODAL_PRECISION_DISABLE
@ GPU_SHADER_3D_UNIFORM_COLOR
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
wmWindowManager * CTX_wm_manager(const bContext *C)
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
void immUniformThemeColor3(int color_id)
rctf BKE_camera_view_border(const struct Scene *scene, const struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d, int winx, int winy, bool no_shift, bool no_zoom, bool no_roll)
static wmOperatorStatus flyEnd(bContext *C, FlyInfo *fly)
MINLINE void negate_v3(float r[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
void VIEW3D_OT_fly(wmOperatorType *ot)
MINLINE void zero_v3(float r[3])
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent *event)
MINLINE float normalize_v3_v3(float r[3], const float a[3])
@ FLY_AXISLOCK_STATE_IDLE
@ FLY_AXISLOCK_STATE_ACTIVE
bool ED_view3d_offset_lock_check(const View3D *v3d, const RegionView3D *rv3d)
MINLINE void add_v3_v3(float r[3], const float a[3])
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
Depsgraph * CTX_data_expect_evaluated_depsgraph(const bContext *C)
Main * CTX_data_main(const bContext *C)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
bool ED_operator_region_view3d_active(bContext *C)
static void fly_cancel(bContext *C, wmOperator *op)
static void flyMoveCamera(bContext *C, FlyInfo *fly, const bool do_rotate, const bool do_translate, const bool is_confirm)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
double BLI_time_now_seconds()
Scene * CTX_data_scene(const bContext *C)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
static void drawFlyPixel(const bContext *, ARegion *, void *arg)
static wmOperatorStatus fly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const wmEventType event_type, const double time_step)
static void flyEvent(FlyInfo *fly, const wmEvent *event)
void fly_modal_keymap(wmKeyConfig *keyconf)
void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl, const bool use_autokey, bContext *C, const bool do_rotate, const bool do_translate)
void WM_cursor_warp(wmWindow *win, int x, int y)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
float view3d_horizon_correct_quat_ease_out(float quat[4], const float horizon_plane[3], const bool horizon_plane_no_flip, const float factor)
View3D * CTX_wm_view3d(const bContext *C)
bScreen * ED_screen_animation_playing(const wmWindowManager *wm)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::ARegionRuntime * runtime
View3DCameraControl * v3d_camera_control
ListBaseT< bConstraint > constraints
eRegionView3D_Persp persp
struct ARegionType * type
void(*) cancel(bContext *C, wmOperator *op)
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type
#define FLY_ZUP_CORRECT_ACCEL
#define FLY_ZUP_CORRECT_FAC