From 602bc38601d6f462440d430ba4d9f2e37a34d3d6 Mon Sep 17 00:00:00 2001 From: praydog Date: Fri, 18 Oct 2024 01:06:08 -0700 Subject: [PATCH] VR: Add Sweep Movement option for Roomscale movement --- src/mods/VR.cpp | 11 +++++++++++ src/mods/VR.hpp | 5 +++++ src/mods/vr/FFakeStereoRenderingHook.cpp | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index 1431a6ee..24155f7d 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2495,6 +2495,17 @@ void VR::on_draw_sidebar_entry(std::string_view name) { if (ImGui::TreeNode("Roomscale Movement")) { m_roomscale_movement->draw("Enabled"); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("When enabled, headset movement will affect the movement of the player character."); + } + + ImGui::SameLine(); + m_roomscale_sweep->draw("Sweep Movement"); + // Draw description of option + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("When enabled, roomscale movement will use a sweep to prevent the player from moving through walls.\nThis also allows physics objects to interact with the player, like doors."); + } + ImGui::TreePop(); } } diff --git a/src/mods/VR.hpp b/src/mods/VR.hpp index fa4ee266..5917b043 100644 --- a/src/mods/VR.hpp +++ b/src/mods/VR.hpp @@ -558,6 +558,10 @@ class VR : public Mod { return m_roomscale_movement->value() && !m_aim_temp_disabled; } + bool is_roomscale_sweep_enabled() const { + return m_roomscale_sweep->value(); + } + bool is_dpad_shifting_enabled() const { return m_dpad_shifting->value(); } @@ -864,6 +868,7 @@ class VR : public Mod { const ModToggle::Ptr m_load_blueprint_code{ ModToggle::create(generate_name("LoadBlueprintCode"), false, true) }; const ModToggle::Ptr m_2d_screen_mode{ ModToggle::create(generate_name("2DScreenMode"), false) }; const ModToggle::Ptr m_roomscale_movement{ ModToggle::create(generate_name("RoomscaleMovement"), false) }; + const ModToggle::Ptr m_roomscale_sweep{ ModToggle::create(generate_name("RoomscaleMovementSweep"), true) }; const ModToggle::Ptr m_swap_controllers{ ModToggle::create(generate_name("SwapControllerInputs"), false) }; const ModCombo::Ptr m_horizontal_projection_override{ModCombo::create(generate_name("HorizontalProjectionOverride"), s_horizontal_projection_override_names)}; const ModCombo::Ptr m_vertical_projection_override{ModCombo::create(generate_name("VerticalProjectionOverride"), s_vertical_projection_override_names)}; diff --git a/src/mods/vr/FFakeStereoRenderingHook.cpp b/src/mods/vr/FFakeStereoRenderingHook.cpp index 22daecbf..b81a2605 100644 --- a/src/mods/vr/FFakeStereoRenderingHook.cpp +++ b/src/mods/vr/FFakeStereoRenderingHook.cpp @@ -4322,7 +4322,9 @@ __forceinline void FFakeStereoRenderingHook::calculate_stereo_view_offset( const auto pawn_pos = pawn->get_actor_location(); const auto new_pos = pawn_pos - head_offset_flat; - pawn->set_actor_location(new_pos, false, false); + // Roomscale sweep option allows the actor to affect the world + // like push doors open, and prevent them from clipping through walls + pawn->set_actor_location(new_pos, vr->is_roomscale_sweep_enabled(), false); // Recenter the standing origin auto current_standing_origin = vr->get_standing_origin();