From f3b261a6ffee81e43d7b486ea4ee63f888230e56 Mon Sep 17 00:00:00 2001 From: mrbelowski Date: Mon, 22 Jan 2024 18:59:36 +0000 Subject: [PATCH 1/8] WIP controller orientation overrides --- src/mods/UObjectHook.cpp | 4 +- src/mods/VR.cpp | 7 ++- src/mods/VR.hpp | 66 ++++++++++++++++++++++++++- src/mods/vr/IXRTrackingSystemHook.cpp | 5 +- 4 files changed, 77 insertions(+), 5 deletions(-) diff --git a/src/mods/UObjectHook.cpp b/src/mods/UObjectHook.cpp index a94f3437..08fb86cf 100644 --- a/src/mods/UObjectHook.cpp +++ b/src/mods/UObjectHook.cpp @@ -431,7 +431,7 @@ void UObjectHook::tick_attachments(Rotator* view_rotation, const float wo } glm::vec3 right_hand_position = vr->get_grip_position(vr->get_right_controller_index()); - glm::quat right_hand_rotation = vr->get_aim_rotation(vr->get_right_controller_index()); + glm::quat right_hand_rotation = vr->get_right_controller_aim_rotation_with_offset();// vr->get_aim_rotation(vr->get_right_controller_index()); const float lerp_speed = m_attach_lerp_speed->value() * m_last_delta_time; @@ -453,7 +453,7 @@ void UObjectHook::tick_attachments(Rotator* view_rotation, const float wo const auto original_right_hand_position = right_hand_position - hmd_origin; glm::vec3 left_hand_position = vr->get_grip_position(vr->get_left_controller_index()); - glm::quat left_hand_rotation = vr->get_aim_rotation(vr->get_left_controller_index()); + glm::quat left_hand_rotation = vr->get_left_controller_aim_rotation_with_offset(); // vr->get_aim_rotation(vr->get_left_controller_index()); if (m_attach_lerp_enabled->value()) { auto spherical_distance_left = glm::dot(left_hand_rotation, m_last_left_aim_rotation); diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index b082fe23..d18c1408 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2392,7 +2392,12 @@ void VR::on_draw_sidebar_entry(std::string_view name) { m_aim_speed->draw("Speed"); m_aim_interp->draw("Smoothing"); - + m_left_aim_offset_x_degrees->draw("Left Controller X Rotation"); + m_left_aim_offset_y_degrees->draw("Left Controller Y Rotation"); + m_left_aim_offset_z_degrees->draw("Left Controller Z Rotation"); + m_right_aim_offset_x_degrees->draw("Right Controller X Rotation"); + m_right_aim_offset_y_degrees->draw("Right Controller Y Rotation"); + m_right_aim_offset_z_degrees->draw("Right Controller Z Rotation"); m_aim_modify_player_control_rotation->draw("Modify Player Control Rotation"); ImGui::SameLine(); m_aim_use_pawn_control_rotation->draw("Use Pawn Control Rotation"); diff --git a/src/mods/VR.hpp b/src/mods/VR.hpp index 8836416d..c6ebe872 100644 --- a/src/mods/VR.hpp +++ b/src/mods/VR.hpp @@ -173,6 +173,34 @@ class VR : public Mod { return get_rotation(index, true); } + Matrix4x4f get_left_controller_aim_rotation_with_offset() { + float x_offset_degrees = get_left_aim_offset_x_degrees(); + float y_offset_degrees = get_left_aim_offset_y_degrees(); + float z_offset_degrees = get_left_aim_offset_z_degrees(); + // if there's no offsets defined, return the original: + auto const rotation = get_rotation(get_left_controller_index(), false); + if (x_offset_degrees == 0 && y_offset_degrees == 0 && z_offset_degrees == 0) { + return rotation; + } else { + auto const requested_rotation_offset = utility::math::ue_rotation_matrix(glm::vec3{x_offset_degrees, y_offset_degrees, -z_offset_degrees}); + return rotation * requested_rotation_offset; + } + } + + Matrix4x4f get_right_controller_aim_rotation_with_offset() { + float x_offset_degrees = get_right_aim_offset_x_degrees(); + float y_offset_degrees = get_right_aim_offset_y_degrees(); + float z_offset_degrees = get_right_aim_offset_z_degrees(); + // if there's no offsets defined, return the original: + auto const rotation = get_rotation(get_right_controller_index(), false); + if (x_offset_degrees == 0 && y_offset_degrees == 0 && z_offset_degrees == 0) { + return rotation; + } else { + auto const requested_rotation_offset = utility::math::ue_rotation_matrix(glm::vec3{x_offset_degrees, y_offset_degrees, -z_offset_degrees}); + return rotation * requested_rotation_offset; + } + } + Matrix4x4f get_aim_rotation(uint32_t index) const { return get_rotation(index, false); } @@ -447,6 +475,30 @@ class VR : public Mod { float get_aim_speed() const { return m_aim_speed->value(); } + + float get_left_aim_offset_x_degrees() const { + return m_left_aim_offset_x_degrees->value(); + } + + float get_left_aim_offset_y_degrees() const { + return m_left_aim_offset_y_degrees->value(); + } + + float get_left_aim_offset_z_degrees() const { + return m_left_aim_offset_z_degrees->value(); + } + + float get_right_aim_offset_x_degrees() const { + return m_right_aim_offset_x_degrees->value(); + } + + float get_right_aim_offset_y_degrees() const { + return m_right_aim_offset_y_degrees->value(); + } + + float get_right_aim_offset_z_degrees() const { + return m_right_aim_offset_z_degrees->value(); + } bool is_aim_multiplayer_support_enabled() const { return m_aim_multiplayer_support->value(); @@ -800,7 +852,13 @@ class VR : public Mod { const ModToggle::Ptr m_aim_modify_player_control_rotation{ ModToggle::create(generate_name("AimModifyPlayerControlRotation"), 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) }; + const ModSlider::Ptr m_aim_speed{ModSlider::create(generate_name("AimSpeed"), 0.01f, 25.0f, 15.0f)}; + const ModSlider::Ptr m_left_aim_offset_x_degrees{ModSlider::create(generate_name("LeftAimOffsetXDegrees"), -90.0f, 90.0f, 0.0f)}; + const ModSlider::Ptr m_left_aim_offset_y_degrees{ModSlider::create(generate_name("LeftAimOffsetYDegrees"), -90.0f, 90.0f, 0.0f)}; + const ModSlider::Ptr m_left_aim_offset_z_degrees{ModSlider::create(generate_name("LeftAimOffsetZDegrees"), -90.0f, 90.0f, 0.0f)}; + const ModSlider::Ptr m_right_aim_offset_x_degrees{ModSlider::create(generate_name("RightAimOffsetXDegrees"), -90.0f, 90.0f, 0.0f)}; + const ModSlider::Ptr m_right_aim_offset_y_degrees{ModSlider::create(generate_name("RightAimOffsetYDegrees"), -90.0f, 90.0f, 0.0f)}; + const ModSlider::Ptr m_right_aim_offset_z_degrees{ModSlider::create(generate_name("RightAimOffsetZDegrees"), -90.0f, 90.0f, 0.0f)}; const ModToggle::Ptr m_dpad_shifting{ ModToggle::create(generate_name("DPadShifting"), true) }; const ModCombo::Ptr m_dpad_shifting_method{ ModCombo::create(generate_name("DPadShiftingMethod"), s_dpad_method_names, DPadMethod::RIGHT_TOUCH) }; @@ -914,6 +972,12 @@ class VR : public Mod { *m_aim_modify_player_control_rotation, *m_aim_multiplayer_support, *m_aim_speed, + *m_left_aim_offset_x_degrees, + *m_left_aim_offset_y_degrees, + *m_left_aim_offset_z_degrees, + *m_right_aim_offset_x_degrees, + *m_right_aim_offset_y_degrees, + *m_right_aim_offset_z_degrees, *m_aim_interp, *m_dpad_shifting, *m_dpad_shifting_method, diff --git a/src/mods/vr/IXRTrackingSystemHook.cpp b/src/mods/vr/IXRTrackingSystemHook.cpp index 90b94d59..b01bad92 100644 --- a/src/mods/vr/IXRTrackingSystemHook.cpp +++ b/src/mods/vr/IXRTrackingSystemHook.cpp @@ -1745,7 +1745,10 @@ void IXRTrackingSystemHook::update_view_rotation(sdk::UObject* reference_obj, Ro if (aim_type == VR::AimMethod::RIGHT_CONTROLLER || aim_type == VR::AimMethod::LEFT_CONTROLLER) { const auto controller_index = aim_type == VR::AimMethod::RIGHT_CONTROLLER ? vr->get_right_controller_index() : vr->get_left_controller_index(); - og_controller_rot = glm::quat{vr->get_aim_rotation(controller_index)}; + og_controller_rot = + aim_type == VR::AimMethod::RIGHT_CONTROLLER ? + glm::quat{ vr->get_right_controller_aim_rotation_with_offset() } : + glm::quat{ vr->get_left_controller_aim_rotation_with_offset() }; // glm::quat{vr->get_aim_rotation(controller_index)}; og_controller_pos = glm::vec3{vr->get_aim_position(controller_index)}; right_controller_forward = og_controller_rot * glm::vec3{0.0f, 0.0f, 1.0f}; } else if (aim_type == VR::AimMethod::TWO_HANDED_RIGHT) { // two handed modes are for imitating rifle aiming From 5011e16a4e010c964101a8e02328301553b2a516 Mon Sep 17 00:00:00 2001 From: mrbelowski Date: Mon, 22 Jan 2024 19:20:41 +0000 Subject: [PATCH 2/8] UI labels --- src/mods/VR.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index d18c1408..78ae2ada 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2392,12 +2392,13 @@ void VR::on_draw_sidebar_entry(std::string_view name) { m_aim_speed->draw("Speed"); m_aim_interp->draw("Smoothing"); - m_left_aim_offset_x_degrees->draw("Left Controller X Rotation"); - m_left_aim_offset_y_degrees->draw("Left Controller Y Rotation"); - m_left_aim_offset_z_degrees->draw("Left Controller Z Rotation"); - m_right_aim_offset_x_degrees->draw("Right Controller X Rotation"); - m_right_aim_offset_y_degrees->draw("Right Controller Y Rotation"); - m_right_aim_offset_z_degrees->draw("Right Controller Z Rotation"); + // TODO: the labels describe the effect correctly, rename the variables etc to match + m_left_aim_offset_x_degrees->draw("Left Controller Yaw"); + m_left_aim_offset_y_degrees->draw("Left Controller Roll"); + m_left_aim_offset_z_degrees->draw("Left Controller Pitch"); + m_right_aim_offset_x_degrees->draw("Right Controller Yaw"); + m_right_aim_offset_y_degrees->draw("Right Controller Roll"); + m_right_aim_offset_z_degrees->draw("Right Controller Pitch"); m_aim_modify_player_control_rotation->draw("Modify Player Control Rotation"); ImGui::SameLine(); m_aim_use_pawn_control_rotation->draw("Use Pawn Control Rotation"); From ca2ab916dfe389eab76189c27e3248ff395cc2ae Mon Sep 17 00:00:00 2001 From: mrbelowski Date: Mon, 22 Jan 2024 19:22:55 +0000 Subject: [PATCH 3/8] comment --- src/mods/VR.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index 78ae2ada..f96d3716 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2393,6 +2393,7 @@ void VR::on_draw_sidebar_entry(std::string_view name) { m_aim_speed->draw("Speed"); m_aim_interp->draw("Smoothing"); // TODO: the labels describe the effect correctly, rename the variables etc to match + // and convert to SliderFloat3 compact layout m_left_aim_offset_x_degrees->draw("Left Controller Yaw"); m_left_aim_offset_y_degrees->draw("Left Controller Roll"); m_left_aim_offset_z_degrees->draw("Left Controller Pitch"); From 223923926e982a504ad7fa2c9be2935ebe8b5da1 Mon Sep 17 00:00:00 2001 From: mrbelowski Date: Tue, 23 Jan 2024 20:20:21 +0000 Subject: [PATCH 4/8] WIP - remove some unused methods; add controller x-y-z position offset and UI tidy up. Position offset still needs to be rotated to the HMD frame --- src/mods/UObjectHook.cpp | 8 +- src/mods/VR.cpp | 47 +++++++-- src/mods/VR.hpp | 135 ++++++++++++++++---------- src/mods/vr/IXRTrackingSystemHook.cpp | 7 +- 4 files changed, 129 insertions(+), 68 deletions(-) diff --git a/src/mods/UObjectHook.cpp b/src/mods/UObjectHook.cpp index 08fb86cf..382db506 100644 --- a/src/mods/UObjectHook.cpp +++ b/src/mods/UObjectHook.cpp @@ -430,8 +430,8 @@ void UObjectHook::tick_attachments(Rotator* view_rotation, const float wo return; } - glm::vec3 right_hand_position = vr->get_grip_position(vr->get_right_controller_index()); - glm::quat right_hand_rotation = vr->get_right_controller_aim_rotation_with_offset();// vr->get_aim_rotation(vr->get_right_controller_index()); + glm::vec3 right_hand_position = vr->get_controller_position_with_offset(VR::Side::RIGHT); + glm::quat right_hand_rotation = vr->get_controller_rotation_with_offset(VR::Side::RIGHT);// vr->get_aim_rotation(vr->get_right_controller_index()); const float lerp_speed = m_attach_lerp_speed->value() * m_last_delta_time; @@ -452,8 +452,8 @@ void UObjectHook::tick_attachments(Rotator* view_rotation, const float wo const auto original_right_hand_rotation = right_hand_rotation; const auto original_right_hand_position = right_hand_position - hmd_origin; - glm::vec3 left_hand_position = vr->get_grip_position(vr->get_left_controller_index()); - glm::quat left_hand_rotation = vr->get_left_controller_aim_rotation_with_offset(); // vr->get_aim_rotation(vr->get_left_controller_index()); + glm::vec3 left_hand_position = vr->get_controller_position_with_offset(VR::Side::LEFT); + glm::quat left_hand_rotation = vr->get_controller_rotation_with_offset(VR::Side::LEFT); // vr->get_aim_rotation(vr->get_left_controller_index()); if (m_attach_lerp_enabled->value()) { auto spherical_distance_left = glm::dot(left_hand_rotation, m_last_left_aim_rotation); diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index f96d3716..835e1b80 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2392,14 +2392,7 @@ void VR::on_draw_sidebar_entry(std::string_view name) { m_aim_speed->draw("Speed"); m_aim_interp->draw("Smoothing"); - // TODO: the labels describe the effect correctly, rename the variables etc to match - // and convert to SliderFloat3 compact layout - m_left_aim_offset_x_degrees->draw("Left Controller Yaw"); - m_left_aim_offset_y_degrees->draw("Left Controller Roll"); - m_left_aim_offset_z_degrees->draw("Left Controller Pitch"); - m_right_aim_offset_x_degrees->draw("Right Controller Yaw"); - m_right_aim_offset_y_degrees->draw("Right Controller Roll"); - m_right_aim_offset_z_degrees->draw("Right Controller Pitch"); + m_aim_modify_player_control_rotation->draw("Modify Player Control Rotation"); ImGui::SameLine(); m_aim_use_pawn_control_rotation->draw("Use Pawn Control Rotation"); @@ -2409,6 +2402,44 @@ void VR::on_draw_sidebar_entry(std::string_view name) { ImGui::TreePop(); } + ImGui::SetNextItemOpen(true, ImGuiCond_::ImGuiCond_Once); + if (ImGui::TreeNode("Aim Offsets")) { + ImGui::TextWrapped("Motion Controller Rotation"); + + float left_controller_rotation_offset[] = {m_left_controller_rotation_offset_x->value(), + m_left_controller_rotation_offset_y->value(), m_left_controller_rotation_offset_z->value()}; + if (ImGui::SliderFloat3("Left Rotation Offset", left_controller_rotation_offset, -180.0f, 180.0f)) { + m_left_controller_rotation_offset_x->value() = left_controller_rotation_offset[0]; + m_left_controller_rotation_offset_y->value() = left_controller_rotation_offset[1]; + m_left_controller_rotation_offset_z->value() = left_controller_rotation_offset[2]; + } + float right_controller_rotation_offset[] = {m_right_controller_rotation_offset_x->value(), + m_right_controller_rotation_offset_y->value(), m_right_controller_rotation_offset_z->value()}; + if (ImGui::SliderFloat3("Right Rotation Offset", right_controller_rotation_offset, -180.0f, 180.0f)) { + m_right_controller_rotation_offset_x->value() = right_controller_rotation_offset[0]; + m_right_controller_rotation_offset_y->value() = right_controller_rotation_offset[1]; + m_right_controller_rotation_offset_z->value() = right_controller_rotation_offset[2]; + } + + ImGui::TextWrapped("Motion Controller Position"); + float left_controller_position_offset[] = {m_left_controller_position_offset_x->value(), + m_left_controller_position_offset_y->value(), m_left_controller_position_offset_z->value()}; + if (ImGui::SliderFloat3("Left Position Offset", left_controller_position_offset, -1.0f, 1.0f)) { + m_left_controller_position_offset_x->value() = left_controller_position_offset[0]; + m_left_controller_position_offset_y->value() = left_controller_position_offset[1]; + m_left_controller_position_offset_z->value() = left_controller_position_offset[2]; + } + float right_controller_position_offset[] = {m_right_controller_position_offset_x->value(), + m_right_controller_position_offset_y->value(), m_right_controller_position_offset_z->value()}; + if (ImGui::SliderFloat3("Right Position Offset", right_controller_position_offset, -1.0f, 1.0f)) { + m_right_controller_position_offset_x->value() = right_controller_position_offset[0]; + m_right_controller_position_offset_y->value() = right_controller_position_offset[1]; + m_right_controller_position_offset_z->value() = right_controller_position_offset[2]; + } + + ImGui::TreePop(); + } + ImGui::SetNextItemOpen(true, ImGuiCond_::ImGuiCond_Once); if (ImGui::TreeNode("Snap Turn")) { m_snapturn->draw("Enabled"); diff --git a/src/mods/VR.hpp b/src/mods/VR.hpp index c6ebe872..410790e9 100644 --- a/src/mods/VR.hpp +++ b/src/mods/VR.hpp @@ -54,6 +54,11 @@ class VR : public Mod { GESTURE_HEAD_RIGHT, }; + enum Side : int32_t { + LEFT, + RIGHT + }; + static const inline std::string s_action_pose = "/actions/default/in/Pose"; static const inline std::string s_action_grip_pose = "/actions/default/in/GripPose"; static const inline std::string s_action_trigger = "/actions/default/in/Trigger"; @@ -161,50 +166,40 @@ class VR : public Mod { Matrix4x4f get_transform(uint32_t index, bool grip = true) const; vr::HmdMatrix34_t get_raw_transform(uint32_t index) const; - Vector4f get_grip_position(uint32_t index) const { - return get_position(index, true); - } - Vector4f get_aim_position(uint32_t index) const { return get_position(index, false); } - Matrix4x4f get_grip_rotation(uint32_t index) const { - return get_rotation(index, true); - } - - Matrix4x4f get_left_controller_aim_rotation_with_offset() { - float x_offset_degrees = get_left_aim_offset_x_degrees(); - float y_offset_degrees = get_left_aim_offset_y_degrees(); - float z_offset_degrees = get_left_aim_offset_z_degrees(); + glm::vec3 get_controller_position_with_offset(Side side) { + float x_offset = (side == Side::LEFT) ? get_left_controller_position_offset_x() : get_right_controller_position_offset_x(); + float y_offset = (side == Side::LEFT) ? get_left_controller_position_offset_y() : get_right_controller_position_offset_y(); + float z_offset = (side == Side::LEFT) ? get_left_controller_position_offset_z() : get_right_controller_position_offset_z(); // if there's no offsets defined, return the original: - auto const rotation = get_rotation(get_left_controller_index(), false); - if (x_offset_degrees == 0 && y_offset_degrees == 0 && z_offset_degrees == 0) { - return rotation; + auto const position = get_position((side == Side::LEFT) ? get_left_controller_index() : get_right_controller_index(), false); + if (x_offset == 0 && y_offset == 0 && z_offset == 0) { + return position; } else { - auto const requested_rotation_offset = utility::math::ue_rotation_matrix(glm::vec3{x_offset_degrees, y_offset_degrees, -z_offset_degrees}); - return rotation * requested_rotation_offset; + // TODO: rotate the requested offset to line up with the HMD, *then* apply it. The code below is nonsense: + auto const hmd_direction = glm::extractMatrixRotation(get_hmd_transform(m_frame_count)); + return glm::vec3{position} - glm::vec3({(glm::vec4{z_offset, -y_offset, x_offset, 0} * hmd_direction)}); } } - Matrix4x4f get_right_controller_aim_rotation_with_offset() { - float x_offset_degrees = get_right_aim_offset_x_degrees(); - float y_offset_degrees = get_right_aim_offset_y_degrees(); - float z_offset_degrees = get_right_aim_offset_z_degrees(); + Matrix4x4f get_controller_rotation_with_offset(Side side) { + float x_offset_degrees = (side == Side::LEFT) ? get_left_controller_rotation_offset_x() : get_right_controller_rotation_offset_x(); + float y_offset_degrees = (side == Side::LEFT) ? get_left_controller_rotation_offset_y() : get_right_controller_rotation_offset_y(); + float z_offset_degrees = (side == Side::LEFT) ? get_left_controller_rotation_offset_z() : get_right_controller_rotation_offset_z(); // if there's no offsets defined, return the original: - auto const rotation = get_rotation(get_right_controller_index(), false); + auto const rotation = get_rotation((side == Side::LEFT) ? get_left_controller_index() : get_right_controller_index(), false); if (x_offset_degrees == 0 && y_offset_degrees == 0 && z_offset_degrees == 0) { return rotation; } else { - auto const requested_rotation_offset = utility::math::ue_rotation_matrix(glm::vec3{x_offset_degrees, y_offset_degrees, -z_offset_degrees}); + auto const requested_rotation_offset = + utility::math::ue_rotation_matrix(glm::vec3{y_offset_degrees, z_offset_degrees, -x_offset_degrees}); return rotation * requested_rotation_offset; } } - Matrix4x4f get_aim_rotation(uint32_t index) const { - return get_rotation(index, false); - } - Matrix4x4f get_grip_transform(uint32_t hand_index) const; Matrix4x4f get_aim_transform(uint32_t hand_index) const; @@ -476,30 +471,54 @@ class VR : public Mod { return m_aim_speed->value(); } - float get_left_aim_offset_x_degrees() const { - return m_left_aim_offset_x_degrees->value(); + float get_left_controller_rotation_offset_x() const { + return m_left_controller_rotation_offset_x->value(); } - float get_left_aim_offset_y_degrees() const { - return m_left_aim_offset_y_degrees->value(); + float get_left_controller_rotation_offset_y() const { + return m_left_controller_rotation_offset_y->value(); } - float get_left_aim_offset_z_degrees() const { - return m_left_aim_offset_z_degrees->value(); + float get_left_controller_rotation_offset_z() const { + return m_left_controller_rotation_offset_z->value(); } - float get_right_aim_offset_x_degrees() const { - return m_right_aim_offset_x_degrees->value(); + float get_right_controller_rotation_offset_x() const { + return m_right_controller_rotation_offset_x->value(); } - float get_right_aim_offset_y_degrees() const { - return m_right_aim_offset_y_degrees->value(); + float get_right_controller_rotation_offset_y() const { + return m_right_controller_rotation_offset_y->value(); } - float get_right_aim_offset_z_degrees() const { - return m_right_aim_offset_z_degrees->value(); + float get_right_controller_rotation_offset_z() const { + return m_right_controller_rotation_offset_z->value(); } + float get_left_controller_position_offset_x() const { + return m_left_controller_position_offset_x->value(); + } + + float get_left_controller_position_offset_y() const { + return m_left_controller_position_offset_y->value(); + } + + float get_left_controller_position_offset_z() const { + return m_left_controller_position_offset_z->value(); + } + + float get_right_controller_position_offset_x() const { + return m_right_controller_position_offset_x->value(); + } + + float get_right_controller_position_offset_y() const { + return m_right_controller_position_offset_y->value(); + } + + float get_right_controller_position_offset_z() const { + return m_right_controller_position_offset_z->value(); + } + bool is_aim_multiplayer_support_enabled() const { return m_aim_multiplayer_support->value(); } @@ -852,15 +871,21 @@ class VR : public Mod { const ModToggle::Ptr m_aim_modify_player_control_rotation{ ModToggle::create(generate_name("AimModifyPlayerControlRotation"), 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)}; - const ModSlider::Ptr m_left_aim_offset_x_degrees{ModSlider::create(generate_name("LeftAimOffsetXDegrees"), -90.0f, 90.0f, 0.0f)}; - const ModSlider::Ptr m_left_aim_offset_y_degrees{ModSlider::create(generate_name("LeftAimOffsetYDegrees"), -90.0f, 90.0f, 0.0f)}; - const ModSlider::Ptr m_left_aim_offset_z_degrees{ModSlider::create(generate_name("LeftAimOffsetZDegrees"), -90.0f, 90.0f, 0.0f)}; - const ModSlider::Ptr m_right_aim_offset_x_degrees{ModSlider::create(generate_name("RightAimOffsetXDegrees"), -90.0f, 90.0f, 0.0f)}; - const ModSlider::Ptr m_right_aim_offset_y_degrees{ModSlider::create(generate_name("RightAimOffsetYDegrees"), -90.0f, 90.0f, 0.0f)}; - const ModSlider::Ptr m_right_aim_offset_z_degrees{ModSlider::create(generate_name("RightAimOffsetZDegrees"), -90.0f, 90.0f, 0.0f)}; + const ModSlider::Ptr m_aim_speed{ ModSlider::create(generate_name("AimSpeed"), 0.01f, 25.0f, 15.0f) }; const ModToggle::Ptr m_dpad_shifting{ ModToggle::create(generate_name("DPadShifting"), true) }; const ModCombo::Ptr m_dpad_shifting_method{ ModCombo::create(generate_name("DPadShiftingMethod"), s_dpad_method_names, DPadMethod::RIGHT_TOUCH) }; + const ModSlider::Ptr m_left_controller_rotation_offset_x{ModSlider::create(generate_name("LeftControllerRotationOffsetX"), -180.0f, 180.0f, 0.0f)}; + const ModSlider::Ptr m_left_controller_rotation_offset_y{ModSlider::create(generate_name("LeftControllerRotationOffsetY"), -180.0f, 180.0f, 0.0f)}; + const ModSlider::Ptr m_left_controller_rotation_offset_z{ModSlider::create(generate_name("LeftControllerRotationOffsetZ"), -180.0f, 180.0f, 0.0f)}; + const ModSlider::Ptr m_right_controller_rotation_offset_x{ModSlider::create(generate_name("RightControllerRotationOffsetX"), -180.0f, 180.0f, 0.0f)}; + const ModSlider::Ptr m_right_controller_rotation_offset_y{ModSlider::create(generate_name("RightControllerRotationOffsetY"), -180.0f, 180.0f, 0.0f)}; + const ModSlider::Ptr m_right_controller_rotation_offset_z{ModSlider::create(generate_name("RightControllerRotationOffsetZ"), -180.0f, 180.0f, 0.0f)}; + const ModSlider::Ptr m_left_controller_position_offset_x{ModSlider::create(generate_name("LeftControllerPositionOffsetX"), -1.0f, 1.0f, 0.0f)}; + const ModSlider::Ptr m_left_controller_position_offset_y{ModSlider::create(generate_name("LeftControllerPositionOffsetY"), -1.0f, 1.0f, 0.0f)}; + const ModSlider::Ptr m_left_controller_position_offset_z{ModSlider::create(generate_name("LeftControllerPositionOffsetZ"), -1.0f, 1.0f, 0.0f)}; + const ModSlider::Ptr m_right_controller_position_offset_x{ModSlider::create(generate_name("RightControllerPositionOffsetX"), -1.0f, 1.0f, 0.0f)}; + const ModSlider::Ptr m_right_controller_position_offset_y{ModSlider::create(generate_name("RightControllerPositionOffsetY"), -1.0f, 1.0f, 0.0f)}; + const ModSlider::Ptr m_right_controller_position_offset_z{ModSlider::create(generate_name("RightControllerPositionOffsetZ"), -1.0f, 1.0f, 0.0f)}; struct DPadGestureState { std::recursive_mutex mtx{}; @@ -972,12 +997,18 @@ class VR : public Mod { *m_aim_modify_player_control_rotation, *m_aim_multiplayer_support, *m_aim_speed, - *m_left_aim_offset_x_degrees, - *m_left_aim_offset_y_degrees, - *m_left_aim_offset_z_degrees, - *m_right_aim_offset_x_degrees, - *m_right_aim_offset_y_degrees, - *m_right_aim_offset_z_degrees, + *m_left_controller_rotation_offset_x, + *m_left_controller_rotation_offset_y, + *m_left_controller_rotation_offset_z, + *m_right_controller_rotation_offset_x, + *m_right_controller_rotation_offset_y, + *m_right_controller_rotation_offset_z, + *m_left_controller_position_offset_x, + *m_left_controller_position_offset_y, + *m_left_controller_position_offset_z, + *m_right_controller_position_offset_x, + *m_right_controller_position_offset_y, + *m_right_controller_position_offset_z, *m_aim_interp, *m_dpad_shifting, *m_dpad_shifting_method, diff --git a/src/mods/vr/IXRTrackingSystemHook.cpp b/src/mods/vr/IXRTrackingSystemHook.cpp index b01bad92..accfee15 100644 --- a/src/mods/vr/IXRTrackingSystemHook.cpp +++ b/src/mods/vr/IXRTrackingSystemHook.cpp @@ -1745,10 +1745,9 @@ void IXRTrackingSystemHook::update_view_rotation(sdk::UObject* reference_obj, Ro if (aim_type == VR::AimMethod::RIGHT_CONTROLLER || aim_type == VR::AimMethod::LEFT_CONTROLLER) { const auto controller_index = aim_type == VR::AimMethod::RIGHT_CONTROLLER ? vr->get_right_controller_index() : vr->get_left_controller_index(); - og_controller_rot = - aim_type == VR::AimMethod::RIGHT_CONTROLLER ? - glm::quat{ vr->get_right_controller_aim_rotation_with_offset() } : - glm::quat{ vr->get_left_controller_aim_rotation_with_offset() }; // glm::quat{vr->get_aim_rotation(controller_index)}; + og_controller_rot = aim_type == VR::AimMethod::RIGHT_CONTROLLER ? + glm::quat{ vr->get_controller_rotation_with_offset(VR::Side::RIGHT) } : + glm::quat{ vr->get_controller_rotation_with_offset(VR::Side::LEFT) }; // glm::quat{vr->get_aim_rotation(controller_index)}; og_controller_pos = glm::vec3{vr->get_aim_position(controller_index)}; right_controller_forward = og_controller_rot * glm::vec3{0.0f, 0.0f, 1.0f}; } else if (aim_type == VR::AimMethod::TWO_HANDED_RIGHT) { // two handed modes are for imitating rifle aiming From 3a610e643106e7aadee26bada340b4a8cf8ac173 Mon Sep 17 00:00:00 2001 From: mrbelowski Date: Wed, 24 Jan 2024 13:32:49 +0000 Subject: [PATCH 5/8] added position offset relative to offset rotation; added reset buttons --- src/mods/UObjectHook.cpp | 8 +++--- src/mods/VR.cpp | 21 ++++++++++++++- src/mods/VR.hpp | 39 ++++++++++++++------------- src/mods/vr/IXRTrackingSystemHook.cpp | 4 +-- 4 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/mods/UObjectHook.cpp b/src/mods/UObjectHook.cpp index 382db506..e20657e7 100644 --- a/src/mods/UObjectHook.cpp +++ b/src/mods/UObjectHook.cpp @@ -430,8 +430,8 @@ void UObjectHook::tick_attachments(Rotator* view_rotation, const float wo return; } - glm::vec3 right_hand_position = vr->get_controller_position_with_offset(VR::Side::RIGHT); - glm::quat right_hand_rotation = vr->get_controller_rotation_with_offset(VR::Side::RIGHT);// vr->get_aim_rotation(vr->get_right_controller_index()); + glm::vec3 right_hand_position = vr->get_controller_position_with_offset(VRRuntime::Hand::RIGHT); + glm::quat right_hand_rotation = vr->get_controller_rotation_with_offset(VRRuntime::Hand::RIGHT);// vr->get_aim_rotation(vr->get_right_controller_index()); const float lerp_speed = m_attach_lerp_speed->value() * m_last_delta_time; @@ -452,8 +452,8 @@ void UObjectHook::tick_attachments(Rotator* view_rotation, const float wo const auto original_right_hand_rotation = right_hand_rotation; const auto original_right_hand_position = right_hand_position - hmd_origin; - glm::vec3 left_hand_position = vr->get_controller_position_with_offset(VR::Side::LEFT); - glm::quat left_hand_rotation = vr->get_controller_rotation_with_offset(VR::Side::LEFT); // vr->get_aim_rotation(vr->get_left_controller_index()); + glm::vec3 left_hand_position = vr->get_controller_position_with_offset(VRRuntime::Hand::LEFT); + glm::quat left_hand_rotation = vr->get_controller_rotation_with_offset(VRRuntime::Hand::LEFT); // vr->get_aim_rotation(vr->get_left_controller_index()); if (m_attach_lerp_enabled->value()) { auto spherical_distance_left = glm::dot(left_hand_rotation, m_last_left_aim_rotation); diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index 835e1b80..d8e95a3d 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2413,6 +2413,11 @@ void VR::on_draw_sidebar_entry(std::string_view name) { m_left_controller_rotation_offset_y->value() = left_controller_rotation_offset[1]; m_left_controller_rotation_offset_z->value() = left_controller_rotation_offset[2]; } + if (ImGui::Button("Reset Left Rotation Offsets")) { + m_left_controller_rotation_offset_x->value() = 0.0f; + m_left_controller_rotation_offset_y->value() = 0.0f; + m_left_controller_rotation_offset_z->value() = 0.0f; + } float right_controller_rotation_offset[] = {m_right_controller_rotation_offset_x->value(), m_right_controller_rotation_offset_y->value(), m_right_controller_rotation_offset_z->value()}; if (ImGui::SliderFloat3("Right Rotation Offset", right_controller_rotation_offset, -180.0f, 180.0f)) { @@ -2420,6 +2425,11 @@ void VR::on_draw_sidebar_entry(std::string_view name) { m_right_controller_rotation_offset_y->value() = right_controller_rotation_offset[1]; m_right_controller_rotation_offset_z->value() = right_controller_rotation_offset[2]; } + if (ImGui::Button("Reset Right Rotation Offsets")) { + m_right_controller_rotation_offset_x->value() = 0.0f; + m_right_controller_rotation_offset_y->value() = 0.0f; + m_right_controller_rotation_offset_z->value() = 0.0f; + } ImGui::TextWrapped("Motion Controller Position"); float left_controller_position_offset[] = {m_left_controller_position_offset_x->value(), @@ -2429,6 +2439,11 @@ void VR::on_draw_sidebar_entry(std::string_view name) { m_left_controller_position_offset_y->value() = left_controller_position_offset[1]; m_left_controller_position_offset_z->value() = left_controller_position_offset[2]; } + if (ImGui::Button("Reset Left Position Offsets")) { + m_left_controller_position_offset_x->value() = 0.0f; + m_left_controller_position_offset_y->value() = 0.0f; + m_left_controller_position_offset_z->value() = 0.0f; + } float right_controller_position_offset[] = {m_right_controller_position_offset_x->value(), m_right_controller_position_offset_y->value(), m_right_controller_position_offset_z->value()}; if (ImGui::SliderFloat3("Right Position Offset", right_controller_position_offset, -1.0f, 1.0f)) { @@ -2436,7 +2451,11 @@ void VR::on_draw_sidebar_entry(std::string_view name) { m_right_controller_position_offset_y->value() = right_controller_position_offset[1]; m_right_controller_position_offset_z->value() = right_controller_position_offset[2]; } - + if (ImGui::Button("Reset Right Position Offsets")) { + m_right_controller_position_offset_x->value() = 0.0f; + m_right_controller_position_offset_y->value() = 0.0f; + m_right_controller_position_offset_z->value() = 0.0f; + } ImGui::TreePop(); } diff --git a/src/mods/VR.hpp b/src/mods/VR.hpp index 410790e9..7510ba10 100644 --- a/src/mods/VR.hpp +++ b/src/mods/VR.hpp @@ -54,11 +54,6 @@ class VR : public Mod { GESTURE_HEAD_RIGHT, }; - enum Side : int32_t { - LEFT, - RIGHT - }; - static const inline std::string s_action_pose = "/actions/default/in/Pose"; static const inline std::string s_action_grip_pose = "/actions/default/in/GripPose"; static const inline std::string s_action_trigger = "/actions/default/in/Trigger"; @@ -170,27 +165,35 @@ class VR : public Mod { return get_position(index, false); } - glm::vec3 get_controller_position_with_offset(Side side) { - float x_offset = (side == Side::LEFT) ? get_left_controller_position_offset_x() : get_right_controller_position_offset_x(); - float y_offset = (side == Side::LEFT) ? get_left_controller_position_offset_y() : get_right_controller_position_offset_y(); - float z_offset = (side == Side::LEFT) ? get_left_controller_position_offset_z() : get_right_controller_position_offset_z(); + glm::vec3 get_controller_position_with_offset(VRRuntime::Hand hand) { + float x_offset = (hand == VRRuntime::Hand::LEFT) ? get_left_controller_position_offset_x() : get_right_controller_position_offset_x(); + float y_offset = (hand == VRRuntime::Hand::LEFT) ? get_left_controller_position_offset_y() : get_right_controller_position_offset_y(); + float z_offset = (hand == VRRuntime::Hand::LEFT) ? get_left_controller_position_offset_z() : get_right_controller_position_offset_z(); // if there's no offsets defined, return the original: - auto const position = get_position((side == Side::LEFT) ? get_left_controller_index() : get_right_controller_index(), false); + auto const position = get_position((hand == VRRuntime::Hand::LEFT) ? get_left_controller_index() : get_right_controller_index(), false); if (x_offset == 0 && y_offset == 0 && z_offset == 0) { return position; } else { - // TODO: rotate the requested offset to line up with the HMD, *then* apply it. The code below is nonsense: - auto const hmd_direction = glm::extractMatrixRotation(get_hmd_transform(m_frame_count)); - return glm::vec3{position} - glm::vec3({(glm::vec4{z_offset, -y_offset, x_offset, 0} * hmd_direction)}); + // if we offset the controller by some specified distance we need a frame of reference - what direction is "x"?. If we use + // the HMD direction then turning your head will make the gun move in the world independently of your hand position. If + // we use the controller's direction then the gun will move around when you rotate it (i.e. it will be on the end of an + // invisible 'stick' that's attached to the rotating controller). As there's no other frame of reference that makes any sense here, + // a stick it is. Whether the stick orientation is the offset or raw orientation is another complication + auto const actual_controller_rotation = get_rotation((hand == VRRuntime::Hand::LEFT) ? get_left_controller_index() : get_right_controller_index(), false); + auto const offset_controller_rotation = get_controller_rotation_with_offset(hand); + if (get_left_controller_position_offset_x() < 0) { + return position - offset_controller_rotation * glm::vec4{-x_offset, -y_offset, z_offset, 0}; + } + return position - actual_controller_rotation * glm::vec4{-x_offset, -y_offset, z_offset, 0}; } } - Matrix4x4f get_controller_rotation_with_offset(Side side) { - float x_offset_degrees = (side == Side::LEFT) ? get_left_controller_rotation_offset_x() : get_right_controller_rotation_offset_x(); - float y_offset_degrees = (side == Side::LEFT) ? get_left_controller_rotation_offset_y() : get_right_controller_rotation_offset_y(); - float z_offset_degrees = (side == Side::LEFT) ? get_left_controller_rotation_offset_z() : get_right_controller_rotation_offset_z(); + Matrix4x4f get_controller_rotation_with_offset(VRRuntime::Hand hand) { + float x_offset_degrees = (hand == VRRuntime::Hand::LEFT) ? get_left_controller_rotation_offset_x() : get_right_controller_rotation_offset_x(); + float y_offset_degrees = (hand == VRRuntime::Hand::LEFT) ? get_left_controller_rotation_offset_y() : get_right_controller_rotation_offset_y(); + float z_offset_degrees = (hand == VRRuntime::Hand::LEFT) ? get_left_controller_rotation_offset_z() : get_right_controller_rotation_offset_z(); // if there's no offsets defined, return the original: - auto const rotation = get_rotation((side == Side::LEFT) ? get_left_controller_index() : get_right_controller_index(), false); + auto const rotation = get_rotation((hand == VRRuntime::Hand::LEFT) ? get_left_controller_index() : get_right_controller_index(), false); if (x_offset_degrees == 0 && y_offset_degrees == 0 && z_offset_degrees == 0) { return rotation; } else { diff --git a/src/mods/vr/IXRTrackingSystemHook.cpp b/src/mods/vr/IXRTrackingSystemHook.cpp index accfee15..dd0ad152 100644 --- a/src/mods/vr/IXRTrackingSystemHook.cpp +++ b/src/mods/vr/IXRTrackingSystemHook.cpp @@ -1746,8 +1746,8 @@ void IXRTrackingSystemHook::update_view_rotation(sdk::UObject* reference_obj, Ro if (aim_type == VR::AimMethod::RIGHT_CONTROLLER || aim_type == VR::AimMethod::LEFT_CONTROLLER) { const auto controller_index = aim_type == VR::AimMethod::RIGHT_CONTROLLER ? vr->get_right_controller_index() : vr->get_left_controller_index(); og_controller_rot = aim_type == VR::AimMethod::RIGHT_CONTROLLER ? - glm::quat{ vr->get_controller_rotation_with_offset(VR::Side::RIGHT) } : - glm::quat{ vr->get_controller_rotation_with_offset(VR::Side::LEFT) }; // glm::quat{vr->get_aim_rotation(controller_index)}; + glm::quat{ vr->get_controller_rotation_with_offset(VRRuntime::Hand::RIGHT) } : + glm::quat{ vr->get_controller_rotation_with_offset(VRRuntime::Hand::LEFT) }; // glm::quat{vr->get_aim_rotation(controller_index)}; og_controller_pos = glm::vec3{vr->get_aim_position(controller_index)}; right_controller_forward = og_controller_rot * glm::vec3{0.0f, 0.0f, 1.0f}; } else if (aim_type == VR::AimMethod::TWO_HANDED_RIGHT) { // two handed modes are for imitating rifle aiming From 6ae9672313bf3a6740ba5133a6136e5e89fa40b7 Mon Sep 17 00:00:00 2001 From: mrbelowski Date: Wed, 24 Jan 2024 14:07:17 +0000 Subject: [PATCH 6/8] UI tweak --- src/mods/VR.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index d8e95a3d..270a542f 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2402,56 +2402,53 @@ void VR::on_draw_sidebar_entry(std::string_view name) { ImGui::TreePop(); } - ImGui::SetNextItemOpen(true, ImGuiCond_::ImGuiCond_Once); - if (ImGui::TreeNode("Aim Offsets")) { - ImGui::TextWrapped("Motion Controller Rotation"); - + if (ImGui::TreeNode("Motion Controller Aim Offsets")) { float left_controller_rotation_offset[] = {m_left_controller_rotation_offset_x->value(), m_left_controller_rotation_offset_y->value(), m_left_controller_rotation_offset_z->value()}; - if (ImGui::SliderFloat3("Left Rotation Offset", left_controller_rotation_offset, -180.0f, 180.0f)) { + if (ImGui::SliderFloat3("Left Rotation", left_controller_rotation_offset, -180.0f, 180.0f)) { m_left_controller_rotation_offset_x->value() = left_controller_rotation_offset[0]; m_left_controller_rotation_offset_y->value() = left_controller_rotation_offset[1]; m_left_controller_rotation_offset_z->value() = left_controller_rotation_offset[2]; } - if (ImGui::Button("Reset Left Rotation Offsets")) { + if (ImGui::Button("Reset Left Rotation")) { m_left_controller_rotation_offset_x->value() = 0.0f; m_left_controller_rotation_offset_y->value() = 0.0f; m_left_controller_rotation_offset_z->value() = 0.0f; } float right_controller_rotation_offset[] = {m_right_controller_rotation_offset_x->value(), m_right_controller_rotation_offset_y->value(), m_right_controller_rotation_offset_z->value()}; - if (ImGui::SliderFloat3("Right Rotation Offset", right_controller_rotation_offset, -180.0f, 180.0f)) { + if (ImGui::SliderFloat3("Right Rotation", right_controller_rotation_offset, -180.0f, 180.0f)) { m_right_controller_rotation_offset_x->value() = right_controller_rotation_offset[0]; m_right_controller_rotation_offset_y->value() = right_controller_rotation_offset[1]; m_right_controller_rotation_offset_z->value() = right_controller_rotation_offset[2]; } - if (ImGui::Button("Reset Right Rotation Offsets")) { + if (ImGui::Button("Reset Right Rotation")) { m_right_controller_rotation_offset_x->value() = 0.0f; m_right_controller_rotation_offset_y->value() = 0.0f; m_right_controller_rotation_offset_z->value() = 0.0f; } - - ImGui::TextWrapped("Motion Controller Position"); + ImGui::NewLine(); float left_controller_position_offset[] = {m_left_controller_position_offset_x->value(), m_left_controller_position_offset_y->value(), m_left_controller_position_offset_z->value()}; - if (ImGui::SliderFloat3("Left Position Offset", left_controller_position_offset, -1.0f, 1.0f)) { + if (ImGui::SliderFloat3("Left Position", left_controller_position_offset, -1.0f, 1.0f)) { m_left_controller_position_offset_x->value() = left_controller_position_offset[0]; m_left_controller_position_offset_y->value() = left_controller_position_offset[1]; m_left_controller_position_offset_z->value() = left_controller_position_offset[2]; } - if (ImGui::Button("Reset Left Position Offsets")) { + if (ImGui::Button("Reset Left Position")) { m_left_controller_position_offset_x->value() = 0.0f; m_left_controller_position_offset_y->value() = 0.0f; m_left_controller_position_offset_z->value() = 0.0f; } + ImGui::NewLine(); float right_controller_position_offset[] = {m_right_controller_position_offset_x->value(), m_right_controller_position_offset_y->value(), m_right_controller_position_offset_z->value()}; - if (ImGui::SliderFloat3("Right Position Offset", right_controller_position_offset, -1.0f, 1.0f)) { + if (ImGui::SliderFloat3("Right Position", right_controller_position_offset, -1.0f, 1.0f)) { m_right_controller_position_offset_x->value() = right_controller_position_offset[0]; m_right_controller_position_offset_y->value() = right_controller_position_offset[1]; m_right_controller_position_offset_z->value() = right_controller_position_offset[2]; } - if (ImGui::Button("Reset Right Position Offsets")) { + if (ImGui::Button("Reset Right Position")) { m_right_controller_position_offset_x->value() = 0.0f; m_right_controller_position_offset_y->value() = 0.0f; m_right_controller_position_offset_z->value() = 0.0f; From c6ac6a78de3f8fef9ff9238c13e4d0366c839572 Mon Sep 17 00:00:00 2001 From: mrbelowski Date: Wed, 24 Jan 2024 14:48:48 +0000 Subject: [PATCH 7/8] remove basic controller pitch setting --- src/mods/VR.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index c40df39d..f48fe001 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2376,7 +2376,9 @@ void VR::on_draw_sidebar_entry(std::string_view name) { ImGui::SetNextItemOpen(true, ImGuiCond_::ImGuiCond_Once); if (ImGui::TreeNode("Controller")) { m_joystick_deadzone->draw("VR Joystick Deadzone"); - m_controller_pitch_offset->draw("Controller Pitch Offset"); + + // JB: pitch offset is settable in the separate 'offsets' submenu + // m_controller_pitch_offset->draw("Controller Pitch Offset"); m_dpad_shifting->draw("DPad Shifting"); ImGui::SameLine(); @@ -2443,7 +2445,6 @@ void VR::on_draw_sidebar_entry(std::string_view name) { m_left_controller_position_offset_y->value() = 0.0f; m_left_controller_position_offset_z->value() = 0.0f; } - ImGui::NewLine(); float right_controller_position_offset[] = {m_right_controller_position_offset_x->value(), m_right_controller_position_offset_y->value(), m_right_controller_position_offset_z->value()}; if (ImGui::SliderFloat3("Right Position", right_controller_position_offset, -1.0f, 1.0f)) { From a9bc43a73c2949cd42fd26386b8ba6189553c596 Mon Sep 17 00:00:00 2001 From: mrbelowski Date: Fri, 9 Feb 2024 16:03:48 +0000 Subject: [PATCH 8/8] remove some debug code --- src/mods/VR.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mods/VR.hpp b/src/mods/VR.hpp index 1e895230..4a4c63ae 100644 --- a/src/mods/VR.hpp +++ b/src/mods/VR.hpp @@ -180,10 +180,6 @@ class VR : public Mod { // invisible 'stick' that's attached to the rotating controller). As there's no other frame of reference that makes any sense here, // a stick it is. Whether the stick orientation is the offset or raw orientation is another complication auto const actual_controller_rotation = get_rotation((hand == VRRuntime::Hand::LEFT) ? get_left_controller_index() : get_right_controller_index(), false); - auto const offset_controller_rotation = get_controller_rotation_with_offset(hand); - if (get_left_controller_position_offset_x() < 0) { - return position - offset_controller_rotation * glm::vec4{-x_offset, -y_offset, z_offset, 0}; - } return position - actual_controller_rotation * glm::vec4{-x_offset, -y_offset, z_offset, 0}; } }