Store face tracker in variant
This commit is contained in:
+21
-45
@@ -1136,40 +1136,6 @@ void application::initialize()
|
|||||||
XrSystemEyeGazeInteractionPropertiesEXT eye_gaze_properties = xr_system_id.eye_gaze_interaction_properties();
|
XrSystemEyeGazeInteractionPropertiesEXT eye_gaze_properties = xr_system_id.eye_gaze_interaction_properties();
|
||||||
spdlog::info(" Eye gaze support: {}", (bool)eye_gaze_properties.supportsEyeGazeInteraction);
|
spdlog::info(" Eye gaze support: {}", (bool)eye_gaze_properties.supportsEyeGazeInteraction);
|
||||||
eye_gaze_supported = eye_gaze_properties.supportsEyeGazeInteraction;
|
eye_gaze_supported = eye_gaze_properties.supportsEyeGazeInteraction;
|
||||||
|
|
||||||
if (eye_gaze_supported)
|
|
||||||
{
|
|
||||||
switch (guess_model())
|
|
||||||
{
|
|
||||||
case model::pico_4_pro:
|
|
||||||
case model::pico_4_enterprise:
|
|
||||||
pico_face_tracking_supported = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
pico_face_tracking_supported = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pico_face_tracking_supported = false;
|
|
||||||
|
|
||||||
spdlog::info(" PICO face tracking support: {}", (bool)pico_face_tracking_supported);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils::contains(xr_extensions, XR_FB_FACE_TRACKING2_EXTENSION_NAME))
|
|
||||||
{
|
|
||||||
XrSystemFaceTrackingProperties2FB fb_face2_properties = xr_system_id.fb_face_tracking2_properties();
|
|
||||||
spdlog::info(" FB face tracking support: {}", (bool)fb_face2_properties.supportsVisualFaceTracking);
|
|
||||||
fb_face_tracking2_supported = fb_face2_properties.supportsVisualFaceTracking;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils::contains(xr_extensions, XR_HTC_FACIAL_TRACKING_EXTENSION_NAME))
|
|
||||||
{
|
|
||||||
XrSystemFacialTrackingPropertiesHTC htc_face_properties = xr_system_id.htc_face_tracking_properties();
|
|
||||||
spdlog::info(" HTC eye tracking support: {}", (bool)htc_face_properties.supportEyeFacialTracking);
|
|
||||||
spdlog::info(" HTC lip tracking support: {}", (bool)htc_face_properties.supportLipFacialTracking);
|
|
||||||
htc_face_tracking_eye_supported = htc_face_properties.supportEyeFacialTracking;
|
|
||||||
htc_face_tracking_lip_supported = htc_face_properties.supportLipFacialTracking;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils::contains(xr_extensions, XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
|
if (utils::contains(xr_extensions, XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
|
||||||
@@ -1216,24 +1182,34 @@ void application::initialize()
|
|||||||
right_hand = xr_session.create_hand_tracker(XR_HAND_RIGHT_EXT);
|
right_hand = xr_session.create_hand_tracker(XR_HAND_RIGHT_EXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fb_face_tracking2_supported)
|
if (utils::contains(xr_extensions, XR_FB_FACE_TRACKING2_EXTENSION_NAME))
|
||||||
{
|
{
|
||||||
fb_face_tracker2 = xr_session.create_fb_face_tracker2();
|
XrSystemFaceTrackingProperties2FB fb_face2_properties = xr_system_id.fb_face_tracking2_properties();
|
||||||
|
spdlog::info(" FB face tracking support: {}", (bool)fb_face2_properties.supportsVisualFaceTracking);
|
||||||
|
if (fb_face2_properties.supportsVisualFaceTracking)
|
||||||
|
face_tracker = xr_session.create_fb_face_tracker2();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (htc_face_tracking_eye_supported)
|
if (std::holds_alternative<std::monostate>(face_tracker) && utils::contains(xr_extensions, XR_HTC_FACIAL_TRACKING_EXTENSION_NAME))
|
||||||
{
|
{
|
||||||
htc_face_tracker_eye = xr_session.create_htc_face_tracker(XR_FACIAL_TRACKING_TYPE_EYE_DEFAULT_HTC);
|
XrSystemFacialTrackingPropertiesHTC htc_face_properties = xr_system_id.htc_face_tracking_properties();
|
||||||
|
spdlog::info(" HTC eye tracking support: {}", (bool)htc_face_properties.supportEyeFacialTracking);
|
||||||
|
spdlog::info(" HTC lip tracking support: {}", (bool)htc_face_properties.supportLipFacialTracking);
|
||||||
|
face_tracker = xr_session.create_htc_face_tracker(htc_face_properties.supportEyeFacialTracking, htc_face_properties.supportLipFacialTracking);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (htc_face_tracking_lip_supported)
|
if (std::holds_alternative<std::monostate>(face_tracker) && eye_gaze_supported)
|
||||||
{
|
{
|
||||||
htc_face_tracker_lip = xr_session.create_htc_face_tracker(XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC);
|
switch (guess_model())
|
||||||
}
|
{
|
||||||
|
case model::pico_4_pro:
|
||||||
if (pico_face_tracking_supported)
|
case model::pico_4_enterprise:
|
||||||
{
|
spdlog::info(" PICO face tracking support: true");
|
||||||
pico_face_tracker = xr_session.create_pico_face_tracker();
|
face_tracker = xr_session.create_pico_face_tracker();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils::contains_all(xr_extensions, std::array{XR_FB_BODY_TRACKING_EXTENSION_NAME, XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME, XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME}))
|
if (utils::contains_all(xr_extensions, std::array{XR_FB_BODY_TRACKING_EXTENSION_NAME, XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME, XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME}))
|
||||||
|
|||||||
+5
-45
@@ -129,17 +129,7 @@ class application : public singleton<application>
|
|||||||
xr::hand_tracker left_hand;
|
xr::hand_tracker left_hand;
|
||||||
xr::hand_tracker right_hand;
|
xr::hand_tracker right_hand;
|
||||||
|
|
||||||
bool fb_face_tracking2_supported = false;
|
std::variant<std::monostate, xr::fb_face_tracker2, xr::htc_face_tracker, xr::pico_face_tracker> face_tracker;
|
||||||
xr::fb_face_tracker2 fb_face_tracker2;
|
|
||||||
|
|
||||||
bool htc_face_tracking_eye_supported = false;
|
|
||||||
xr::htc_face_tracker htc_face_tracker_eye;
|
|
||||||
bool htc_face_tracking_lip_supported = false;
|
|
||||||
xr::htc_face_tracker htc_face_tracker_lip;
|
|
||||||
|
|
||||||
bool pico_face_tracking_supported = false;
|
|
||||||
xr::pico_face_tracker pico_face_tracker;
|
|
||||||
|
|
||||||
std::variant<std::monostate, xr::fb_body_tracker, xr::htc_body_tracker, xr::pico_body_tracker> body_tracker;
|
std::variant<std::monostate, xr::fb_body_tracker, xr::htc_body_tracker, xr::pico_body_tracker> body_tracker;
|
||||||
|
|
||||||
bool eye_gaze_supported = false;
|
bool eye_gaze_supported = false;
|
||||||
@@ -430,24 +420,9 @@ public:
|
|||||||
return instance().hand_tracking_supported;
|
return instance().hand_tracking_supported;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool get_fb_face_tracking2_supported()
|
static bool get_face_tracking_supported()
|
||||||
{
|
{
|
||||||
return instance().fb_face_tracking2_supported;
|
return !std::holds_alternative<std::monostate>(instance().face_tracker);
|
||||||
}
|
|
||||||
|
|
||||||
static bool get_htc_face_tracking_eye_supported()
|
|
||||||
{
|
|
||||||
return instance().htc_face_tracking_eye_supported;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool get_htc_face_tracking_lip_supported()
|
|
||||||
{
|
|
||||||
return instance().htc_face_tracking_lip_supported;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool get_pico_face_tracking_supported()
|
|
||||||
{
|
|
||||||
return instance().pico_face_tracking_supported;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool get_body_tracking_supported()
|
static bool get_body_tracking_supported()
|
||||||
@@ -475,24 +450,9 @@ public:
|
|||||||
return instance().right_hand;
|
return instance().right_hand;
|
||||||
}
|
}
|
||||||
|
|
||||||
static xr::fb_face_tracker2 & get_fb_face_tracker2()
|
static auto & get_face_tracker()
|
||||||
{
|
{
|
||||||
return instance().fb_face_tracker2;
|
return instance().face_tracker;
|
||||||
}
|
|
||||||
|
|
||||||
static xr::htc_face_tracker & get_htc_face_tracker_eye()
|
|
||||||
{
|
|
||||||
return instance().htc_face_tracker_eye;
|
|
||||||
}
|
|
||||||
|
|
||||||
static xr::htc_face_tracker & get_htc_face_tracker_lip()
|
|
||||||
{
|
|
||||||
return instance().htc_face_tracker_lip;
|
|
||||||
}
|
|
||||||
|
|
||||||
static xr::pico_face_tracker & get_pico_face_tracker()
|
|
||||||
{
|
|
||||||
return instance().pico_face_tracker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto & get_body_tracker()
|
static auto & get_body_tracker()
|
||||||
|
|||||||
@@ -106,18 +106,17 @@ bool configuration::check_feature(feature f) const
|
|||||||
{
|
{
|
||||||
case model::htc_vive_focus_3:
|
case model::htc_vive_focus_3:
|
||||||
case model::htc_vive_focus_vision:
|
case model::htc_vive_focus_vision:
|
||||||
[[fallthrough]];
|
|
||||||
case model::htc_vive_xr_elite:
|
case model::htc_vive_xr_elite:
|
||||||
if (not(application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported()))
|
if (not std::holds_alternative<xr::htc_face_tracker>(application::get_face_tracker()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case model::pico_4_pro:
|
case model::pico_4_pro:
|
||||||
case model::pico_4_enterprise:
|
case model::pico_4_enterprise:
|
||||||
if (not application::get_pico_face_tracking_supported())
|
if (not std::holds_alternative<xr::pico_face_tracker>(application::get_face_tracker()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (not application::get_fb_face_tracking2_supported())
|
if (not std::holds_alternative<xr::fb_face_tracker2>(application::get_face_tracker()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -728,7 +728,7 @@ void scenes::lobby::gui_settings()
|
|||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ImGui::BeginDisabled(not(application::get_fb_face_tracking2_supported() or application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported() or application::get_pico_face_tracking_supported()));
|
ImGui::BeginDisabled(not application::get_face_tracking_supported());
|
||||||
bool enabled = config.check_feature(feature::face_tracking);
|
bool enabled = config.check_feature(feature::face_tracking);
|
||||||
if (ImGui::Checkbox(_S("Enable face tracking"), &enabled))
|
if (ImGui::Checkbox(_S("Enable face tracking"), &enabled))
|
||||||
{
|
{
|
||||||
@@ -1400,7 +1400,7 @@ static const char * get_face_icon(XrTime predicted_display_time)
|
|||||||
{
|
{
|
||||||
static const auto w = face_weights();
|
static const auto w = face_weights();
|
||||||
wivrn::from_headset::tracking::fb_face2 expression;
|
wivrn::from_headset::tracking::fb_face2 expression;
|
||||||
application::get_fb_face_tracker2().get_weights(predicted_display_time, expression);
|
std::get<xr::fb_face_tracker2>(application::get_face_tracker()).get_weights(predicted_display_time, expression);
|
||||||
|
|
||||||
if (not expression.is_valid)
|
if (not expression.is_valid)
|
||||||
return ICON_FA_FACE_MEH;
|
return ICON_FA_FACE_MEH;
|
||||||
@@ -1464,24 +1464,16 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (application::get_fb_face_tracking2_supported())
|
if (application::get_face_tracking_supported())
|
||||||
{
|
{
|
||||||
|
const char * icon_enabled = std::holds_alternative<xr::fb_face_tracker2>(application::get_face_tracker())
|
||||||
|
? get_face_icon(predicted_display_time)
|
||||||
|
: ICON_FA_FACE_KISS_WINK_HEART;
|
||||||
items.push_back({
|
items.push_back({
|
||||||
.f = feature::face_tracking,
|
.f = feature::face_tracking,
|
||||||
.tooltip_enabled = _("Face tracking is enabled"),
|
.tooltip_enabled = _("Face tracking is enabled"),
|
||||||
.tooltip_disabled = _("Face tracking is disabled"),
|
.tooltip_disabled = _("Face tracking is disabled"),
|
||||||
.icon_enabled = get_face_icon(predicted_display_time),
|
.icon_enabled = icon_enabled,
|
||||||
.icon_disabled = ICON_FA_FACE_MEH_BLANK,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported() or application::get_pico_face_tracking_supported())
|
|
||||||
{
|
|
||||||
items.push_back({
|
|
||||||
.f = feature::face_tracking,
|
|
||||||
.tooltip_enabled = _("Face tracking is enabled"),
|
|
||||||
.tooltip_disabled = _("Face tracking is disabled"),
|
|
||||||
.icon_enabled = ICON_FA_FACE_KISS_WINK_HEART,
|
|
||||||
.icon_disabled = ICON_FA_FACE_MEH_BLANK,
|
.icon_disabled = ICON_FA_FACE_MEH_BLANK,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "utils/overloaded.h"
|
#include "utils/overloaded.h"
|
||||||
#include "xr/fb_body_tracker.h"
|
#include "xr/fb_body_tracker.h"
|
||||||
|
#include "xr/fb_face_tracker2.h"
|
||||||
#include "xr/htc_body_tracker.h"
|
#include "xr/htc_body_tracker.h"
|
||||||
#include "xr/pico_body_tracker.h"
|
#include "xr/pico_body_tracker.h"
|
||||||
#define GLM_FORCE_RADIANS
|
#define GLM_FORCE_RADIANS
|
||||||
@@ -219,12 +220,21 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
|||||||
|
|
||||||
if (config.check_feature(feature::face_tracking))
|
if (config.check_feature(feature::face_tracking))
|
||||||
{
|
{
|
||||||
if (application::get_fb_face_tracking2_supported())
|
info.face_tracking = std::visit(utils::overloaded{
|
||||||
info.face_tracking = from_headset::face_type::fb2;
|
[](std::monostate &) {
|
||||||
else if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported())
|
return from_headset::face_type::none;
|
||||||
info.face_tracking = from_headset::face_type::htc;
|
},
|
||||||
else if (application::get_pico_face_tracking_supported())
|
[](xr::fb_face_tracker2 &) {
|
||||||
info.face_tracking = from_headset::face_type::pico;
|
return from_headset::face_type::fb2;
|
||||||
|
},
|
||||||
|
[](xr::htc_face_tracker &) {
|
||||||
|
return from_headset::face_type::htc;
|
||||||
|
},
|
||||||
|
[](xr::pico_face_tracker &) {
|
||||||
|
return from_headset::face_type::fb2;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
application::get_face_tracker());
|
||||||
}
|
}
|
||||||
|
|
||||||
info.num_generic_trackers = 0;
|
info.num_generic_trackers = 0;
|
||||||
|
|||||||
@@ -261,21 +261,15 @@ void scenes::stream::tracking()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
from_headset::face_type face_tracking = from_headset::face_type::none;
|
const bool face_tracking = config.check_feature(feature::face_tracking);
|
||||||
if (config.check_feature(feature::face_tracking))
|
auto & face_tracker = application::get_face_tracker();
|
||||||
|
if (face_tracking)
|
||||||
{
|
{
|
||||||
if (application::get_fb_face_tracking2_supported())
|
// We can't start the face tracking on application initialisation like we do for
|
||||||
face_tracking = from_headset::face_type::fb2;
|
// other face trackers due to a Pico runtime bug where face tracking freezes when
|
||||||
else if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported())
|
// the headset is taken off or the application is quit.
|
||||||
face_tracking = from_headset::face_type::htc;
|
if (auto * face_pico = std::get_if<xr::pico_face_tracker>(&face_tracker))
|
||||||
else if (application::get_pico_face_tracking_supported())
|
face_pico->start();
|
||||||
{
|
|
||||||
face_tracking = from_headset::face_type::pico;
|
|
||||||
// We can't start the face tracking on application initialisation like we do for
|
|
||||||
// other face trackers due to a Pico runtime bug where face tracking freezes when
|
|
||||||
// the headset is taken off or the application is quit.
|
|
||||||
application::get_pico_face_tracker().start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool body_tracking = config.check_feature(feature::body_tracking);
|
const bool body_tracking = config.check_feature(feature::body_tracking);
|
||||||
@@ -430,29 +424,15 @@ void scenes::stream::tracking()
|
|||||||
},
|
},
|
||||||
body_tracker);
|
body_tracker);
|
||||||
|
|
||||||
if (control.enabled[size_t(tid::face)])
|
if (face_tracking && control.enabled[size_t(tid::face)])
|
||||||
{
|
{
|
||||||
switch (face_tracking)
|
std::visit(utils::overloaded{
|
||||||
{
|
[](std::monostate &) {},
|
||||||
case wivrn::from_headset::face_type::none:
|
[&](auto & ft) {
|
||||||
break;
|
ft.get_weights(t0 + Δt, packet.face.emplace<typename std::remove_reference_t<decltype(ft)>::packet_type>());
|
||||||
case wivrn::from_headset::face_type::fb2:
|
},
|
||||||
application::get_fb_face_tracker2().get_weights(t0 + Δt, packet.face.emplace<wivrn::from_headset::tracking::fb_face2>());
|
},
|
||||||
break;
|
face_tracker);
|
||||||
case wivrn::from_headset::face_type::htc: {
|
|
||||||
auto & face_htc = packet.face.emplace<wivrn::from_headset::tracking::htc_face>();
|
|
||||||
face_htc.eye_active = false;
|
|
||||||
face_htc.lip_active = false;
|
|
||||||
if (application::get_htc_face_tracking_eye_supported())
|
|
||||||
application::get_htc_face_tracker_eye().get_weights(t0 + Δt, face_htc);
|
|
||||||
if (application::get_htc_face_tracking_lip_supported())
|
|
||||||
application::get_htc_face_tracker_lip().get_weights(t0 + Δt, face_htc);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wivrn::from_headset::face_type::pico:
|
|
||||||
application::get_pico_face_tracker().get_weights(t0 + Δt, packet.face.emplace<wivrn::from_headset::tracking::fb_face2>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::system_error & e)
|
catch (const std::system_error & e)
|
||||||
@@ -555,8 +535,8 @@ void scenes::stream::tracking()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (face_tracking == from_headset::face_type::pico)
|
if (auto * face_pico = std::get_if<xr::pico_face_tracker>(&face_tracker))
|
||||||
application::get_pico_face_tracker().stop();
|
face_pico->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void scenes::stream::operator()(to_headset::tracking_control && packet)
|
void scenes::stream::operator()(to_headset::tracking_control && packet)
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ class fb_face_tracker2 : public utils::handle<XrFaceTracker2FB, destroy_fb_face_
|
|||||||
PFN_xrDestroyFaceTracker2FB xrDestroyFaceTracker2FB{};
|
PFN_xrDestroyFaceTracker2FB xrDestroyFaceTracker2FB{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using packet_type = wivrn::from_headset::tracking::fb_face2;
|
||||||
fb_face_tracker2() = default;
|
fb_face_tracker2() = default;
|
||||||
fb_face_tracker2(instance & inst, XrFaceTracker2FB h);
|
fb_face_tracker2(instance & inst, XrFaceTracker2FB h);
|
||||||
|
|
||||||
void get_weights(XrTime time, struct wivrn::from_headset::tracking::fb_face2 & out_expressions);
|
void get_weights(XrTime time, packet_type & out_expressions);
|
||||||
};
|
};
|
||||||
} // namespace xr
|
} // namespace xr
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* WiVRn VR streaming
|
* WiVRn VR streaming
|
||||||
* Copyright (C) 2024 galister <galister@librevr.org>
|
* Copyright (C) 2024 galister <galister@librevr.org>
|
||||||
|
* Copyright (C) 2025 Sapphire <imsapphire0@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,26 +20,50 @@
|
|||||||
#include "htc_face_tracker.h"
|
#include "htc_face_tracker.h"
|
||||||
#include "wivrn_packets.h"
|
#include "wivrn_packets.h"
|
||||||
#include "xr/instance.h"
|
#include "xr/instance.h"
|
||||||
|
#include "xr/session.h"
|
||||||
#include <openxr/openxr.h>
|
#include <openxr/openxr.h>
|
||||||
|
|
||||||
static PFN_xrDestroyFacialTrackerHTC xrDestroyFacialTrackerHTC{};
|
xr::htc_face_tracker::htc_face_tracker(instance & inst, session & s, bool eye, bool lip) :
|
||||||
|
s(s)
|
||||||
XrResult xr::destroy_htc_face_tracker(XrFacialTrackerHTC id)
|
|
||||||
{
|
{
|
||||||
return xrDestroyFacialTrackerHTC(id);
|
if (!eye && !lip)
|
||||||
}
|
return;
|
||||||
|
|
||||||
xr::htc_face_tracker::htc_face_tracker(instance & inst, XrFacialTrackerHTC h, XrFacialTrackingTypeHTC facialTrackingTypeHTC)
|
xrCreateFacialTrackerHTC = inst.get_proc<PFN_xrCreateFacialTrackerHTC>("xrCreateFacialTrackerHTC");
|
||||||
{
|
|
||||||
id = h;
|
|
||||||
xrGetFacialExpressionsHTC = inst.get_proc<PFN_xrGetFacialExpressionsHTC>("xrGetFacialExpressionsHTC");
|
xrGetFacialExpressionsHTC = inst.get_proc<PFN_xrGetFacialExpressionsHTC>("xrGetFacialExpressionsHTC");
|
||||||
xrDestroyFacialTrackerHTC = inst.get_proc<PFN_xrDestroyFacialTrackerHTC>("xrDestroyFacialTrackerHTC");
|
xrDestroyFacialTrackerHTC = inst.get_proc<PFN_xrDestroyFacialTrackerHTC>("xrDestroyFacialTrackerHTC");
|
||||||
trackerType = facialTrackingTypeHTC;
|
|
||||||
|
XrFacialTrackerCreateInfoHTC create_info{
|
||||||
|
.type = XR_TYPE_FACIAL_TRACKER_CREATE_INFO_HTC,
|
||||||
|
.next = nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (eye)
|
||||||
|
{
|
||||||
|
create_info.facialTrackingType = XR_FACIAL_TRACKING_TYPE_EYE_DEFAULT_HTC;
|
||||||
|
xrCreateFacialTrackerHTC(s, &create_info, &this->eye);
|
||||||
|
}
|
||||||
|
if (lip)
|
||||||
|
{
|
||||||
|
create_info.facialTrackingType = XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC;
|
||||||
|
xrCreateFacialTrackerHTC(s, &create_info, &this->lip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void xr::htc_face_tracker::get_weights(XrTime time, wivrn::from_headset::tracking::htc_face & out_expressions)
|
xr::htc_face_tracker::~htc_face_tracker()
|
||||||
{
|
{
|
||||||
if (!id || !xrGetFacialExpressionsHTC)
|
if (!xrDestroyFacialTrackerHTC)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (eye)
|
||||||
|
CHECK_XR(xrDestroyFacialTrackerHTC(std::exchange(eye, nullptr)));
|
||||||
|
if (lip)
|
||||||
|
CHECK_XR(xrDestroyFacialTrackerHTC(std::exchange(lip, nullptr)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void xr::htc_face_tracker::get_weights(XrTime time, packet_type & out_expressions)
|
||||||
|
{
|
||||||
|
if (!(eye || lip) || !xrGetFacialExpressionsHTC)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XrFacialExpressionsHTC expressions{
|
XrFacialExpressionsHTC expressions{
|
||||||
@@ -47,25 +72,18 @@ void xr::htc_face_tracker::get_weights(XrTime time, wivrn::from_headset::trackin
|
|||||||
.sampleTime = time,
|
.sampleTime = time,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool * is_active;
|
if (eye)
|
||||||
|
|
||||||
switch (trackerType)
|
|
||||||
{
|
{
|
||||||
case XR_FACIAL_TRACKING_TYPE_EYE_DEFAULT_HTC:
|
expressions.expressionCount = out_expressions.eye.size();
|
||||||
expressions.expressionCount = out_expressions.eye.size();
|
expressions.expressionWeightings = out_expressions.eye.data();
|
||||||
expressions.expressionWeightings = out_expressions.eye.data();
|
CHECK_XR(xrGetFacialExpressionsHTC(eye, &expressions));
|
||||||
is_active = &out_expressions.eye_active;
|
out_expressions.eye_active = expressions.isActive;
|
||||||
break;
|
}
|
||||||
case XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC:
|
if (lip)
|
||||||
expressions.expressionCount = out_expressions.lip.size();
|
{
|
||||||
expressions.expressionWeightings = out_expressions.lip.data();
|
expressions.expressionCount = out_expressions.lip.size();
|
||||||
is_active = &out_expressions.lip_active;
|
expressions.expressionWeightings = out_expressions.lip.data();
|
||||||
break;
|
CHECK_XR(xrGetFacialExpressionsHTC(lip, &expressions));
|
||||||
default:
|
out_expressions.lip_active = expressions.isActive;
|
||||||
throw std::system_error(1, std::generic_category(), "htc_face_tracker with unknown trackerType");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_XR(xrGetFacialExpressionsHTC(id, &expressions));
|
|
||||||
|
|
||||||
*is_active = expressions.isActive;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* WiVRn VR streaming
|
* WiVRn VR streaming
|
||||||
* Copyright (C) 2024 galister <galister@librevr.org>
|
* Copyright (C) 2024 galister <galister@librevr.org>
|
||||||
|
* Copyright (C) 2025 Sapphire <imsapphire0@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -25,19 +26,23 @@
|
|||||||
namespace xr
|
namespace xr
|
||||||
{
|
{
|
||||||
class instance;
|
class instance;
|
||||||
|
class session;
|
||||||
|
|
||||||
XrResult destroy_htc_face_tracker(XrFacialTrackerHTC);
|
class htc_face_tracker
|
||||||
|
|
||||||
class htc_face_tracker : public utils::handle<XrFacialTrackerHTC, destroy_htc_face_tracker>
|
|
||||||
{
|
{
|
||||||
|
XrSession s;
|
||||||
|
XrFacialTrackerHTC eye{};
|
||||||
|
XrFacialTrackerHTC lip{};
|
||||||
|
PFN_xrCreateFacialTrackerHTC xrCreateFacialTrackerHTC{};
|
||||||
PFN_xrGetFacialExpressionsHTC xrGetFacialExpressionsHTC{};
|
PFN_xrGetFacialExpressionsHTC xrGetFacialExpressionsHTC{};
|
||||||
PFN_xrDestroyFacialTrackerHTC xrDestroyFacialTrackerHTC{};
|
PFN_xrDestroyFacialTrackerHTC xrDestroyFacialTrackerHTC{};
|
||||||
XrFacialTrackingTypeHTC trackerType{};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using packet_type = wivrn::from_headset::tracking::htc_face;
|
||||||
htc_face_tracker() = default;
|
htc_face_tracker() = default;
|
||||||
htc_face_tracker(instance & inst, XrFacialTrackerHTC h, XrFacialTrackingTypeHTC facialTrackingTypeHTC);
|
htc_face_tracker(instance & inst, session & s, bool eye, bool lip);
|
||||||
|
~htc_face_tracker();
|
||||||
|
|
||||||
void get_weights(XrTime time, struct wivrn::from_headset::tracking::htc_face & out_expressions);
|
void get_weights(XrTime time, packet_type & out_expressions);
|
||||||
};
|
};
|
||||||
} // namespace xr
|
} // namespace xr
|
||||||
|
|||||||
@@ -40,12 +40,13 @@ class pico_face_tracker
|
|||||||
bool started{};
|
bool started{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using packet_type = wivrn::from_headset::tracking::fb_face2;
|
||||||
pico_face_tracker() = default;
|
pico_face_tracker() = default;
|
||||||
pico_face_tracker(instance & inst, session & s);
|
pico_face_tracker(instance & inst, session & s);
|
||||||
~pico_face_tracker();
|
~pico_face_tracker();
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
void get_weights(XrTime time, struct wivrn::from_headset::tracking::fb_face2 & out_expressions);
|
void get_weights(XrTime time, packet_type & out_expressions);
|
||||||
};
|
};
|
||||||
} // namespace xr
|
} // namespace xr
|
||||||
|
|||||||
+2
-14
@@ -123,21 +123,9 @@ xr::fb_face_tracker2 xr::session::create_fb_face_tracker2()
|
|||||||
return {*inst, ft};
|
return {*inst, ft};
|
||||||
}
|
}
|
||||||
|
|
||||||
xr::htc_face_tracker xr::session::create_htc_face_tracker(XrFacialTrackingTypeHTC facialTrackingType)
|
xr::htc_face_tracker xr::session::create_htc_face_tracker(bool eye, bool lip)
|
||||||
{
|
{
|
||||||
XrFacialTrackerCreateInfoHTC create_info{
|
return {*inst, *this, eye, lip};
|
||||||
.type = XR_TYPE_FACIAL_TRACKER_CREATE_INFO_HTC,
|
|
||||||
.next = nullptr,
|
|
||||||
.facialTrackingType = facialTrackingType,
|
|
||||||
};
|
|
||||||
|
|
||||||
XrFacialTrackerHTC ft;
|
|
||||||
|
|
||||||
auto xrCreateFacialTrackerHTC = inst->get_proc<PFN_xrCreateFacialTrackerHTC>("xrCreateFacialTrackerHTC");
|
|
||||||
assert(xrCreateFacialTrackerHTC);
|
|
||||||
|
|
||||||
CHECK_XR(xrCreateFacialTrackerHTC(id, &create_info, &ft));
|
|
||||||
return {*inst, ft, facialTrackingType};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xr::pico_face_tracker xr::session::create_pico_face_tracker()
|
xr::pico_face_tracker xr::session::create_pico_face_tracker()
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ public:
|
|||||||
space create_action_space(XrAction action, const XrPosef & pose = {{0, 0, 0, 1}, {0, 0, 0}});
|
space create_action_space(XrAction action, const XrPosef & pose = {{0, 0, 0, 1}, {0, 0, 0}});
|
||||||
hand_tracker create_hand_tracker(XrHandEXT hand, XrHandJointSetEXT hand_joint_set = XR_HAND_JOINT_SET_DEFAULT_EXT);
|
hand_tracker create_hand_tracker(XrHandEXT hand, XrHandJointSetEXT hand_joint_set = XR_HAND_JOINT_SET_DEFAULT_EXT);
|
||||||
fb_face_tracker2 create_fb_face_tracker2();
|
fb_face_tracker2 create_fb_face_tracker2();
|
||||||
htc_face_tracker create_htc_face_tracker(XrFacialTrackingTypeHTC);
|
htc_face_tracker create_htc_face_tracker(bool eye, bool lip);
|
||||||
pico_face_tracker create_pico_face_tracker();
|
pico_face_tracker create_pico_face_tracker();
|
||||||
fb_body_tracker create_fb_body_tracker();
|
fb_body_tracker create_fb_body_tracker();
|
||||||
htc_body_tracker create_htc_body_tracker();
|
htc_body_tracker create_htc_body_tracker();
|
||||||
|
|||||||
@@ -198,7 +198,6 @@ enum face_type : uint8_t
|
|||||||
none,
|
none,
|
||||||
fb2,
|
fb2,
|
||||||
htc,
|
htc,
|
||||||
pico,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct headset_info_packet
|
struct headset_info_packet
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto face = get_info().face_tracking;
|
auto face = get_info().face_tracking;
|
||||||
if (face == from_headset::face_type::fb2 || face == from_headset::face_type::pico || is_forced_extension("FB_face_tracking2"))
|
if (face == from_headset::face_type::fb2 || is_forced_extension("FB_face_tracking2"))
|
||||||
{
|
{
|
||||||
fb_face2_tracker = std::make_unique<wivrn_fb_face2_tracker>(&hmd, *this);
|
fb_face2_tracker = std::make_unique<wivrn_fb_face2_tracker>(&hmd, *this);
|
||||||
static_roles.face = fb_face2_tracker.get();
|
static_roles.face = fb_face2_tracker.get();
|
||||||
|
|||||||
Reference in New Issue
Block a user