50 #ifdef WITH_INPUT_NDOF
56 #define USE_TABLET_SUPPORT
231 #ifdef WITH_INPUT_NDOF
233 wmNDOFMotionData *ndof;
270 #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];
409 .snap_target_select = SCE_SNAP_TARGET_ALL,
411 .edit_mode_type = SNAP_GEOM_EDIT,
420 *r_distance /= walk->
grid;
435 float ray_normal[3] = {0, 0, -1};
451 .snap_target_select = SCE_SNAP_TARGET_ALL,
460 if (
dot_v3v3(ray_normal, r_normal) > 0) {
465 *ray_distance /= walk->
grid;
492 #ifdef NDOF_WALK_DEBUG
493 puts(
"\n-- walk begin --");
505 "Cannot navigate a camera from an external library or non-editable override");
546 walk->
speed =
U.walk_navigation.walk_speed;
561 #ifdef USE_TABLET_SUPPORT
567 #ifdef NDOF_WALK_DRAW_TOOMUCH
574 #ifdef WITH_INPUT_NDOF
612 #ifdef WITH_INPUT_NDOF
614 walkApply_ndof(
C, walk,
true);
623 #ifdef NDOF_WALK_DEBUG
624 puts(
"\n-- walk end --");
640 #ifdef WITH_INPUT_NDOF
664 #ifdef USE_TABLET_SUPPORT
679 #ifdef WITH_INPUT_NDOF
685 const wmNDOFMotionData *incoming_ndof =
event->customdata;
686 switch (incoming_ndof->progress) {
689 # ifdef NDOF_WALK_DEBUG
690 puts(
"start keeping track of 3D mouse position");
695 # ifdef NDOF_WALK_DEBUG
699 if (walk->ndof ==
NULL) {
705 memcpy(walk->ndof, incoming_ndof,
sizeof(wmNDOFMotionData));
710 # ifdef NDOF_WALK_DEBUG
711 puts(
"stop keeping track of 3D mouse position");
730 switch (event->
val) {
797 #define JUMP_SPEED_MIN 1.0f
798 #define JUMP_TIME_MAX 0.2f
799 #define JUMP_SPEED_MAX sqrtf(2.0f * walk->gravity * walk->jump_height)
843 float loc[3],
nor[3];
859 teleport->
duration =
U.walk_navigation.teleport_time;
875 #undef JUMP_SPEED_MAX
877 #undef JUMP_SPEED_MIN
900 const bool do_rotate,
901 const bool do_translate,
902 const bool is_confirm)
906 const bool use_autokey = is_confirm || walk->
anim_playing;
917 return gravity * (
time *
time) * 0.5f;
922 return velocity / gravity;
927 #define WALK_ROTATE_TABLET_FAC 8.8f
928 #define WALK_ROTATE_CONSTANT_FAC DEG2RAD(0.15f)
929 #define WALK_TOP_LIMIT DEG2RADF(85.0f)
930 #define WALK_BOTTOM_LIMIT DEG2RADF(-80.0f)
931 #define WALK_MOVE_SPEED base_speed
932 #define WALK_BOOST_FACTOR ((void)0, walk->speed_factor)
933 #define WALK_ZUP_CORRECT_FAC 0.1f
934 #define WALK_ZUP_CORRECT_ACCEL 0.05f
942 float dvec[3] = {0.0f, 0.0f, 0.0f};
947 #ifdef NDOF_WALK_DEBUG
949 static uint iteration = 1;
950 printf(
"walk timer %d\n", iteration++);
964 moffset[1] = -moffset[1];
978 float time_redraw_clamped;
979 #ifdef NDOF_WALK_DRAW_TOOMUCH
986 time_redraw_clamped =
min_ff(0.05f, time_redraw);
1013 #ifdef USE_TABLET_SUPPORT
1054 if (upvec[2] < 0.0f) {
1055 moffset[0] = -moffset[0];
1062 #ifdef USE_TABLET_SUPPORT
1087 if (
fabsf(upvec[2]) > 0.00001f) {
1088 float roll = upvec[2] * 5.0f;
1150 dvec_tmp[0] = direction * rv3d->
viewinv[0][0];
1151 dvec_tmp[1] = direction * rv3d->
viewinv[0][1];
1188 float difference = -100.0f;
1189 float fall_distance;
1201 if (
fabsf(difference) < fall_distance) {
1203 dvec[2] -= difference;
1226 float ray_distance, difference = -100.0f;
1250 if (difference > 0.0f) {
1252 dvec[2] -= difference;
1258 dvec[2] = z_cur - z_new;
1263 dvec[2] = z_cur - z_new;
1312 #undef WALK_ROTATE_TABLET_FAC
1313 #undef WALK_TOP_LIMIT
1314 #undef WALK_BOTTOM_LIMIT
1315 #undef WALK_MOVE_SPEED
1316 #undef WALK_BOOST_FACTOR
1319 #ifdef WITH_INPUT_NDOF
1323 bool has_translate, has_rotate;
1325 view3d_ndof_fly(walk->ndof,
1333 if (has_translate || has_rotate) {
1389 bool do_draw =
false;
1399 #ifdef WITH_INPUT_NDOF
1402 walkApply_ndof(
C, walk,
false);
1437 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 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)
#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], float angle)
void axis_angle_to_quat_single(float q[4], char axis, float angle)
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
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], 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
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
bool ED_region_draw_cb_exit(struct ARegionType *art, void *handle)
bool ED_transform_snap_object_project_ray(SnapObjectContext *sctx, struct Depsgraph *depsgraph, const View3D *v3d, 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(struct Scene *scene, int flag)
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx)
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 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)
T distance(const T &a, const T &b)
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
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)
struct WalkTeleport WalkTeleport
static void walkMoveCamera(bContext *C, WalkInfo *walk, const bool do_rotate, const bool do_translate, const bool is_confirm)
static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op, const int mval[2])
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_TABLET_FAC
static void walkEvent(WalkInfo *walk, const wmEvent *event)
#define WALK_ROTATE_CONSTANT_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
@ 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_GRAVITY_TOGGLE
@ WALK_MODAL_DIR_BACKWARD_STOP
@ WALK_MODAL_DIR_RIGHT_STOP
@ WALK_MODAL_FAST_DISABLE
static void walk_cancel(bContext *C, wmOperator *op)
static float getFreeFallDistance(const float gravity, const float time)
#define WALK_ZUP_CORRECT_ACCEL
static bool walk_ray_cast(RegionView3D *rv3d, WalkInfo *walk, float r_location[3], float r_normal[3], float *ray_distance)
#define WALK_ZUP_CORRECT_FAC
@ WALK_AXISLOCK_STATE_DONE
@ WALK_AXISLOCK_STATE_OFF
@ WALK_AXISLOCK_STATE_ACTIVE
#define WALK_BOOST_FACTOR
static float getVelocityZeroTime(const float gravity, const float velocity)
static int walkApply(bContext *C, struct WalkInfo *walk, bool is_confirm)
void walk_modal_keymap(wmKeyConfig *keyconf)
static void walk_navigation_mode_set(WalkInfo *walk, eWalkMethod mode)
#define WALK_BOTTOM_LIMIT
void WM_cursor_grab_enable(wmWindow *win, int wrap, bool hide, int bounds[4])
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
#define ISMOUSE_MOTION(event_type)
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)
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)