Skip to content

Commit

Permalink
UObjectHook: Fix "Attach HMD" not accounting for rotation offset
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jul 20, 2024
1 parent 0de855e commit c185d4e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mods/UObjectHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ void UObjectHook::tick_attachments(Rotator<float>* view_rotation, const float wo
update_overlaps(1, overlapped_components);
}

const auto head_rotation = glm::normalize(vqi_norm * (rotation_offset * glm::quat{vr->get_rotation(0)}));
const auto head_euler = glm::degrees(utility::math::euler_angles_from_steamvr(head_rotation));

for (auto& it : comps) {
if (!is_using_controllers && it.second->hand != 2) {
continue;
Expand All @@ -715,11 +718,8 @@ void UObjectHook::tick_attachments(Rotator<float>* view_rotation, const float wo
glm::radians(-orig_rotation.z));
const auto orig_rotation_quat = glm::quat{orig_rotation_mat};

const auto head_rotation = vqi_norm * glm::quat{vr->get_rotation(0)};

const auto& hand_rotation = state.hand != 2 ? (state.hand == 1 ? right_hand_rotation : left_hand_rotation) : head_rotation;
const auto& hand_position = state.hand != 2 ? (state.hand == 1 ? right_hand_position : left_hand_position) : final_position;
const auto head_euler = glm::degrees(utility::math::euler_angles_from_steamvr(head_rotation));
const auto& hand_euler = state.hand != 2 ? (state.hand == 1 ? right_hand_euler : left_hand_euler) : head_euler;

const auto adjusted_rotation = hand_rotation * glm::inverse(state.rotation_offset);
Expand Down

0 comments on commit c185d4e

Please sign in to comment.