switch to stage tracking on client
This commit is contained in:
committed by
Patrick Nicolas
parent
5e55e714aa
commit
2141c66c6e
@@ -131,7 +131,6 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
|
||||
self->network_session->send_control(info);
|
||||
|
||||
self->update_local_floor(self->instance.now());
|
||||
self->network_thread = utils::named_thread("network_thread", &stream::process_packets, self.get());
|
||||
|
||||
self->command_buffer = std::move(self->device.allocateCommandBuffers({
|
||||
@@ -714,7 +713,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
XrCompositionLayerProjection layer{
|
||||
.type = XR_TYPE_COMPOSITION_LAYER_PROJECTION,
|
||||
.layerFlags = 0,
|
||||
.space = local_floor,
|
||||
.space = world_space,
|
||||
.viewCount = (uint32_t)layer_view.size(),
|
||||
.views = layer_view.data(),
|
||||
};
|
||||
@@ -1006,22 +1005,10 @@ scene::meta & scenes::stream::get_meta_scene()
|
||||
return m;
|
||||
}
|
||||
|
||||
void scenes::stream::update_local_floor(XrTime when)
|
||||
{
|
||||
xr::space local = session.create_reference_space(XR_REFERENCE_SPACE_TYPE_LOCAL);
|
||||
xr::space stage = session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE);
|
||||
|
||||
XrSpaceLocation location{
|
||||
.type = XR_TYPE_SPACE_LOCATION,
|
||||
};
|
||||
xrLocateSpace(stage, local, when, &location);
|
||||
|
||||
XrPosef offset{{0, 0, 0, 1}, {location.pose.position.x, location.pose.position.y, 0}};
|
||||
std::lock_guard lock(local_floor_mutex);
|
||||
local_floor = session.create_reference_space(XR_REFERENCE_SPACE_TYPE_LOCAL, offset);
|
||||
}
|
||||
|
||||
void scenes::stream::on_reference_space_changed(XrReferenceSpaceType space, XrTime when)
|
||||
{
|
||||
update_local_floor(when);
|
||||
if (space == XrReferenceSpaceType::XR_REFERENCE_SPACE_TYPE_LOCAL)
|
||||
{
|
||||
local_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,10 +78,9 @@ private:
|
||||
std::unique_ptr<wivrn_session> network_session;
|
||||
std::atomic<bool> exiting = false;
|
||||
std::thread network_thread;
|
||||
std::mutex local_floor_mutex;
|
||||
xr::space local_floor;
|
||||
std::mutex tracking_control_mutex;
|
||||
to_headset::tracking_control tracking_control;
|
||||
std::atomic<bool> local_dirty = false;
|
||||
std::atomic<XrDuration> display_time_phase = 0;
|
||||
std::atomic<XrDuration> display_time_period = 0;
|
||||
std::optional<std::thread> tracking_thread;
|
||||
@@ -230,7 +229,6 @@ private:
|
||||
|
||||
void accumulate_metrics(XrTime predicted_display_time, const std::vector<std::shared_ptr<shard_accumulator::blit_handle>> & blit_handles, const gpu_timestamps & timestamps);
|
||||
XrCompositionLayerQuad plot_performance_metrics(XrTime predicted_display_time);
|
||||
void update_local_floor(XrTime when);
|
||||
void on_reference_space_changed(XrReferenceSpaceType space, XrTime) override;
|
||||
};
|
||||
} // namespace scenes
|
||||
|
||||
@@ -255,14 +255,17 @@ void scenes::stream::tracking()
|
||||
j.fov = i.fov;
|
||||
}
|
||||
|
||||
packet.flags = flags;
|
||||
packet.view_flags = flags;
|
||||
|
||||
packet.state_flags = 0;
|
||||
if (local_dirty.exchange(false))
|
||||
packet.state_flags = xrt::drivers::wivrn::from_headset::tracking::recentered;
|
||||
|
||||
packet.device_poses.clear();
|
||||
std::lock_guard lock(local_floor_mutex);
|
||||
for (auto [device, space]: spaces)
|
||||
{
|
||||
if (enabled(control, device))
|
||||
packet.device_poses.push_back(locate_space(device, space, local_floor, t0 + Δt));
|
||||
packet.device_poses.push_back(locate_space(device, space, world_space, t0 + Δt));
|
||||
}
|
||||
|
||||
send_stream(packet);
|
||||
@@ -272,14 +275,14 @@ void scenes::stream::tracking()
|
||||
if (control.enabled[size_t(tid::left_hand)])
|
||||
{
|
||||
hands.hand = xrt::drivers::wivrn::from_headset::hand_tracking::left;
|
||||
hands.joints = locate_hands(application::get_left_hand(), local_floor, hands.timestamp);
|
||||
hands.joints = locate_hands(application::get_left_hand(), world_space, hands.timestamp);
|
||||
send_stream(hands);
|
||||
}
|
||||
|
||||
if (control.enabled[size_t(tid::right_hand)])
|
||||
{
|
||||
hands.hand = xrt::drivers::wivrn::from_headset::hand_tracking::right;
|
||||
hands.joints = locate_hands(application::get_right_hand(), local_floor, hands.timestamp);
|
||||
hands.joints = locate_hands(application::get_right_hand(), world_space, hands.timestamp);
|
||||
send_stream(hands);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user