Store all spaces in an array
This commit is contained in:
@@ -211,9 +211,9 @@ input_profile::input_profile(const std::filesystem::path & json_profile, scene_l
|
||||
|
||||
XrSpace space;
|
||||
if (layout == "left")
|
||||
space = application::left_grip();
|
||||
space = application::space(xr::spaces::grip_left);
|
||||
else if (layout == "right")
|
||||
space = application::right_grip();
|
||||
space = application::space(xr::spaces::grip_right);
|
||||
else
|
||||
continue;
|
||||
|
||||
@@ -292,13 +292,13 @@ void input_profile::apply(XrSpace world_space, XrTime predicted_display_time, bo
|
||||
{
|
||||
for (auto && [space, node]: model_handles)
|
||||
{
|
||||
if (space == application::left_grip() && hide_left)
|
||||
if (space == application::space(xr::spaces::grip_left) && hide_left)
|
||||
{
|
||||
node->visible = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (space == application::right_grip() && hide_right)
|
||||
if (space == application::space(xr::spaces::grip_right) && hide_right)
|
||||
{
|
||||
node->visible = false;
|
||||
continue;
|
||||
|
||||
@@ -372,12 +372,12 @@ std::optional<glm::vec3> scenes::lobby::check_recenter_action(XrTime predicted_d
|
||||
|
||||
if (application::read_action_bool(recenter_left_action).value_or(std::pair{0, false}).second)
|
||||
{
|
||||
aim = application::locate_controller(application::left_aim(), world_space, predicted_display_time);
|
||||
aim = application::locate_controller(application::space(xr::spaces::aim_left), application::space(xr::spaces::world), predicted_display_time);
|
||||
}
|
||||
|
||||
if (application::read_action_bool(recenter_right_action).value_or(std::pair{0, false}).second)
|
||||
{
|
||||
aim = application::locate_controller(application::right_aim(), world_space, predicted_display_time);
|
||||
aim = application::locate_controller(application::space(xr::spaces::aim_right), application::space(xr::spaces::world), predicted_display_time);
|
||||
}
|
||||
|
||||
if (aim)
|
||||
@@ -534,13 +534,14 @@ void scenes::lobby::render(const XrFrameState & frame_state)
|
||||
|
||||
session.begin_frame();
|
||||
|
||||
XrSpace world_space = application::space(xr::spaces::world);
|
||||
auto [flags, views] = session.locate_views(viewconfig, frame_state.predictedDisplayTime, world_space);
|
||||
assert(views.size() == swapchains_lobby.size());
|
||||
|
||||
bool hide_left_controller = false;
|
||||
bool hide_right_controller = false;
|
||||
|
||||
std::optional<std::pair<glm::vec3, glm::quat>> head_position = application::locate_controller(application::view(), world_space, frame_state.predictedDisplayTime);
|
||||
std::optional<std::pair<glm::vec3, glm::quat>> head_position = application::locate_controller(application::space(xr::spaces::view), world_space, frame_state.predictedDisplayTime);
|
||||
std::optional<glm::vec3> new_gui_position;
|
||||
|
||||
if (head_position)
|
||||
@@ -731,7 +732,7 @@ void scenes::lobby::on_focused()
|
||||
}
|
||||
|
||||
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{0.6, 0.4});
|
||||
imgui_ctx.emplace(physical_device, device, queue_family_index, queue, application::space(xr::spaces::world), imgui_inputs, swapchain_imgui, glm::vec2{0.6, 0.4});
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
auto [flags, views] = self->session.locate_views(
|
||||
XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO,
|
||||
self->instance.now(),
|
||||
application::view());
|
||||
application::space(xr::spaces::view));
|
||||
|
||||
assert(views.size() == info.fov.size());
|
||||
|
||||
@@ -209,7 +209,7 @@ void scenes::stream::on_focused()
|
||||
device,
|
||||
queue_family_index,
|
||||
queue,
|
||||
view_space,
|
||||
application::space(xr::spaces::world),
|
||||
std::span<imgui_context::controller>{},
|
||||
swapchain_imgui,
|
||||
glm::vec2{1.0, 0.6666});
|
||||
@@ -734,7 +734,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
XrCompositionLayerProjection layer{
|
||||
.type = XR_TYPE_COMPOSITION_LAYER_PROJECTION,
|
||||
.layerFlags = 0,
|
||||
.space = world_space,
|
||||
.space = application::space(xr::spaces::world),
|
||||
.viewCount = (uint32_t)layer_view.size(),
|
||||
.views = layer_view.data(),
|
||||
};
|
||||
|
||||
@@ -176,16 +176,17 @@ void scenes::stream::tracking()
|
||||
const XrDuration battery_check_interval = 30'000'000'000; // 30s
|
||||
#endif
|
||||
std::vector<std::pair<device_id, XrSpace>> spaces = {
|
||||
{device_id::HEAD, application::view()},
|
||||
{device_id::LEFT_AIM, application::left_aim()},
|
||||
{device_id::LEFT_GRIP, application::left_grip()},
|
||||
{device_id::RIGHT_AIM, application::right_aim()},
|
||||
{device_id::RIGHT_GRIP, application::right_grip()}};
|
||||
{device_id::HEAD, application::space(xr::spaces::view)},
|
||||
{device_id::LEFT_AIM, application::space(xr::spaces::aim_left)},
|
||||
{device_id::LEFT_GRIP, application::space(xr::spaces::grip_left)},
|
||||
{device_id::RIGHT_AIM, application::space(xr::spaces::aim_right)},
|
||||
{device_id::RIGHT_GRIP, application::space(xr::spaces::grip_right)}};
|
||||
|
||||
if (application::get_eye_gaze_supported())
|
||||
spaces.push_back({device_id::EYE_GAZE, application::eye_gaze()});
|
||||
spaces.push_back({device_id::EYE_GAZE, application::space(xr::spaces::eye_gaze)});
|
||||
|
||||
XrSpace view_space = application::view();
|
||||
XrSpace view_space = application::space(xr::spaces::view);
|
||||
XrSpace world_space = application::space(xr::spaces::world);
|
||||
XrDuration tracking_period = 1'000'000; // Send tracking data every 1ms
|
||||
const XrDuration dt = 100'000; // Wake up 0.1ms before measuring the position
|
||||
|
||||
|
||||
Reference in New Issue
Block a user