Change face tracking packet members to a variant

This commit is contained in:
Sapphire
2025-06-01 10:21:47 +02:00
committed by xytovl
parent 908d21ffec
commit c2c94a57bb
5 changed files with 23 additions and 23 deletions
+3 -3
View File
@@ -336,10 +336,10 @@ void scenes::stream::tracking()
case wivrn::from_headset::face_type::none:
break;
case wivrn::from_headset::face_type::fb2:
application::get_fb_face_tracker2().get_weights(t0 + Δt, packet.face.emplace());
application::get_fb_face_tracker2().get_weights(t0 + Δt, packet.face.emplace<wivrn::from_headset::tracking::fb_face2>());
break;
case wivrn::from_headset::face_type::htc: {
auto & face_htc = packet.face_htc.emplace();
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())
@@ -349,7 +349,7 @@ void scenes::stream::tracking()
break;
}
case wivrn::from_headset::face_type::pico:
application::get_pico_face_tracker().get_weights(t0 + Δt, packet.face_pico.emplace());
application::get_pico_face_tracker().get_weights(t0 + Δt, packet.face.emplace<wivrn::from_headset::tracking::pico_face>());
break;
}
}
+2 -3
View File
@@ -278,7 +278,6 @@ struct tracking
bool is_valid;
bool is_eye_following_blendshapes_valid;
};
std::optional<fb_face2> face;
struct htc_face
{
@@ -287,14 +286,14 @@ struct tracking
bool eye_active;
bool lip_active;
};
std::optional<htc_face> face_htc;
struct pico_face
{
std::array<float, XR_BLEND_SHAPE_COUNT_PICO> weights;
bool is_valid;
};
std::optional<pico_face> face_pico;
std::variant<std::monostate, fb_face2, htc_face, pico_face> face;
};
struct trackings
+6 -6
View File
@@ -80,15 +80,15 @@ void wivrn_fb_face2_tracker::update_inputs()
void wivrn_fb_face2_tracker::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
{
if (not(tracking.face and tracking.face->is_valid))
auto * face = std::get_if<from_headset::tracking::fb_face2>(&tracking.face);
if (not(face and face->is_valid))
return;
const auto & face = *tracking.face;
wivrn_fb_face2_data data{
.weights = face.weights,
.confidences = face.confidences,
.is_valid = face.is_valid,
.is_eye_following_blendshapes_valid = face.is_eye_following_blendshapes_valid,
.weights = face->weights,
.confidences = face->confidences,
.is_valid = face->is_valid,
.is_eye_following_blendshapes_valid = face->is_eye_following_blendshapes_valid,
};
if (not face_list.update_tracking(tracking.production_timestamp, tracking.timestamp, data, offset))
+6 -6
View File
@@ -84,15 +84,15 @@ void wivrn_htc_face_tracker::update_inputs()
void wivrn_htc_face_tracker::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
{
if (not(tracking.face_htc))
auto * face = std::get_if<from_headset::tracking::htc_face>(&tracking.face);
if (not face)
return;
const auto & face = *tracking.face_htc;
wivrn_htc_face_data data{
.eye = face.eye,
.lip = face.lip,
.eye_active = face.eye_active,
.lip_active = face.lip_active};
.eye = face->eye,
.lip = face->lip,
.eye_active = face->eye_active,
.lip_active = face->lip_active};
if (not face_list.update_tracking(tracking.production_timestamp, tracking.timestamp, data, offset))
cnx.set_enabled(to_headset::tracking_control::id::face, false);
+6 -5
View File
@@ -84,14 +84,15 @@ void wivrn_pico_face_tracker::update_inputs()
void wivrn_pico_face_tracker::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
{
static std::array<float, XR_FACE_CONFIDENCE2_COUNT_FB> confidences{1.0, 1.0};
if (not(tracking.face_pico and tracking.face_pico->is_valid))
auto * face = std::get_if<from_headset::tracking::pico_face>(&tracking.face);
if (not(face and face->is_valid))
return;
const auto & face = *tracking.face_pico;
std::array<float, XR_FACE_EXPRESSION2_COUNT_FB> weights{};
#define MAP_EXPRESSION(fb, pico) \
weights[fb] = face.weights[pico];
weights[fb] = face->weights[pico];
// Map the blendshapes.
MAP_EXPRESSION(XR_FACE_EXPRESSION2_BROW_LOWERER_L_FB, XR_BS_BROWDOWN_L_PICO);
@@ -170,8 +171,8 @@ void wivrn_pico_face_tracker::update_tracking(const from_headset::tracking & tra
wivrn_fb_face2_data data{
.weights = weights,
.confidences = confidences,
.is_valid = face.is_valid,
.is_eye_following_blendshapes_valid = face.is_valid,
.is_valid = face->is_valid,
.is_eye_following_blendshapes_valid = face->is_valid,
};
if (not face_list.update_tracking(tracking.production_timestamp, tracking.timestamp, data, offset))