Store face tracker in variant
This commit is contained in:
@@ -728,7 +728,7 @@ void scenes::lobby::gui_settings()
|
||||
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);
|
||||
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();
|
||||
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)
|
||||
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({
|
||||
.f = feature::face_tracking,
|
||||
.tooltip_enabled = _("Face tracking is enabled"),
|
||||
.tooltip_disabled = _("Face tracking is disabled"),
|
||||
.icon_enabled = get_face_icon(predicted_display_time),
|
||||
.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_enabled = icon_enabled,
|
||||
.icon_disabled = ICON_FA_FACE_MEH_BLANK,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
#include "utils/overloaded.h"
|
||||
#include "xr/fb_body_tracker.h"
|
||||
#include "xr/fb_face_tracker2.h"
|
||||
#include "xr/htc_body_tracker.h"
|
||||
#include "xr/pico_body_tracker.h"
|
||||
#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 (application::get_fb_face_tracking2_supported())
|
||||
info.face_tracking = from_headset::face_type::fb2;
|
||||
else if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported())
|
||||
info.face_tracking = from_headset::face_type::htc;
|
||||
else if (application::get_pico_face_tracking_supported())
|
||||
info.face_tracking = from_headset::face_type::pico;
|
||||
info.face_tracking = std::visit(utils::overloaded{
|
||||
[](std::monostate &) {
|
||||
return from_headset::face_type::none;
|
||||
},
|
||||
[](xr::fb_face_tracker2 &) {
|
||||
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;
|
||||
|
||||
@@ -261,21 +261,15 @@ void scenes::stream::tracking()
|
||||
break;
|
||||
}
|
||||
|
||||
from_headset::face_type face_tracking = from_headset::face_type::none;
|
||||
if (config.check_feature(feature::face_tracking))
|
||||
const bool face_tracking = config.check_feature(feature::face_tracking);
|
||||
auto & face_tracker = application::get_face_tracker();
|
||||
if (face_tracking)
|
||||
{
|
||||
if (application::get_fb_face_tracking2_supported())
|
||||
face_tracking = from_headset::face_type::fb2;
|
||||
else if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported())
|
||||
face_tracking = from_headset::face_type::htc;
|
||||
else if (application::get_pico_face_tracking_supported())
|
||||
{
|
||||
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();
|
||||
}
|
||||
// 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.
|
||||
if (auto * face_pico = std::get_if<xr::pico_face_tracker>(&face_tracker))
|
||||
face_pico->start();
|
||||
}
|
||||
|
||||
const bool body_tracking = config.check_feature(feature::body_tracking);
|
||||
@@ -430,29 +424,15 @@ void scenes::stream::tracking()
|
||||
},
|
||||
body_tracker);
|
||||
|
||||
if (control.enabled[size_t(tid::face)])
|
||||
if (face_tracking && control.enabled[size_t(tid::face)])
|
||||
{
|
||||
switch (face_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<wivrn::from_headset::tracking::fb_face2>());
|
||||
break;
|
||||
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;
|
||||
}
|
||||
std::visit(utils::overloaded{
|
||||
[](std::monostate &) {},
|
||||
[&](auto & ft) {
|
||||
ft.get_weights(t0 + Δt, packet.face.emplace<typename std::remove_reference_t<decltype(ft)>::packet_type>());
|
||||
},
|
||||
},
|
||||
face_tracker);
|
||||
}
|
||||
}
|
||||
catch (const std::system_error & e)
|
||||
@@ -555,8 +535,8 @@ void scenes::stream::tracking()
|
||||
}
|
||||
}
|
||||
|
||||
if (face_tracking == from_headset::face_type::pico)
|
||||
application::get_pico_face_tracker().stop();
|
||||
if (auto * face_pico = std::get_if<xr::pico_face_tracker>(&face_tracker))
|
||||
face_pico->stop();
|
||||
}
|
||||
|
||||
void scenes::stream::operator()(to_headset::tracking_control && packet)
|
||||
|
||||
Reference in New Issue
Block a user