fix vr head and controller pos

This commit is contained in:
2019-06-26 18:33:15 +02:00
parent 1bffeb2d03
commit a7f402a9e6
5 changed files with 13 additions and 11 deletions

View File

@@ -91,7 +91,7 @@ void Vive::Update()
h.m[0][3], h.m[1][3], h.m[2][3], 1,
};
if (!m_position_valid)
if (current_pose.bPoseIsValid && !m_position_valid)
{
m_initial_position = { h.m[0][3], h.m[1][3], h.m[2][3] };
m_position_valid = true;
@@ -102,7 +102,7 @@ void Vive::Update()
auto mat_eye = glm::inverse(glm::make_mat4(data_eye_pose));
m_proj[eye] = mat_proj;
m_view[eye] = mat_eye * mat_pose * glm::translate(m_initial_position);
m_view[eye] = mat_eye * mat_pose/* * glm::translate(m_initial_position)*/;
m_pose = glm::make_mat4(data_hmd_pose);
// invalidate controller state
@@ -125,7 +125,7 @@ void Vive::Update()
{
m_controllers[controller_index].m_valid = true;
m_hmd->GetControllerState(id, &m_controllers[controller_index].m_state, sizeof(vr::VRControllerState_t));
m_controllers[controller_index].m_mat = glm::translate(-m_initial_position) * Pose2Mat(poses[id].mDeviceToAbsoluteTracking);
m_controllers[controller_index].m_mat = /*glm::translate(-m_initial_position) * */Pose2Mat(poses[id].mDeviceToAbsoluteTracking);
auto pressed_mask = m_controllers[controller_index].m_state.ulButtonPressed;
for (uint8_t bi = 0; bi < (uint8_t)ViveController::kButton::COUNT; bi++)