Don't send haptics when focusing with hand
This commit is contained in:
@@ -314,38 +314,40 @@ void imgui_context::new_frame(XrTime display_time)
|
||||
|
||||
controller_state & new_state = new_states.emplace_back();
|
||||
|
||||
if (auto joints = ctrl.hand.locate(world, display_time))
|
||||
if (ctrl.hand)
|
||||
{
|
||||
XrHandJointLocationEXT & index_tip = (*joints)[XR_HAND_JOINT_INDEX_TIP_EXT].first;
|
||||
if (index_tip.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
if (auto joints = ctrl.hand->locate(world, display_time))
|
||||
{
|
||||
new_state.aim_position = {
|
||||
index_tip.pose.position.x,
|
||||
index_tip.pose.position.y,
|
||||
index_tip.pose.position.z};
|
||||
|
||||
new_state.aim_orientation = orientation_;
|
||||
|
||||
new_state.active = true;
|
||||
auto position_distance = ray_plane_intersection(new_state);
|
||||
|
||||
if (position_distance)
|
||||
XrHandJointLocationEXT & index_tip = (*joints)[XR_HAND_JOINT_INDEX_TIP_EXT].first;
|
||||
if (index_tip.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
{
|
||||
new_state.hover_distance = std::abs(position_distance->second);
|
||||
new_state.aim_position = {
|
||||
index_tip.pose.position.x,
|
||||
index_tip.pose.position.y,
|
||||
index_tip.pose.position.z};
|
||||
|
||||
if (std::abs(position_distance->second) < 0.1f)
|
||||
new_state.fingertip_hovered = true;
|
||||
new_state.aim_orientation = orientation_;
|
||||
|
||||
new_state.active = true;
|
||||
auto position_distance = ray_plane_intersection(new_state);
|
||||
|
||||
if (position_distance)
|
||||
{
|
||||
new_state.hover_distance = std::abs(position_distance->second);
|
||||
|
||||
if (std::abs(position_distance->second) < 0.1f)
|
||||
new_state.fingertip_hovered = true;
|
||||
else
|
||||
new_state.active = false;
|
||||
|
||||
if (new_state.hover_distance < 0.02)
|
||||
new_state.fingertip_touched = true;
|
||||
}
|
||||
else
|
||||
new_state.active = false;
|
||||
|
||||
if (new_state.hover_distance < 0.02)
|
||||
new_state.fingertip_touched = true;
|
||||
new_state.hover_distance = 1e10;
|
||||
}
|
||||
else
|
||||
new_state.hover_distance = 1e10;
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto location = application::locate_controller(ctrl.aim, world, display_time))
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
XrAction scroll; // XR_ACTION_TYPE_VECTOR2F_INPUT
|
||||
// TODO: thresholds?
|
||||
|
||||
xr::hand_tracker & hand;
|
||||
xr::hand_tracker * hand = nullptr;
|
||||
};
|
||||
|
||||
struct controller_state
|
||||
|
||||
+15
-3
@@ -735,22 +735,34 @@ void scenes::lobby::on_focused()
|
||||
}
|
||||
recenter_action = get_action("recenter").first;
|
||||
|
||||
std::array imgui_inputs{
|
||||
std::vector imgui_inputs{
|
||||
imgui_context::controller{
|
||||
.aim = get_action_space("left_aim"),
|
||||
.trigger = get_action("left_trigger").first,
|
||||
.squeeze = get_action("left_squeeze").first,
|
||||
.scroll = get_action("left_scroll").first,
|
||||
.hand = application::get_left_hand(),
|
||||
},
|
||||
imgui_context::controller{
|
||||
.aim = get_action_space("right_aim"),
|
||||
.trigger = get_action("right_trigger").first,
|
||||
.squeeze = get_action("right_squeeze").first,
|
||||
.scroll = get_action("right_scroll").first,
|
||||
.hand = application::get_right_hand(),
|
||||
},
|
||||
};
|
||||
if (auto & hand = application::get_left_hand())
|
||||
{
|
||||
imgui_inputs.push_back(
|
||||
{
|
||||
.hand = &hand,
|
||||
});
|
||||
}
|
||||
if (auto & hand = application::get_right_hand())
|
||||
{
|
||||
imgui_inputs.push_back(
|
||||
{
|
||||
.hand = &hand,
|
||||
});
|
||||
}
|
||||
|
||||
swapchain_imgui = xr::swapchain(session, device, swapchain_format, 1500, 1000);
|
||||
imgui_ctx.emplace(physical_device, device, queue_family_index, queue, world_space, imgui_inputs, swapchain_imgui, glm::vec2{1.0, 0.6666});
|
||||
|
||||
Reference in New Issue
Block a user