diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index 556acbe2..c4876caa 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include @@ -2781,4 +2783,26 @@ void VR::recenter_view() { const auto new_rotation_offset = glm::normalize(glm::inverse(utility::math::flatten(glm::quat{get_rotation(0)}))); set_rotation_offset(new_rotation_offset); +} + +void VR::process_snapturn() { + if (!m_snapturn_on_frame) { + return; + } + + const auto world = sdk::UEngine::get()->get_world(); + if (const auto controller = sdk::UGameplayStatics::get()->get_player_controller(world, 0); controller != nullptr) { + auto controller_rot = controller->get_control_rotation(); + auto turn_degrees = get_snapturn_angle(); + + if (m_snapturn_left) { + turn_degrees = -turn_degrees; + m_snapturn_left = false; + } + + controller_rot.y += turn_degrees; + controller->set_control_rotation(controller_rot); + } + + m_snapturn_on_frame = false; } \ No newline at end of file diff --git a/src/mods/VR.hpp b/src/mods/VR.hpp index 087b7917..040dfdeb 100644 --- a/src/mods/VR.hpp +++ b/src/mods/VR.hpp @@ -744,12 +744,14 @@ class VR : public Mod { const ModToggle::Ptr m_roomscale_movement_actor_rotation{ ModToggle::create(generate_name("RoomscaleMovementActorRotation"), false) }; // Snap turn settings and globals + void process_snapturn(); + const ModToggle::Ptr m_snapturn{ ModToggle::create(generate_name("SnapTurn"), false) }; const ModSlider::Ptr m_snapturn_joystick_deadzone{ ModSlider::create(generate_name("SnapturnJoystickDeadzone"), 0.01f, 0.99f, 0.2f) }; const ModInt32::Ptr m_snapturn_angle{ ModSliderInt32::create(generate_name("SnapturnTurnAngle"), 1, 359, 45) }; - static inline bool m_snapturn_on_frame{false}; - static inline bool m_snapturn_left{false}; - static inline bool m_was_snapturn_run_on_input{false}; + bool m_snapturn_on_frame{false}; + bool m_snapturn_left{false}; + bool m_was_snapturn_run_on_input{false}; // Aim method and movement orientation are not the same thing, but they can both have the same options const ModCombo::Ptr m_aim_method{ ModCombo::create(generate_name("AimMethod"), s_aim_method_names, AimMethod::GAME) }; diff --git a/src/mods/vr/FFakeStereoRenderingHook.cpp b/src/mods/vr/FFakeStereoRenderingHook.cpp index 18b844a7..582e6b08 100644 --- a/src/mods/vr/FFakeStereoRenderingHook.cpp +++ b/src/mods/vr/FFakeStereoRenderingHook.cpp @@ -4136,21 +4136,7 @@ __forceinline void FFakeStereoRenderingHook::calculate_stereo_view_offset( } // Process snapturn - if (vr->m_snapturn_on_frame) { - const auto world = sdk::UEngine::get()->get_world(); - if (const auto controller = sdk::UGameplayStatics::get()->get_player_controller(world, 0); controller != nullptr) { - auto controller_rot = controller->get_control_rotation(); - auto turn_degrees = vr->get_snapturn_angle(); - - if (vr->m_snapturn_left) { - turn_degrees = -turn_degrees; - vr->m_snapturn_left = false; - } - controller_rot.y += turn_degrees; - controller->set_control_rotation(controller_rot); - } - vr->m_snapturn_on_frame = false; - } + vr->process_snapturn(); } if (!is_full_pass) {