55#define USE_TABLET_SUPPORT
183 "Increase Jump Height",
184 "Increase jump height"},
188 "Decrease Jump Height",
189 "Decrease jump height"},
191 {0,
nullptr, 0,
nullptr,
nullptr},
262#ifdef WITH_INPUT_NDOF
264 wmNDOFMotionData *ndof;
300#ifdef USE_TABLET_SUPPORT
338#ifdef WITH_INPUT_NDOF
349 const int outter_length = 24;
350 const int inner_length = 14;
420 const float ray_normal[3] = {0, 0, -1};
422 float location_dummy[3];
423 float normal_dummy[3];
449 *r_distance /= walk->
grid;
462 float *r_ray_distance)
464 float ray_normal[3] = {0, 0, -1};
489 if (
dot_v3v3(ray_normal, r_normal) > 0) {
494 *r_ray_distance /= walk->
grid;
523#ifdef NDOF_WALK_DEBUG
524 puts(
"\n-- walk begin --");
537 "Cannot navigate a camera from an external library or non-editable override");
553 if (
fabsf(
U.walk_navigation.walk_speed -
g_walk.userdef_speed) > 0.1f) {
554 g_walk.base_speed =
U.walk_navigation.walk_speed;
555 g_walk.userdef_speed =
U.walk_navigation.walk_speed;
558 if (
fabsf(
U.walk_navigation.jump_height -
g_walk.userdef_jump_height) > 0.1f) {
559 g_walk.jump_height =
U.walk_navigation.jump_height;
560 g_walk.userdef_jump_height =
U.walk_navigation.jump_height;
585 walk->
speed =
U.walk_navigation.walk_speed;
600#ifdef USE_TABLET_SUPPORT
606#ifdef NDOF_WALK_DRAW_TOOMUCH
613#ifdef WITH_INPUT_NDOF
614 walk->ndof =
nullptr;
651#ifdef WITH_INPUT_NDOF
653 walkApply_ndof(C, walk,
true);
662#ifdef NDOF_WALK_DEBUG
663 puts(
"\n-- walk end --");
677 rv3d->
rflag &= ~RV3D_NAVIGATING;
679#ifdef WITH_INPUT_NDOF
703#ifdef USE_TABLET_SUPPORT
718#ifdef WITH_INPUT_NDOF
724 const wmNDOFMotionData *incoming_ndof =
static_cast<const wmNDOFMotionData *
>(
726 switch (incoming_ndof->progress) {
729# ifdef NDOF_WALK_DEBUG
730 puts(
"start keeping track of 3D mouse position");
736# ifdef NDOF_WALK_DEBUG
740 if (walk->ndof ==
nullptr) {
742 walk->ndof =
static_cast<wmNDOFMotionData *
>(
MEM_dupallocN(incoming_ndof));
746 memcpy(walk->ndof, incoming_ndof,
sizeof(wmNDOFMotionData));
752# ifdef NDOF_WALK_DEBUG
753 puts(
"stop keeping track of 3D mouse position");
758 walk->ndof =
nullptr;
775 switch (event->
val) {
874#define JUMP_SPEED_MIN 1.0f
875#define JUMP_TIME_MAX 0.2f
876#define JUMP_SPEED_MAX sqrtf(2.0f * walk->gravity * walk->jump_height)
921 float loc[3],
nor[3];
937 teleport->
duration =
U.walk_navigation.teleport_time;
974#define JUMP_HEIGHT_FACTOR 1.5f
975#define JUMP_HEIGHT_MIN 0.1f
976#define JUMP_HEIGHT_MAX 10.0f
987#undef JUMP_HEIGHT_FACTOR
988#undef JUMP_HEIGHT_MIN
989#undef JUMP_HEIGHT_MAX
996 const bool do_rotate,
997 const bool do_translate,
998 const bool is_confirm)
1002 const bool use_autokey = is_confirm || walk->
anim_playing;
1013 return gravity * (time *
time) * 0.5f;
1018 return velocity / gravity;
1023#define WALK_ROTATE_TABLET_FAC 8.8f
1024#define WALK_ROTATE_CONSTANT_FAC DEG2RADF(0.15f)
1025#define WALK_TOP_LIMIT DEG2RADF(85.0f)
1026#define WALK_BOTTOM_LIMIT DEG2RADF(-80.0f)
1027#define WALK_MOVE_SPEED (0 ? 0.0f : g_walk.base_speed)
1028#define WALK_JUMP_HEIGHT (0 ? 0.0f : g_walk.jump_height)
1029#define WALK_BOOST_FACTOR ((void)0, walk->speed_factor)
1030#define WALK_ZUP_CORRECT_FAC 0.1f
1031#define WALK_ZUP_CORRECT_ACCEL 0.05f
1039 float dvec[3] = {0.0f, 0.0f, 0.0f};
1044#ifdef NDOF_WALK_DEBUG
1046 static uint iteration = 1;
1047 printf(
"walk timer %d\n", iteration++);
1061 moffset[1] = -moffset[1];
1079 double time_current;
1081 float time_redraw_clamped;
1082#ifdef NDOF_WALK_DRAW_TOOMUCH
1089 time_redraw_clamped =
min_ff(0.05f, time_redraw);
1113 y =
float(moffset[1]);
1116#ifdef USE_TABLET_SUPPORT
1156 if (upvec[2] < 0.0f) {
1157 moffset[0] = -moffset[0];
1161 x =
float(moffset[0]);
1164#ifdef USE_TABLET_SUPPORT
1189 if (
fabsf(upvec[2]) > 0.00001f) {
1190 float roll = upvec[2] * 5.0f;
1254 dvec_tmp[0] = direction * rv3d->
viewinv[0][0];
1255 dvec_tmp[1] = direction * rv3d->
viewinv[0][1];
1307 float difference = -100.0f;
1317 if (
fabsf(difference) < fall_distance) {
1319 dvec[2] -= difference;
1339 float ray_distance, difference = -100.0f;
1360 if (difference > 0.0f) {
1362 dvec[2] -= difference;
1368 dvec[2] = z_cur - z_new;
1373 dvec[2] = z_cur - z_new;
1422#undef WALK_ROTATE_TABLET_FAC
1423#undef WALK_TOP_LIMIT
1424#undef WALK_BOTTOM_LIMIT
1425#undef WALK_MOVE_SPEED
1426#undef WALK_JUMP_HEIGHT
1427#undef WALK_BOOST_FACTOR
1430#ifdef WITH_INPUT_NDOF
1434 bool has_translate, has_rotate;
1436 view3d_ndof_fly(walk->ndof,
1444 if (has_translate || has_rotate) {
1470 WalkInfo *walk = MEM_cnew<WalkInfo>(
"NavigationWalkOperation");
1497 bool do_draw =
false;
1507#ifdef WITH_INPUT_NDOF
1510 walkApply_ndof(C, walk,
false);
1521 const int exit_code =
walkEnd(C, walk);
1550 ot->
name =
"Walk Navigation";
Depsgraph * CTX_data_ensure_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)
#define BVH_RAYCAST_DIST_MAX
MINLINE float max_ff(float a, float b)
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 mat[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 void madd_v3_v3fl(float r[3], const float a[3], float f)
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 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])
MINLINE float normalize_v3_length(float n[3], float unit_length)
MINLINE float normalize_v3(float n[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)
#define ENUM_OPERATORS(_type, _max)
Object is a sort of wrapper for general info.
@ USER_WALK_MOUSE_REVERSE
#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
SnapObjectContext * ED_transform_snap_object_context_create(Scene *scene, int flag)
bool ED_transform_snap_object_project_ray(SnapObjectContext *sctx, Depsgraph *depsgraph, const View3D *v3d, const SnapObjectParams *params, const float ray_start[3], const float ray_normal[3], float *ray_depth, float r_co[3], float r_no[3])
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx)
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
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
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)
float distance(float a, float b)
Frequency::GEOMETRY nor[]
struct ARegionType * type
struct PhysicsSettings physics_settings
eSnapTargetOP snap_target_select
eSnapEditType edit_mode_type
eWalkMethod navigation_mode
eWalkDirectionFlag active_directions
bool need_translation_keyframe
bool need_rotation_keyframe
eWalkGravityState gravity_state
View3DCameraControl * v3d_camera_control
SnapObjectContext * snap_context
eWalkMethod navigation_mode
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)
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])
float userdef_jump_height
static bool walk_floor_distance_get(RegionView3D *rv3d, WalkInfo *walk, const float dvec[3], float *r_distance)
@ WALK_MODAL_DIR_LOCAL_DOWN
@ WALK_MODAL_DIR_LEFT_STOP
@ WALK_MODAL_SLOW_DISABLE
@ WALK_MODAL_DIR_LOCAL_UP
@ WALK_MODAL_DIR_DOWN_STOP
@ WALK_MODAL_DECREASE_JUMP
@ WALK_MODAL_INCREASE_JUMP
@ 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_DIR_LOCAL_DOWN_STOP
@ WALK_MODAL_DIR_LOCAL_UP_STOP
@ WALK_MODAL_FAST_DISABLE
#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)
@ WALK_GRAVITY_STATE_START
@ WALK_GRAVITY_STATE_JUMP
static struct @552 g_walk
static void walk_cancel(bContext *C, wmOperator *op)
static float walk_calc_free_fall_distance(const float gravity, const float time)
static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm)
#define WALK_ZUP_CORRECT_ACCEL
static float walk_calc_velocity_zero_time(const float gravity, const float velocity)
static void drawWalkPixel(const bContext *, ARegion *region, void *arg)
#define WALK_ZUP_CORRECT_FAC
@ WALK_AXISLOCK_STATE_DONE
@ WALK_AXISLOCK_STATE_OFF
@ WALK_AXISLOCK_STATE_ACTIVE
@ WALK_BIT_LOCAL_BACKWARD
#define WALK_BOOST_FACTOR
#define JUMP_HEIGHT_FACTOR
void walk_modal_keymap(wmKeyConfig *keyconf)
static bool walk_ray_cast(RegionView3D *rv3d, WalkInfo *walk, float r_location[3], float r_normal[3], float *r_ray_distance)
static void walk_navigation_mode_set(WalkInfo *walk, eWalkMethod mode)
#define WALK_BOTTOM_LIMIT
void WM_cursor_grab_enable(wmWindow *win, const eWM_CursorWrapAxis wrap, const rcti *wrap_region, const bool hide)
void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2])
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_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_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)