122 {0,
nullptr, 0,
nullptr,
nullptr},
176#ifdef WITH_INPUT_NDOF
178 wmNDOFMotionData *ndof;
216#ifdef WITH_INPUT_NDOF
316 puts(
"\n-- fly begin --");
329 "Cannot navigate a camera from an external library or non-editable override");
357#ifdef NDOF_FLY_DRAW_TOOMUCH
366#ifdef WITH_INPUT_NDOF
381 if (
fabsf(upvec[2]) < 0.1f) {
425#ifdef WITH_INPUT_NDOF
427 flyApply_ndof(C, fly,
true);
437 puts(
"\n-- fly end --");
449 rv3d->
rflag &= ~RV3D_NAVIGATING;
451#ifdef WITH_INPUT_NDOF
474#ifdef WITH_INPUT_NDOF
480 const wmNDOFMotionData *incoming_ndof =
static_cast<const wmNDOFMotionData *
>(
482 switch (incoming_ndof->progress) {
485# ifdef NDOF_FLY_DEBUG
486 puts(
"start keeping track of 3D mouse position");
492# ifdef NDOF_FLY_DEBUG
496 if (fly->ndof ==
nullptr) {
498 fly->ndof =
static_cast<wmNDOFMotionData *
>(
MEM_dupallocN(incoming_ndof));
502 memcpy(fly->ndof, incoming_ndof,
sizeof(wmNDOFMotionData));
508# ifdef NDOF_FLY_DEBUG
509 puts(
"stop keeping track of 3D mouse position");
529 switch (event->
val) {
543 if (fac > 0.0f && fly->
speed < 0.0f) {
546 else if (fac < 0.0f && fly->speed > 0.0f) {
556 double time_currwheel;
560 if (fly->
axis == -1) {
570 time_wheel = 1.0f + (10.0f - (20.0f *
min_ff(time_wheel, 0.5f)));
572 if (fly->
speed < 0.0f) {
581 double time_currwheel;
585 if (fly->
axis == -1) {
594 time_wheel = 1.0f + (10.0f - (20.0f *
min_ff(time_wheel, 0.5f)));
596 if (fly->
speed > 0.0f) {
614 if (fly->
axis == 2 && fly->
speed < 0.0f) {
621 if (fly->
speed < 0.0f) {
624 else if (fly->
axis == 2) {
632 if (fly->
axis == 2 && fly->
speed > 0.0f) {
636 if (fly->
speed > 0.0f) {
639 else if (fly->
axis == 2) {
648 if (fly->
axis == 0 && fly->
speed < 0.0f) {
652 if (fly->
speed < 0.0f) {
655 else if (fly->
axis == 0) {
664 if (fly->
axis == 0 && fly->
speed > 0.0f) {
668 if (fly->
speed > 0.0f) {
671 else if (fly->
axis == 0) {
680 if (fly->
axis == 1 && fly->
speed < 0.0f) {
684 if (fly->
speed < 0.0f) {
687 else if (fly->
axis == 1) {
695 if (fly->
axis == 1 && fly->
speed > 0.0f) {
699 if (fly->
speed > 0.0f) {
702 else if (fly->
axis == 1) {
751 const bool do_rotate,
752 const bool do_translate,
753 const bool is_confirm)
757 const bool use_autokey = is_confirm || fly->
anim_playing;
763#define FLY_ROTATE_FAC 10.0f
764#define FLY_ZUP_CORRECT_FAC 0.1f
765#define FLY_ZUP_CORRECT_ACCEL 0.05f
766#define FLY_SMOOTH_FAC 20.0f
773 float dvec[3] = {0, 0, 0};
781 static uint iteration = 1;
782 printf(
"fly timer %d\n", iteration++);
797 if (moffset[0] > xmargin) {
798 moffset[0] -= xmargin;
800 else if (moffset[0] < -xmargin) {
801 moffset[0] += xmargin;
807 if (moffset[1] > ymargin) {
808 moffset[1] -= ymargin;
810 else if (moffset[1] < -ymargin) {
811 moffset[1] += ymargin;
824 moffset[0] *=
fabsf(moffset[0]);
829 moffset[1] *=
fabsf(moffset[1]);
833 if ((fly->
speed != 0.0f) || moffset[0] || moffset[1] ||
835 dvec[0] || dvec[1] || dvec[2])
843 float time_redraw_clamped;
844#ifdef NDOF_FLY_DRAW_TOOMUCH
851 time_redraw_clamped =
min_ff(0.05f, time_redraw);
858 fly->
speed = fly->
speed * (1.0f - time_redraw_clamped);
865 copy_v3_fl3(dvec_tmp, -moffset[0], -moffset[1], 0.0f);
905 if (upvec[2] < 0.0f) {
906 moffset[0] = -moffset[0];
936 if (
fabsf(upvec[2]) > 0.00001f) {
937 roll = upvec[2] * 5.0f;
963 if (
fabsf(upvec[2]) > 0.00001f) {
964 roll = upvec[2] * -5.0f;
971 tmp_quat, upvec, roll * time_redraw_clamped * fly->
xlock_momentum * 0.1f);
982 if (fly->
axis == -1) {
991 dvec_tmp[fly->
axis] = 1.0f;
997 if (fly->
speed < 0.0f) {
1014 ((moffset[0] || moffset[1]) && !fly->
pan_view));
1015 const bool do_translate = (fly->
speed != 0.0f || fly->
pan_view);
1030#ifdef WITH_INPUT_NDOF
1034 bool has_translate, has_rotate;
1036 view3d_ndof_fly(fly->ndof,
1044 if (has_translate || has_rotate) {
1048 flyMoveCamera(C, fly, has_rotate, has_translate, is_confirm);
1068 FlyInfo *fly = MEM_cnew<FlyInfo>(
"FlyOperation");
1096 bool do_draw =
false;
1106#ifdef WITH_INPUT_NDOF
1109 flyApply_ndof(C, fly,
false);
1120 exit_code =
flyEnd(C, fly);
1149 ot->
name =
"Fly Navigation";
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)
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_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.
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void MEM_freeN(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
struct ARegionType * type
View3DCameraControl * v3d_camera_control
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
void(* cancel)(bContext *C, wmOperator *op)
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 int flyEnd(bContext *C, FlyInfo *fly)
static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm)
void fly_modal_keymap(wmKeyConfig *keyconf)
static void drawFlyPixel(const bContext *, ARegion *, void *arg)
#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)
static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@ 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)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const int event_type, const double time_step)