From 4edac2143f0091e94fa12ff48f7299de47f7fdf1 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Thu, 13 Nov 2025 00:00:48 +0100 Subject: [PATCH] Remove some unused fields --- client/constants.h | 2 +- client/render/imgui_impl.cpp | 15 ++------------- client/render/imgui_impl.h | 5 +---- client/scenes/lobby.cpp | 1 - 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/client/constants.h b/client/constants.h index 9a29d1c4..8ed9e3e6 100644 --- a/client/constants.h +++ b/client/constants.h @@ -43,7 +43,7 @@ constexpr float scroll_ratio = 10; constexpr float trigger_click_thd = 0.8; // Thresholds on the distance between the fingertip and GUI layers (positive: in front of the GUI, negative: behind the GUI) -constexpr float fingertip_distance_hovering_thd = 0.15; // Max distance to have the cursor hovering +constexpr float fingertip_distance_close_thd = 0.15; // Distance to switch between touch and aim interaction constexpr float fingertip_distance_touching_thd_hi = -0.01; // Distance to register a click constexpr float fingertip_distance_touching_thd_lo = -0.15; // Distance to register a click constexpr float fingertip_distance_stick_thd = -0.02; // Max distance where the fingertip is moved to be on the GUI diff --git a/client/render/imgui_impl.cpp b/client/render/imgui_impl.cpp index d8fc4304..7bd308f7 100644 --- a/client/render/imgui_impl.cpp +++ b/client/render/imgui_impl.cpp @@ -210,9 +210,6 @@ imgui_textures::imgui_textures( std::vector> imgui_context::ray_plane_intersection(const imgui_context::controller_state & in) const { - if (!in.active) - return {}; - std::vector> intersections; for (const auto & i: layers_) @@ -581,20 +578,13 @@ std::vector imgui_context::read_controllers_sta index_tip.pose.position.y, index_tip.pose.position.z}; // aim_orientation is ignored by ray_plane_intersection() for hands - - state.active = true; } compute_pointer_position(state); - if (state.hover_distance < constants::gui::fingertip_distance_hovering_thd) - { - state.fingertip_hovering = true; + if (state.hover_distance < constants::gui::fingertip_distance_close_thd) aim_interaction[ctrl.index] = false; - } else - { state.pointer_position.reset(); - } if (state.hover_distance < constants::gui::fingertip_distance_touching_thd_hi and state.hover_distance > constants::gui::fingertip_distance_touching_thd_lo) state.fingertip_touching = true; @@ -614,7 +604,6 @@ std::vector imgui_context::read_controllers_sta if (auto location = application::locate_controller(ctrl.aim, world, display_time)) { - state.active = true; state.aim_position = location->first + glm::mat3_cast(location->second * ctrl.offset.second) * ctrl.offset.first; state.aim_orientation = location->second * ctrl.offset.second; compute_pointer_position(state); @@ -645,7 +634,7 @@ std::vector imgui_context::read_controllers_sta return new_states; } -void imgui_context::compute_pointer_position(imgui_context::controller_state & state) +void imgui_context::compute_pointer_position(imgui_context::controller_state & state) const { auto intersections = ray_plane_intersection(state); diff --git a/client/render/imgui_impl.h b/client/render/imgui_impl.h index ae335339..98086d70 100644 --- a/client/render/imgui_impl.h +++ b/client/render/imgui_impl.h @@ -109,8 +109,6 @@ public: struct controller_state { - bool active = false; - glm::vec3 aim_position = {0, 0, 0}; glm::quat aim_orientation = {1, 0, 0, 0}; @@ -122,7 +120,6 @@ public: bool squeeze_clicked = false; bool trigger_clicked = false; - bool fingertip_hovering = false; bool fingertip_touching = false; ImGuiMouseSource source = ImGuiMouseSource_Mouse; }; @@ -232,7 +229,7 @@ public: } std::vector> ray_plane_intersection(const controller_state & in) const; - void compute_pointer_position(controller_state & state); + void compute_pointer_position(controller_state & state) const; // Convert position from viewport coordinates to real-world glm::vec3 rw_from_vp(const ImVec2 & position); diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp index ff6b5df4..0ced83fe 100644 --- a/client/scenes/lobby.cpp +++ b/client/scenes/lobby.cpp @@ -542,7 +542,6 @@ std::optional scenes::lobby::check_recenter_action(XrTime predicted_d { // First frame of recentering imgui_context::controller_state state{ - .active = true, .aim_position = aim->first, .aim_orientation = aim->second, };