62 #ifdef WITH_INPUT_NDOF
68 #define USE_TABLET_SUPPORT
71 #define USE_PIXELSIZE_NATIVE_SUPPORT
167 {
WALK_MODAL_TOGGLE,
"GRAVITY_TOGGLE", 0,
"Toggle Gravity",
"Toggle gravity effect"},
232 #ifdef WITH_INPUT_NDOF
234 wmNDOFMotionData *ndof;
271 #ifdef USE_TABLET_SUPPORT
308 #ifdef WITH_INPUT_NDOF
319 const int outter_length = 24;
320 const int inner_length = 14;
390 const float ray_normal[3] = {0, 0, -1};
393 float r_normal_dummy[3];
408 .snap_select = SNAP_ALL,
410 .use_object_edit_cage = true,
419 *r_distance /= walk->
grid;
434 float ray_normal[3] = {0, 0, -1};
449 .snap_select = SNAP_ALL,
458 if (
dot_v3v3(ray_normal, r_normal) > 0) {
463 *ray_distance /= walk->
grid;
490 #ifdef NDOF_WALK_DEBUG
491 puts(
"\n-- walk begin --");
541 walk->
speed =
U.walk_navigation.walk_speed;
555 #ifdef USE_TABLET_SUPPORT
563 #ifdef NDOF_WALK_DRAW_TOOMUCH
570 #ifdef WITH_INPUT_NDOF
595 #ifdef USE_PIXELSIZE_NATIVE_SUPPORT
627 #ifdef WITH_INPUT_NDOF
629 walkApply_ndof(
C, walk,
true);
638 #ifdef NDOF_WALK_DEBUG
639 puts(
"\n-- walk end --");
655 #ifdef WITH_INPUT_NDOF
664 #ifdef USE_TABLET_SUPPORT
690 #ifdef USE_TABLET_SUPPORT
724 #ifdef USE_TABLET_SUPPORT
746 #ifdef WITH_INPUT_NDOF
752 const wmNDOFMotionData *incoming_ndof =
event->customdata;
753 switch (incoming_ndof->progress) {
756 # ifdef NDOF_WALK_DEBUG
757 puts(
"start keeping track of 3D mouse position");
762 # ifdef NDOF_WALK_DEBUG
766 if (walk->ndof ==
NULL) {
772 memcpy(walk->ndof, incoming_ndof,
sizeof(wmNDOFMotionData));
777 # ifdef NDOF_WALK_DEBUG
778 puts(
"stop keeping track of 3D mouse position");
797 switch (event->
val) {
864 #define JUMP_SPEED_MIN 1.0f
865 #define JUMP_TIME_MAX 0.2f
866 #define JUMP_SPEED_MAX sqrtf(2.0f * walk->gravity * walk->jump_height)
910 float loc[3],
nor[3];
926 teleport->
duration =
U.walk_navigation.teleport_time;
942 #undef JUMP_SPEED_MAX
944 #undef JUMP_SPEED_MIN
960 const bool do_rotate,
961 const bool do_translate,
962 const bool is_confirm)
966 const bool use_autokey = is_confirm || walk->
anim_playing;
977 return gravity * (
time *
time) * 0.5f;
982 return velocity / gravity;
987 #define WALK_ROTATE_RELATIVE_FAC 2.2f
988 #define WALK_ROTATE_CONSTANT_FAC DEG2RAD(0.15f)
989 #define WALK_TOP_LIMIT DEG2RADF(85.0f)
990 #define WALK_BOTTOM_LIMIT DEG2RADF(-80.0f)
991 #define WALK_MOVE_SPEED base_speed
992 #define WALK_BOOST_FACTOR ((void)0, walk->speed_factor)
1003 float dvec[3] = {0.0f, 0.0f, 0.0f};
1008 #ifdef NDOF_WALK_DEBUG
1010 static uint iteration = 1;
1011 printf(
"walk timer %d\n", iteration++);
1025 moffset[1] = -moffset[1];
1036 double time_current;
1038 #ifdef NDOF_WALK_DRAW_TOOMUCH
1069 #ifdef USE_TABLET_SUPPORT
1110 if (upvec[2] < 0.0f) {
1111 moffset[0] = -moffset[0];
1118 #ifdef USE_TABLET_SUPPORT
1181 dvec_tmp[0] = direction * rv3d->
viewinv[0][0];
1182 dvec_tmp[1] = direction * rv3d->
viewinv[0][1];
1218 float difference = -100.0f;
1219 float fall_distance;
1231 if (
fabsf(difference) < fall_distance) {
1233 dvec[2] -= difference;
1256 float ray_distance, difference = -100.0f;
1280 if (difference > 0.0f) {
1282 dvec[2] -= difference;
1288 dvec[2] = z_cur - z_new;
1293 dvec[2] = z_cur - z_new;
1341 #undef WALK_ROTATE_RELATIVE_FAC
1342 #undef WALK_TOP_LIMIT
1343 #undef WALK_BOTTOM_LIMIT
1344 #undef WALK_MOVE_SPEED
1345 #undef WALK_BOOST_FACTOR
1348 #ifdef WITH_INPUT_NDOF
1352 bool has_translate, has_rotate;
1354 view3d_ndof_fly(walk->ndof,
1362 if (has_translate || has_rotate) {
1418 bool do_draw =
false;
1427 #ifdef WITH_INPUT_NDOF
1430 walkApply_ndof(
C, walk,
false);
1462 ot->
name =
"Walk Navigation";
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct View3D * CTX_wm_view3d(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)
#define BVH_RAYCAST_DIST_MAX
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 mul_mat3_m4_v3(const float M[4][4], float r[3])
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 axis_angle_to_quat_single(float q[4], const char axis, const float angle)
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
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 float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void negate_v3(float r[3])
MINLINE float normalize_v3_length(float r[3], const float unit_scale)
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
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 PHYS_GLOBAL_GRAVITY
@ USER_WALK_MOUSE_REVERSE
#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 *)
bool ED_transform_snap_object_project_ray(SnapObjectContext *sctx, struct Depsgraph *depsgraph, const struct SnapObjectParams *params, const float ray_origin[3], const float ray_direction[3], float *ray_depth, float r_co[3], float r_no[3])
SnapObjectContext * ED_transform_snap_object_context_create_view3d(struct Scene *scene, int flag, const struct ARegion *region, const struct View3D *v3d)
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx)
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 y
_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 GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
@ GPU_SHADER_2D_UNIFORM_COLOR
Read Guarded memory(de)allocation.
Platform independent time functions.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
struct ARegionType * type
struct PhysicsSettings physics_settings
struct Depsgraph * depsgraph
eWalkMethod navigation_mode
bool need_translation_keyframe
struct View3DCameraControl * v3d_camera_control
bool need_rotation_keyframe
eWalkGravityState gravity_state
struct SnapObjectContext * snap_context
eWalkMethod navigation_mode
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)
__forceinline const avxi abs(const avxi &a)
ccl_device_inline float distance(const float2 &a, const float2 &b)
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)
struct WalkTeleport WalkTeleport
static void walkMoveCamera(bContext *C, WalkInfo *walk, const bool do_rotate, const bool do_translate, const bool is_confirm)
static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *region, void *arg)
static bool walk_floor_distance_get(RegionView3D *rv3d, WalkInfo *walk, const float dvec[3], float *r_distance)
#define WALK_ROTATE_CONSTANT_FAC
#define WALK_ROTATE_RELATIVE_FAC
@ WALK_TELEPORT_STATE_OFF
static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int walkEnd(bContext *C, WalkInfo *walk)
static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void VIEW3D_OT_walk(wmOperatorType *ot)
static float userdef_speed
@ WALK_GRAVITY_STATE_START
@ WALK_GRAVITY_STATE_JUMP
static void walk_cancel(bContext *C, wmOperator *op)
static float getFreeFallDistance(const float gravity, const float time)
static bool walk_ray_cast(RegionView3D *rv3d, WalkInfo *walk, float r_location[3], float r_normal[3], float *ray_distance)
#define WALK_BOOST_FACTOR
static float getVelocityZeroTime(const float gravity, const float velocity)
static void walkEvent(bContext *C, WalkInfo *walk, const wmEvent *event)
static int walkApply(bContext *C, struct WalkInfo *walk, bool is_confirm)
void walk_modal_keymap(wmKeyConfig *keyconf)
@ WALK_MODAL_DIR_LEFT_STOP
@ WALK_MODAL_SLOW_DISABLE
@ WALK_MODAL_DIR_DOWN_STOP
@ WALK_MODAL_DIR_BACKWARD
@ WALK_MODAL_DIR_FORWARD_STOP
@ WALK_MODAL_DIR_BACKWARD_STOP
@ WALK_MODAL_DIR_RIGHT_STOP
@ WALK_MODAL_FAST_DISABLE
static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
static void walk_navigation_mode_set(WalkInfo *walk, eWalkMethod mode)
#define WALK_BOTTOM_LIMIT
void WM_cursor_modal_set(wmWindow *win, int val)
void WM_cursor_modal_restore(wmWindow *win)
bool WM_event_is_last_mousemove(const wmEvent *event)
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_compatible_xy(wmWindow *win, int *x, int *y)
void WM_cursor_warp(wmWindow *win, int x, int y)
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)