Skip to content

Commit

Permalink
OpenXR: Update got_first_poses only after valid flags are set
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 11, 2023
1 parent 233f597 commit 039a438
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/mods/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,23 +1265,20 @@ void VR::update_hmd_state(bool from_view_extensions, uint32_t frame_count) {
// Update the poses used for the game
// If we used the data directly from the WaitGetPoses call, we would have to lock a different mutex and wait a long time
// This is because the WaitGetPoses call is blocking, and we don't want to block any game logic
{
if (runtime->wants_reset_origin && runtime->ready() && runtime->got_first_poses) {
std::unique_lock _{ runtime->pose_mtx };
set_rotation_offset(glm::identity<glm::quat>());
m_standing_origin = get_position_unsafe(vr::k_unTrackedDeviceIndex_Hmd);

if (runtime->wants_reset_origin && runtime->ready()) {
set_rotation_offset(glm::identity<glm::quat>());
m_standing_origin = get_position_unsafe(vr::k_unTrackedDeviceIndex_Hmd);

runtime->wants_reset_origin = false;
}
runtime->wants_reset_origin = false;
}

runtime->update_matrices(m_nearz, m_farz);

// On first run, set the standing origin to the headset position
if (!runtime->got_first_poses) {
/*if (!runtime->got_first_poses) {
m_standing_origin = get_position(vr::k_unTrackedDeviceIndex_Hmd);
}
}*/

if (!runtime->got_first_poses && runtime->is_openvr()) {
//std::unique_lock _{m_openvr->pose_mtx};
Expand Down
5 changes: 4 additions & 1 deletion src/mods/vr/runtimes/OpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,11 @@ VRRuntime::Error OpenXR::update_poses(bool from_view_extensions, uint32_t frame_
this->grip_matrices[i][3] = Vector4f{*(Vector3f*)&hand.grip_location.pose.position, 1.0f};
}

if (!this->got_first_poses) {
this->got_first_poses = (this->view_space_location.locationFlags & (XR_SPACE_LOCATION_POSITION_VALID_BIT | XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)) != 0;
}

this->needs_pose_update = false;
this->got_first_poses = true;
return VRRuntime::Error::SUCCESS;
}

Expand Down

0 comments on commit 039a438

Please sign in to comment.