diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp index 645adec0..43db674e 100644 --- a/client/scenes/lobby.cpp +++ b/client/scenes/lobby.cpp @@ -497,6 +497,16 @@ void scenes::lobby::connect(server_data & data) data.manual); } +void scenes::lobby::check_recenter_gesture(const std::array & joints) +{ + const auto & palm = joints[XR_HAND_JOINT_PALM_EXT].first; + const auto & o = palm.pose.orientation; + glm::quat q{o.w, o.x, o.y, o.z}; + + if (glm::dot(q * glm::vec3(0, 1, 0), glm::vec3(0, -1, 0)) > 0.8) + recenter_gui = true; +} + static std::vector render_layer(std::vector & views, std::vector & swapchains, scene_renderer & renderer, scene_data & data, const std::array & clear_color) { std::vector frames; @@ -610,7 +620,10 @@ void scenes::lobby::render(XrTime predicted_display_time, bool should_render) left_hand->apply(joints); if (joints) + { hide_left_controller = true; + check_recenter_gesture(*joints); + } } if (right_hand) @@ -620,7 +633,10 @@ void scenes::lobby::render(XrTime predicted_display_time, bool should_render) right_hand->apply(joints); if (joints) + { hide_right_controller = true; + check_recenter_gesture(*joints); + } } } diff --git a/client/scenes/lobby.h b/client/scenes/lobby.h index 065f7ba1..3049f155 100644 --- a/client/scenes/lobby.h +++ b/client/scenes/lobby.h @@ -134,6 +134,8 @@ class lobby : public scene_impl void connect(server_data & data); + void check_recenter_gesture(const std::array& joints); + public: virtual ~lobby(); lobby();