Skip to content

Commit

Permalink
Aiming: Add "Use Pawn Control Rotation" option
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Dec 25, 2023
1 parent 02bea8b commit 551239b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/mods/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
6 changes: 6 additions & 0 deletions src/mods/VR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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) };
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 16 additions & 2 deletions src/mods/vr/FFakeStereoRenderingHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 551239b

Please sign in to comment.