13 #ifdef WITH_INPUT_NDOF
174 #ifdef WITH_INPUT_NDOF
176 wmNDOFMotionData *ndof;
216 #ifdef WITH_INPUT_NDOF
226 float x1,
x2,
y1, y2;
231 xoff = viewborder.
xmin;
232 yoff = viewborder.
ymin;
242 x1 = xoff + 0.45f * fly->
width;
244 x2 = xoff + 0.55f * fly->
width;
245 y2 = yoff + 0.55f * fly->
height;
316 #ifdef NDOF_FLY_DEBUG
317 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);
436 #ifdef NDOF_FLY_DEBUG
437 puts(
"\n-- fly end --");
451 #ifdef WITH_INPUT_NDOF
474 #ifdef WITH_INPUT_NDOF
480 const wmNDOFMotionData *incoming_ndof =
event->customdata;
481 switch (incoming_ndof->progress) {
484 # ifdef NDOF_FLY_DEBUG
485 puts(
"start keeping track of 3D mouse position");
490 # ifdef NDOF_FLY_DEBUG
494 if (fly->ndof ==
NULL) {
500 memcpy(fly->ndof, incoming_ndof,
sizeof(wmNDOFMotionData));
505 # ifdef NDOF_FLY_DEBUG
506 puts(
"stop keeping track of 3D mouse position");
523 switch (event->
val) {
533 float fac = 0.02f * (
event->prev_xy[1] -
event->xy[1]);
536 if (fac > 0.0f && fly->
speed < 0.0f) {
539 else if (fac < 0.0f && fly->speed > 0.0f) {
549 double time_currwheel;
553 if (fly->
axis == -1) {
563 time_wheel = 1.0f + (10.0f - (20.0f *
min_ff(time_wheel, 0.5f)));
565 if (fly->
speed < 0.0f) {
574 double time_currwheel;
578 if (fly->
axis == -1) {
587 time_wheel = 1.0f + (10.0f - (20.0f *
min_ff(time_wheel, 0.5f)));
589 if (fly->
speed > 0.0f) {
606 if (fly->
axis == 2 && fly->
speed < 0.0f) {
613 if (fly->
speed < 0.0f) {
616 else if (fly->
axis == 2) {
623 if (fly->
axis == 2 && fly->
speed > 0.0f) {
627 if (fly->
speed > 0.0f) {
630 else if (fly->
axis == 2) {
638 if (fly->
axis == 0 && fly->
speed < 0.0f) {
642 if (fly->
speed < 0.0f) {
645 else if (fly->
axis == 0) {
653 if (fly->
axis == 0 && fly->
speed > 0.0f) {
657 if (fly->
speed > 0.0f) {
660 else if (fly->
axis == 0) {
668 if (fly->
axis == 1 && fly->
speed < 0.0f) {
672 if (fly->
speed < 0.0f) {
675 else if (fly->
axis == 1) {
682 if (fly->
axis == 1 && fly->
speed > 0.0f) {
686 if (fly->
speed > 0.0f) {
689 else if (fly->
axis == 1) {
734 const bool do_rotate,
735 const bool do_translate,
736 const bool is_confirm)
740 const bool use_autokey = is_confirm || fly->
anim_playing;
746 #define FLY_ROTATE_FAC 10.0f
747 #define FLY_ZUP_CORRECT_FAC 0.1f
748 #define FLY_ZUP_CORRECT_ACCEL 0.05f
749 #define FLY_SMOOTH_FAC 20.0f
756 float dvec[3] = {0, 0, 0};
763 int xmargin, ymargin;
765 #ifdef NDOF_FLY_DEBUG
767 static uint iteration = 1;
768 printf(
"fly timer %d\n", iteration++);
772 xmargin = fly->
width / 20.0f;
773 ymargin = fly->
height / 20.0f;
782 if (moffset[0] > xmargin) {
783 moffset[0] -= xmargin;
785 else if (moffset[0] < -xmargin) {
786 moffset[0] += xmargin;
792 if (moffset[1] > ymargin) {
793 moffset[1] -= ymargin;
795 else if (moffset[1] < -ymargin) {
796 moffset[1] += ymargin;
808 moffset[0] /= fly->
width - (xmargin * 2);
809 moffset[0] *=
fabsf(moffset[0]);
813 moffset[1] /= fly->
height - (ymargin * 2);
814 moffset[1] *=
fabsf(moffset[1]);
818 if ((fly->
speed != 0.0f) || moffset[0] || moffset[1] ||
820 dvec[0] || dvec[1] || dvec[2]) {
827 float time_redraw_clamped;
828 #ifdef NDOF_FLY_DRAW_TOOMUCH
835 time_redraw_clamped =
min_ff(0.05f, time_redraw);
842 fly->
speed = fly->
speed * (1.0f - time_redraw_clamped);
849 copy_v3_fl3(dvec_tmp, -moffset[0], -moffset[1], 0.0f);
888 if (upvec[2] < 0.0f) {
889 moffset[0] = -moffset[0];
919 if (
fabsf(upvec[2]) > 0.00001f) {
920 roll = upvec[2] * 5.0f;
946 if (
fabsf(upvec[2]) > 0.00001f) {
947 roll = upvec[2] * -5.0f;
954 tmp_quat, upvec, roll * time_redraw_clamped * fly->
xlock_momentum * 0.1f);
965 if (fly->
axis == -1) {
974 dvec_tmp[fly->
axis] = 1.0f;
980 if (fly->
speed < 0.0f) {
997 ((moffset[0] || moffset[1]) && !fly->
pan_view));
998 const bool do_translate = (fly->
speed != 0.0f || fly->
pan_view);
1013 #ifdef WITH_INPUT_NDOF
1017 bool has_translate, has_rotate;
1019 view3d_ndof_fly(fly->ndof,
1027 if (has_translate || has_rotate) {
1080 bool do_draw =
false;
1090 #ifdef WITH_INPUT_NDOF
1093 flyApply_ndof(
C, fly,
false);
1128 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 Main * CTX_data_main(const bContext *C)
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
bool BKE_id_is_editable(const struct Main *bmain, const struct 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)
struct Depsgraph Depsgraph
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
bool ED_region_draw_cb_exit(struct ARegionType *art, void *handle)
bool ED_view3d_offset_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d)
bool ED_view3d_camera_lock_undo_push(const char *str, View3D *v3d, struct RegionView3D *rv3d, struct bContext *C)
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, bool no_shift)
_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
struct wmOperatorType * type
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)
#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)
@ FLY_MODAL_PRECISION_ENABLE
@ FLY_MODAL_FREELOOK_DISABLE
@ FLY_MODAL_FREELOOK_ENABLE
@ FLY_MODAL_PRECISION_DISABLE
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)