review vr stuff, fix controller-ui ray casting

This commit is contained in:
2019-06-05 16:27:29 +02:00
parent 02b92cf382
commit dc9da77cf8
10 changed files with 96 additions and 47 deletions

View File

@@ -87,17 +87,22 @@ void Vive::Update()
h.m[0][0], h.m[1][0], h.m[2][0], 0,
h.m[0][1], h.m[1][1], h.m[2][1], 0,
h.m[0][2], h.m[1][2], h.m[2][2], 0,
0, 0, 0, 1, // rotation only
//h.m[0][3], h.m[1][3], h.m[2][3], 1,
// 0, 0, 0, 1, // rotation only
h.m[0][3], h.m[1][3], h.m[2][3], 1,
};
if (!m_position_valid)
{
m_initial_position = { h.m[0][3], h.m[1][3], h.m[2][3] };
m_position_valid = true;
}
auto mat_proj = glm::make_mat4(data_eye_proj);
auto mat_pose = glm::inverse(glm::make_mat4(data_hmd_pose));
auto mat_eye = glm::inverse(glm::make_mat4(data_eye_pose));
glm::vec3 head_position(h.m[0][3], h.m[1][3], h.m[2][3]);
m_proj[eye] = mat_proj;
m_view[eye] = mat_eye * mat_pose;
m_view[eye] = mat_eye * mat_pose * glm::translate(m_initial_position);
m_pose = glm::make_mat4(data_hmd_pose);
// invalidate controller state
@@ -120,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(-head_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++)