27 #ifdef WITH_INPUT_NDOF
187 #ifdef WITH_INPUT_NDOF
189 wmNDOFMotionData *ndof;
229 #ifdef WITH_INPUT_NDOF
239 float x1,
x2,
y1, y2;
244 xoff = viewborder.
xmin;
245 yoff = viewborder.
ymin;
255 x1 = xoff + 0.45f * fly->
width;
257 x2 = xoff + 0.55f * fly->
width;
258 y2 = yoff + 0.55f * fly->
height;
329 #ifdef NDOF_FLY_DEBUG
330 puts(
"\n-- fly begin --");
366 #ifdef NDOF_FLY_DRAW_TOOMUCH
375 #ifdef WITH_INPUT_NDOF
390 if (
fabsf(upvec[2]) < 0.1f) {
434 #ifdef WITH_INPUT_NDOF
436 flyApply_ndof(
C, fly,
true);
445 #ifdef NDOF_FLY_DEBUG
446 puts(
"\n-- fly end --");
460 #ifdef WITH_INPUT_NDOF
483 #ifdef WITH_INPUT_NDOF
489 const wmNDOFMotionData *incoming_ndof =
event->customdata;
490 switch (incoming_ndof->progress) {
493 # ifdef NDOF_FLY_DEBUG
494 puts(
"start keeping track of 3D mouse position");
499 # ifdef NDOF_FLY_DEBUG
503 if (fly->ndof ==
NULL) {
509 memcpy(fly->ndof, incoming_ndof,
sizeof(wmNDOFMotionData));
514 # ifdef NDOF_FLY_DEBUG
515 puts(
"stop keeping track of 3D mouse position");
532 switch (event->
val) {
542 float fac = 0.02f * (
event->prevy -
event->y);
545 if (fac > 0.0f && fly->
speed < 0.0f) {
548 else if (fac < 0.0f && fly->speed > 0.0f) {
558 double time_currwheel;
562 if (fly->
axis == -1) {
572 time_wheel = 1.0f + (10.0f - (20.0f *
min_ff(time_wheel, 0.5f)));
574 if (fly->
speed < 0.0f) {
583 double time_currwheel;
587 if (fly->
axis == -1) {
596 time_wheel = 1.0f + (10.0f - (20.0f *
min_ff(time_wheel, 0.5f)));
598 if (fly->
speed > 0.0f) {
616 if (fly->
axis == 2 && fly->
speed < 0.0f) {
623 if (fly->
speed < 0.0f) {
626 else if (fly->
axis == 2) {
633 if (fly->
axis == 2 && fly->
speed > 0.0f) {
637 if (fly->
speed > 0.0f) {
640 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) {
663 if (fly->
axis == 0 && fly->
speed > 0.0f) {
667 if (fly->
speed > 0.0f) {
670 else if (fly->
axis == 0) {
678 if (fly->
axis == 1 && fly->
speed < 0.0f) {
682 if (fly->
speed < 0.0f) {
685 else if (fly->
axis == 1) {
692 if (fly->
axis == 1 && fly->
speed > 0.0f) {
696 if (fly->
speed > 0.0f) {
699 else if (fly->
axis == 1) {
744 const bool do_rotate,
745 const bool do_translate,
746 const bool is_confirm)
750 const bool use_autokey = is_confirm || fly->
anim_playing;
756 #define FLY_ROTATE_FAC 10.0f
757 #define FLY_ZUP_CORRECT_FAC 0.1f
758 #define FLY_ZUP_CORRECT_ACCEL 0.05f
759 #define FLY_SMOOTH_FAC 20.0f
769 float dvec[3] = {0, 0, 0};
776 int xmargin, ymargin;
778 #ifdef NDOF_FLY_DEBUG
780 static uint iteration = 1;
781 printf(
"fly timer %d\n", iteration++);
785 xmargin = fly->
width / 20.0f;
786 ymargin = fly->
height / 20.0f;
795 if (moffset[0] > xmargin) {
796 moffset[0] -= xmargin;
798 else if (moffset[0] < -xmargin) {
799 moffset[0] += xmargin;
805 if (moffset[1] > ymargin) {
806 moffset[1] -= ymargin;
808 else if (moffset[1] < -ymargin) {
809 moffset[1] += ymargin;
821 moffset[0] /= fly->
width - (xmargin * 2);
822 moffset[0] *=
fabsf(moffset[0]);
826 moffset[1] /= fly->
height - (ymargin * 2);
827 moffset[1] *=
fabsf(moffset[1]);
831 if ((fly->
speed != 0.0f) || moffset[0] || moffset[1] ||
833 dvec[0] || dvec[1] || dvec[2]) {
840 float time_redraw_clamped;
841 #ifdef NDOF_FLY_DRAW_TOOMUCH
848 time_redraw_clamped =
min_ff(0.05f, time_redraw);
855 fly->
speed = fly->
speed * (1.0f - time_redraw_clamped);
862 copy_v3_fl3(dvec_tmp, -moffset[0], -moffset[1], 0.0f);
901 if (upvec[2] < 0.0f) {
902 moffset[0] = -moffset[0];
932 if (
fabsf(upvec[2]) > 0.00001f) {
933 roll = upvec[2] * 5.0f;
959 if (
fabsf(upvec[2]) > 0.00001f) {
960 roll = upvec[2] * -5.0f;
967 tmp_quat, upvec, roll * time_redraw_clamped * fly->
xlock_momentum * 0.1f);
978 if (fly->
axis == -1) {
987 dvec_tmp[fly->
axis] = 1.0f;
993 if (fly->
speed < 0.0f) {
1010 ((moffset[0] || moffset[1]) && !fly->
pan_view));
1011 const bool do_translate = (fly->
speed != 0.0f || fly->
pan_view);
1026 #ifdef WITH_INPUT_NDOF
1030 bool has_translate, has_rotate;
1032 view3d_ndof_fly(fly->ndof,
1040 if (has_translate || has_rotate) {
1093 bool do_draw =
false;
1102 #ifdef WITH_INPUT_NDOF
1105 flyApply_ndof(
C, fly,
false);
1137 ot->
name =
"Fly Navigation";
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
struct Depsgraph * CTX_data_expect_evaluated_depsgraph(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
void BKE_report(ReportList *reports, ReportType 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], const float angle)
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
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)
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)
struct Depsgraph Depsgraph
#define ID_IS_LINKED(_id)
Object is a sort of wrapper for general info.
#define RV3D_LOCK_FLAGS(rv3d)
@ RV3D_LOCK_ANY_TRANSFORM
bScreen * ED_screen_animation_playing(const struct wmWindowManager *wm)
void ED_region_tag_redraw(struct ARegion *region)
bool ED_operator_region_view3d_active(struct bContext *C)
void * ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *customdata, int type)
#define REGION_DRAW_POST_PIXEL
void ED_region_draw_cb_exit(struct ARegionType *, void *)
void ED_view3d_calc_camera_border(const struct Scene *scene, struct Depsgraph *depsgraph, const struct ARegion *region, const struct View3D *v3d, const struct RegionView3D *rv3d, struct rctf *r_viewborder, const bool no_shift)
bool ED_view3d_offset_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble y1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
@ GPU_SHADER_2D_UNIFORM_COLOR
Read Guarded memory(de)allocation.
Platform independent time functions.
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
struct ARegionType * type
struct View3DCameraControl * v3d_camera_control
struct Depsgraph * depsgraph
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
struct ReportList * reports
double PIL_check_seconds_timer(void)
void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl, const bool use_autokey, struct bContext *C, const bool do_rotate, const bool do_translate)
Object * ED_view3d_cameracontrol_object_get(View3DCameraControl *vctrl)
struct View3DCameraControl * ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d)
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 drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(region), void *arg)
static int flyEnd(bContext *C, FlyInfo *fly)
void fly_modal_keymap(wmKeyConfig *keyconf)
@ FLY_MODAL_PRECISION_ENABLE
@ FLY_MODAL_FREELOOK_DISABLE
@ FLY_MODAL_FREELOOK_ENABLE
@ FLY_MODAL_PRECISION_DISABLE
#define FLY_ZUP_CORRECT_FAC
static void fly_cancel(bContext *C, wmOperator *op)
static int flyApply(bContext *C, struct FlyInfo *fly, bool is_confirm)
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)
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_find(wmKeyConfig *keyconf, const char *idname)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
void WM_cursor_warp(wmWindow *win, int x, int y)
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)