From 551239bac4de6bd3fb371053f33d5bc209ca934b Mon Sep 17 00:00:00 2001 From: praydog Date: Sun, 24 Dec 2023 16:14:12 -0800 Subject: [PATCH] Aiming: Add "Use Pawn Control Rotation" option --- src/mods/VR.cpp | 2 ++ src/mods/VR.hpp | 6 ++++++ src/mods/vr/FFakeStereoRenderingHook.cpp | 18 ++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index fd5558e3..61366818 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2116,6 +2116,8 @@ void VR::on_draw_sidebar_entry(std::string_view name) { } m_aim_multiplayer_support->draw("Multiplayer Support"); + ImGui::SameLine(); + m_aim_use_pawn_control_rotation->draw("Use Pawn Control Rotation"); m_aim_interp->draw("Smoothing"); m_aim_speed->draw("Speed"); diff --git a/src/mods/VR.hpp b/src/mods/VR.hpp index 20bf6a25..7c771392 100644 --- a/src/mods/VR.hpp +++ b/src/mods/VR.hpp @@ -425,6 +425,10 @@ class VR : public Mod { return m_aim_multiplayer_support->value(); } + bool is_aim_pawn_control_rotation_enabled() const { + return m_aim_use_pawn_control_rotation->value(); + } + bool is_aim_interpolation_enabled() const { return m_aim_interp->value(); } @@ -761,6 +765,7 @@ class VR : public Mod { const ModCombo::Ptr m_aim_method{ ModCombo::create(generate_name("AimMethod"), s_aim_method_names, AimMethod::GAME) }; const ModCombo::Ptr m_movement_orientation{ ModCombo::create(generate_name("MovementOrientation"), s_aim_method_names, AimMethod::GAME) }; AimMethod m_previous_aim_method{ AimMethod::GAME }; + const ModToggle::Ptr m_aim_use_pawn_control_rotation{ ModToggle::create(generate_name("AimUsePawnControlRotation"), false) }; const ModToggle::Ptr m_aim_multiplayer_support{ ModToggle::create(generate_name("AimMPSupport"), false) }; const ModToggle::Ptr m_aim_interp{ ModToggle::create(generate_name("AimInterp"), true, true) }; const ModSlider::Ptr m_aim_speed{ ModSlider::create(generate_name("AimSpeed"), 0.01f, 25.0f, 15.0f) }; @@ -835,6 +840,7 @@ class VR : public Mod { *m_snapturn_angle, *m_aim_method, *m_movement_orientation, + *m_aim_use_pawn_control_rotation, *m_aim_multiplayer_support, *m_aim_speed, *m_aim_interp, diff --git a/src/mods/vr/FFakeStereoRenderingHook.cpp b/src/mods/vr/FFakeStereoRenderingHook.cpp index 582e6b08..1eed6b2b 100644 --- a/src/mods/vr/FFakeStereoRenderingHook.cpp +++ b/src/mods/vr/FFakeStereoRenderingHook.cpp @@ -4103,11 +4103,25 @@ __forceinline void FFakeStereoRenderingHook::calculate_stereo_view_offset( // Roomscale movement // only do it on the right eye pass // if we did it on the left, there would be eye desyncs when the right eye is rendered - if (true_index == 1 && vr->is_roomscale_enabled()) { + if (true_index == 1 && (vr->is_roomscale_enabled() || vr->is_aim_pawn_control_rotation_enabled())) { const auto world = sdk::UEngine::get()->get_world(); if (const auto controller = sdk::UGameplayStatics::get()->get_player_controller(world, 0); controller != nullptr) { - if (const auto pawn = controller->get_acknowledged_pawn(); pawn != nullptr) { + const auto pawn = controller->get_acknowledged_pawn(); + + if (pawn != nullptr && vr->is_aim_pawn_control_rotation_enabled()) { + auto camera_component = (sdk::UObject*)pawn->get_camera_component(); + + if (camera_component != nullptr) { + auto data = camera_component->get_property_data(L"bUsePawnControlRotation"); + + if (data != nullptr) { + *(bool*)data = true; + } + } + } + + if (pawn != nullptr && vr->is_roomscale_enabled()) { const auto pawn_pos = pawn->get_actor_location(); const auto new_pos = pawn_pos - head_offset_flat;