Overrideable foveation center
This commit is contained in:
@@ -245,6 +245,15 @@ configuration::configuration(xr::system & system)
|
||||
|
||||
if (system.passthrough_supported() == xr::system::passthrough_type::no_passthrough)
|
||||
passthrough_enabled = false;
|
||||
|
||||
if (auto val = root["override_foveation_enable"]; val.is_bool())
|
||||
override_foveation_enable = val.get_bool();
|
||||
|
||||
if (auto val = root["override_foveation_pitch"]; val.is_double())
|
||||
override_foveation_pitch = val.get_double();
|
||||
|
||||
if (auto val = root["override_foveation_distance"]; val.is_double())
|
||||
override_foveation_distance = val.get_double();
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
@@ -361,5 +370,8 @@ void configuration::save()
|
||||
for (auto & [key, value]: features)
|
||||
json << "," << key << ":" << std::boolalpha << value;
|
||||
json << ",\"virtual_keyboard_layout\":" << json_string(virtual_keyboard_layout);
|
||||
json << ",\"override_foveation_enable\":" << std::boolalpha << override_foveation_enable;
|
||||
json << ",\"override_foveation_pitch\":" << override_foveation_pitch;
|
||||
json << ",\"override_foveation_distance\":" << override_foveation_distance;
|
||||
json << "}";
|
||||
}
|
||||
|
||||
@@ -78,6 +78,10 @@ public:
|
||||
|
||||
std::string virtual_keyboard_layout = "QWERTY";
|
||||
|
||||
bool override_foveation_enable = false;
|
||||
float override_foveation_pitch = 10 * M_PI / 180;
|
||||
float override_foveation_distance = 3;
|
||||
|
||||
bool check_feature(feature f) const;
|
||||
void set_feature(feature f, bool state);
|
||||
|
||||
@@ -90,6 +94,7 @@ private:
|
||||
|
||||
public:
|
||||
configuration(xr::system &);
|
||||
configuration() = default;
|
||||
|
||||
void save();
|
||||
};
|
||||
|
||||
@@ -1103,3 +1103,50 @@ imgui_context::viewport & imgui_context::layer(ImVec2 position)
|
||||
|
||||
return layers_.front();
|
||||
}
|
||||
|
||||
void imgui_context::tooltip(std::string_view text)
|
||||
{
|
||||
// FIXME: this is incorrect if we use the docking branch of imgui
|
||||
ImGuiViewport * viewport = ImGui::GetMainViewport();
|
||||
auto & current_layer = layer(ImGui::GetMousePos());
|
||||
auto pos_backup = viewport->Pos;
|
||||
auto size_backup = viewport->Size;
|
||||
viewport->Pos = ImVec2(current_layer.vp_origin.x, current_layer.vp_origin.y);
|
||||
viewport->Size = ImVec2(current_layer.vp_size.x, current_layer.vp_size.y);
|
||||
|
||||
ImVec2 pos{
|
||||
(ImGui::GetItemRectMin().x + ImGui::GetItemRectMax().x) / 2,
|
||||
ImGui::GetItemRectMin().y - constants::style::tooltip_distance,
|
||||
};
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::tooltip_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, constants::style::tooltip_rounding);
|
||||
|
||||
// Clamp position to avoid overflowing on the right
|
||||
auto & style = ImGui::GetStyle();
|
||||
const ImVec2 text_size = ImGui::CalcTextSize(text.data(), text.data() + text.size(), true);
|
||||
const ImVec2 size = {text_size.x + style.WindowPadding.x * 2.0f, text_size.y + style.WindowPadding.y * 2.0f};
|
||||
pos.x = std::min(pos.x, viewport->Pos.x + viewport->Size.x - size.x / 2);
|
||||
ImVec2 pivot = {0.5, 1};
|
||||
|
||||
// Move tooltip below the item if it overflows on the top
|
||||
if (pos.y - size.y <= viewport->Pos.y)
|
||||
{
|
||||
pos.y = ImGui::GetItemRectMax().y + constants::style::tooltip_distance;
|
||||
pivot.y = 0;
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot);
|
||||
if (ImGui::BeginTooltip())
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, 0xffffffff);
|
||||
ImGui::TextUnformatted(text.data(), text.data() + text.size());
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
viewport->Pos = pos_backup;
|
||||
viewport->Size = size_backup;
|
||||
}
|
||||
|
||||
@@ -215,4 +215,5 @@ public:
|
||||
void vibrate_on_hover();
|
||||
void set_hovered_item();
|
||||
void set_controllers_enabled(bool value);
|
||||
void tooltip(std::string_view text);
|
||||
};
|
||||
|
||||
@@ -98,7 +98,6 @@ class lobby : public scene_impl<lobby>
|
||||
std::optional<float> gui_recenter_distance;
|
||||
bool recenter_gui = true;
|
||||
void move_gui(glm::vec3 head_position, glm::vec3 new_gui_position);
|
||||
void tooltip(std::string_view text);
|
||||
|
||||
enum class tab
|
||||
{
|
||||
|
||||
+22
-69
@@ -138,53 +138,6 @@ std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB f
|
||||
}
|
||||
}
|
||||
|
||||
void scenes::lobby::tooltip(std::string_view text)
|
||||
{
|
||||
// FIXME: this is incorrect if we use the docking branch of imgui
|
||||
ImGuiViewport * viewport = ImGui::GetMainViewport();
|
||||
auto & layer = imgui_ctx->layer(ImGui::GetMousePos());
|
||||
auto pos_backup = viewport->Pos;
|
||||
auto size_backup = viewport->Size;
|
||||
viewport->Pos = ImVec2(layer.vp_origin.x, layer.vp_origin.y);
|
||||
viewport->Size = ImVec2(layer.vp_size.x, layer.vp_size.y);
|
||||
|
||||
ImVec2 pos{
|
||||
(ImGui::GetItemRectMin().x + ImGui::GetItemRectMax().x) / 2,
|
||||
ImGui::GetItemRectMin().y - constants::style::tooltip_distance,
|
||||
};
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::tooltip_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, constants::style::tooltip_rounding);
|
||||
|
||||
// Clamp position to avoid overflowing on the right
|
||||
auto & style = ImGui::GetStyle();
|
||||
const ImVec2 text_size = ImGui::CalcTextSize(text.data(), text.data() + text.size(), true);
|
||||
const ImVec2 size = {text_size.x + style.WindowPadding.x * 2.0f, text_size.y + style.WindowPadding.y * 2.0f};
|
||||
pos.x = std::min(pos.x, viewport->Pos.x + viewport->Size.x - size.x / 2);
|
||||
ImVec2 pivot = {0.5, 1};
|
||||
|
||||
// Move tooltip below the item if it overflows on the top
|
||||
if (pos.y - size.y <= viewport->Pos.y)
|
||||
{
|
||||
pos.y = ImGui::GetItemRectMax().y + constants::style::tooltip_distance;
|
||||
pivot.y = 0;
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot);
|
||||
if (ImGui::BeginTooltip())
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, 0xffffffff);
|
||||
ImGui::TextUnformatted(text.data(), text.data() + text.size());
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
viewport->Pos = pos_backup;
|
||||
viewport->Size = size_backup;
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_connecting(locked_notifiable<pin_request_data> & pin_request)
|
||||
{
|
||||
using constants::style::button_size;
|
||||
@@ -272,7 +225,7 @@ void scenes::lobby::gui_enter_pin(locked_notifiable<pin_request_data> & pin_requ
|
||||
|
||||
ImGui::PopFont();
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(_("Input the PIN displayed on the dashboard"));
|
||||
imgui_ctx->tooltip(_("Input the PIN displayed on the dashboard"));
|
||||
|
||||
ImGui::BeginDisabled(pin_buffer.size() == pin_size);
|
||||
for (int i = 1; i <= 9;)
|
||||
@@ -517,9 +470,9 @@ void scenes::lobby::gui_server_list()
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
{
|
||||
if (!data.compatible && !data.manual)
|
||||
tooltip(_("Incompatible server version"));
|
||||
imgui_ctx->tooltip(_("Incompatible server version"));
|
||||
else if (!data.visible && !data.manual)
|
||||
tooltip(_("Server not available"));
|
||||
imgui_ctx->tooltip(_("Server not available"));
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
@@ -614,7 +567,7 @@ void scenes::lobby::gui_settings()
|
||||
config.save();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(_("Select refresh rate based on measured application performance.\nMay cause flicker when a change happens."));
|
||||
imgui_ctx->tooltip(_("Select refresh rate based on measured application performance.\nMay cause flicker when a change happens."));
|
||||
for (float rate: refresh_rates)
|
||||
{
|
||||
if (ImGui::Selectable(fmt::format("{}", rate).c_str(), rate == config.preferred_refresh_rate, ImGuiSelectableFlags_SelectOnRelease))
|
||||
@@ -691,7 +644,7 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(_("Force disable audio filters, such as noise cancellation"));
|
||||
imgui_ctx->tooltip(_("Force disable audio filters, such as noise cancellation"));
|
||||
ImGui::Unindent();
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
@@ -705,7 +658,7 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) and (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled))
|
||||
tooltip(_("This feature is not supported by your headset"));
|
||||
imgui_ctx->tooltip(_("This feature is not supported by your headset"));
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
{
|
||||
@@ -718,7 +671,7 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) and (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled))
|
||||
tooltip(_("This feature is not supported by your headset"));
|
||||
imgui_ctx->tooltip(_("This feature is not supported by your headset"));
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
{
|
||||
@@ -731,7 +684,7 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) and (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled))
|
||||
tooltip(_("This feature is not supported by your headset"));
|
||||
imgui_ctx->tooltip(_("This feature is not supported by your headset"));
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
|
||||
@@ -748,14 +701,14 @@ void scenes::lobby::gui_settings()
|
||||
{
|
||||
if (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled)
|
||||
{
|
||||
tooltip(_("This feature is not supported by your headset"));
|
||||
imgui_ctx->tooltip(_("This feature is not supported by your headset"));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::visit(utils::overloaded{
|
||||
[](auto &) {},
|
||||
[this](xr::fb_body_tracker &) {
|
||||
tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise body data will be guessed from controller and headset positions"));
|
||||
imgui_ctx->tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise body data will be guessed from controller and headset positions"));
|
||||
},
|
||||
},
|
||||
application::get_body_tracker());
|
||||
@@ -774,7 +727,7 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(_("Estimate lower body joint positions using Generative Legs\nRequires 'Hand and body tracking' to be enabled in the Quest movement tracking settings"));
|
||||
imgui_ctx->tooltip(_("Estimate lower body joint positions using Generative Legs\nRequires 'Hand and body tracking' to be enabled in the Quest movement tracking settings"));
|
||||
|
||||
ImGui::BeginDisabled(not config.fb_lower_body);
|
||||
if (ImGui::Checkbox(_S("Enable hip tracking"), &config.fb_hip))
|
||||
@@ -783,7 +736,7 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(_("Only takes affect with lower body tracking enabled\nMay be desired when using another source of hip tracking"));
|
||||
imgui_ctx->tooltip(_("Only takes affect with lower body tracking enabled\nMay be desired when using another source of hip tracking"));
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::Unindent();
|
||||
@@ -798,14 +751,14 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) and (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled))
|
||||
tooltip(_("This feature is not supported by your headset"));
|
||||
imgui_ctx->tooltip(_("This feature is not supported by your headset"));
|
||||
ImGui::EndDisabled();
|
||||
|
||||
if (ImGui::Checkbox(_S("Show performance metrics"), &config.show_performance_metrics))
|
||||
config.save();
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(_("Overlay can be toggled by pressing both thumbsticks"));
|
||||
imgui_ctx->tooltip(_("Overlay can be toggled by pressing both thumbsticks"));
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
@@ -896,7 +849,7 @@ void scenes::lobby::gui_post_processing()
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
|
||||
imgui_ctx->tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -921,7 +874,7 @@ void scenes::lobby::gui_post_processing()
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
|
||||
imgui_ctx->tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
|
||||
}
|
||||
}
|
||||
ImGui::Unindent();
|
||||
@@ -938,9 +891,9 @@ void scenes::lobby::gui_post_processing()
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
if (application::get_openxr_post_processing_supported())
|
||||
tooltip(_("On this headset, this setting has been fully superseded by the native Sharpening setting above.\nOnly enable if you know what you're doing."));
|
||||
imgui_ctx->tooltip(_("On this headset, this setting has been fully superseded by the native Sharpening setting above.\nOnly enable if you know what you're doing."));
|
||||
else
|
||||
tooltip(_("Client-side upscaling and sharpening, adds a performance cost on the headset"));
|
||||
imgui_ctx->tooltip(_("Client-side upscaling and sharpening, adds a performance cost on the headset"));
|
||||
}
|
||||
if (application::get_openxr_post_processing_supported())
|
||||
{
|
||||
@@ -983,7 +936,7 @@ void scenes::lobby::gui_post_processing()
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(_("Adds an additional performance cost"));
|
||||
imgui_ctx->tooltip(_("Adds an additional performance cost"));
|
||||
}
|
||||
{
|
||||
const float current = config.sgsr.edge_threshold;
|
||||
@@ -995,7 +948,7 @@ void scenes::lobby::gui_post_processing()
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(fmt::format(_F("Recommended: {:.1f}"), 4.0));
|
||||
imgui_ctx->tooltip(fmt::format(_F("Recommended: {:.1f}"), 4.0));
|
||||
}
|
||||
{
|
||||
if (ImGui::SliderFloat(_S("Edge sharpness"), &config.sgsr.edge_sharpness, 1.0, 2.0, "%.2f"))
|
||||
@@ -1004,7 +957,7 @@ void scenes::lobby::gui_post_processing()
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(fmt::format(_F("Recommended: {:.1f}"), 2.0));
|
||||
imgui_ctx->tooltip(fmt::format(_F("Recommended: {:.1f}"), 2.0));
|
||||
}
|
||||
ImGui::Unindent();
|
||||
ImGui::EndDisabled();
|
||||
@@ -1517,7 +1470,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
||||
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(i.enabled ? i.tooltip_enabled : i.tooltip_disabled);
|
||||
imgui_ctx->tooltip(i.enabled ? i.tooltip_enabled : i.tooltip_disabled);
|
||||
|
||||
if (i.icon_disabled == std::string_view(ICON_FA_SLASH) and not i.enabled)
|
||||
{
|
||||
|
||||
+78
-14
@@ -310,6 +310,20 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const auto & config = application::get_config();
|
||||
self->override_foveation_enable = config.override_foveation_enable;
|
||||
self->override_foveation_pitch = config.override_foveation_pitch;
|
||||
self->override_foveation_distance = config.override_foveation_distance;
|
||||
|
||||
if (self->override_foveation_enable)
|
||||
self->network_session->send_control(from_headset::override_foveation_center{
|
||||
.enabled = self->override_foveation_enable,
|
||||
.pitch = self->override_foveation_pitch,
|
||||
.distance = self->override_foveation_distance,
|
||||
});
|
||||
}
|
||||
|
||||
self->network_thread = utils::named_thread("network_thread", &stream::process_packets, self.get());
|
||||
|
||||
self->command_buffer = std::move(self->device.allocateCommandBuffers({
|
||||
@@ -450,6 +464,10 @@ void scenes::stream::on_focused()
|
||||
plots_toggle_2 = get_action("plots_toggle_2").first;
|
||||
recenter_left = get_action("recenter_left").first;
|
||||
recenter_right = get_action("recenter_right").first;
|
||||
foveation_pitch = get_action("foveation_pitch").first;
|
||||
foveation_distance = get_action("foveation_distance").first;
|
||||
foveation_ok = get_action("foveation_ok").first;
|
||||
foveation_cancel = get_action("foveation_cancel").first;
|
||||
}
|
||||
|
||||
assert(video_stream_description);
|
||||
@@ -714,6 +732,28 @@ void scenes::stream::update_gui_position(xr::spaces controller)
|
||||
}
|
||||
}
|
||||
|
||||
bool scenes::stream::is_gui_interactable() const
|
||||
{
|
||||
if (not imgui_ctx)
|
||||
return false;
|
||||
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::foveation_settings:
|
||||
return true;
|
||||
|
||||
case gui_status::hidden:
|
||||
case gui_status::overlay_only:
|
||||
case gui_status::compact:
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(false);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
void scenes::stream::render(const XrFrameState & frame_state)
|
||||
{
|
||||
if (exiting)
|
||||
@@ -1087,7 +1127,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
queue.submit(submit_info, *fence);
|
||||
swapchain.release();
|
||||
|
||||
std::vector<XrCompositionLayerProjectionView> layer_view(view_count); // TODO array or inplace_vector
|
||||
std::vector<XrCompositionLayerProjectionView> layer_view(view_count);
|
||||
|
||||
if (use_alpha)
|
||||
session.enable_passthrough(system);
|
||||
@@ -1120,7 +1160,9 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
application::space(xr::spaces::world),
|
||||
std::move(layer_view));
|
||||
|
||||
if (composition_layer_color_scale_bias_supported and imgui_ctx and gui_status == gui_status::interactable)
|
||||
bool interactable = is_gui_interactable();
|
||||
|
||||
if (composition_layer_color_scale_bias_supported and imgui_ctx and interactable)
|
||||
set_color_scale_bias({0.7, 0.7, 0.7, 1}, {0.15, 0.15, 0.15, 0});
|
||||
|
||||
if (const configuration::openxr_post_processing_settings openxr_post_processing = application::get_config().openxr_post_processing;
|
||||
@@ -1130,16 +1172,16 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
if (imgui_ctx)
|
||||
{
|
||||
XrSpace world_space = application::space(xr::spaces::world);
|
||||
std::vector<XrCompositionLayerQuad> imgui_layers; // TODO array or inplace_vector
|
||||
std::vector<XrCompositionLayerQuad> imgui_layers;
|
||||
accumulate_metrics(frame_state.predictedDisplayTime, current_blit_handles, timestamps);
|
||||
auto views = session.locate_views(viewconfig, frame_state.predictedDisplayTime, world_space).second;
|
||||
|
||||
imgui_ctx->set_controllers_enabled(gui_status == gui_status::interactable);
|
||||
imgui_ctx->set_controllers_enabled(interactable);
|
||||
if (gui_status != gui_status::hidden)
|
||||
imgui_layers = draw_gui(frame_state.predictedDisplayTime);
|
||||
imgui_layers = draw_gui(frame_state.predictedDisplayTime, frame_state.predictedDisplayPeriod);
|
||||
|
||||
// Display controllers and handle recentering
|
||||
if (gui_status == gui_status::interactable)
|
||||
if (interactable)
|
||||
{
|
||||
if (recentering_context)
|
||||
{
|
||||
@@ -1170,7 +1212,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
else
|
||||
recentering_context.reset();
|
||||
|
||||
std::vector<glm::vec4> ray_limits; // TODO array or inplace_vector
|
||||
std::vector<glm::vec4> ray_limits;
|
||||
for (auto & layer: imgui_layers)
|
||||
{
|
||||
ray_limits.push_back(compute_ray_limits(layer.pose));
|
||||
@@ -1200,9 +1242,18 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
std::optional<std::pair<glm::vec3, glm::quat>> head_position = application::locate_controller(application::space(xr::spaces::view), world_space, frame_state.predictedDisplayTime);
|
||||
if (head_position)
|
||||
{
|
||||
glm::mat3 M = glm::mat3_cast(head_position->second);
|
||||
imgui_ctx->layers()[0].orientation = head_position->second * head_gui_orientation;
|
||||
imgui_ctx->layers()[0].position = head_position->first + M * head_gui_position;
|
||||
if (gui_status == gui_status::foveation_settings)
|
||||
{
|
||||
glm::mat3 M = glm::mat3_cast(head_position->second);
|
||||
imgui_ctx->layers()[0].orientation = head_position->second;
|
||||
imgui_ctx->layers()[0].position = head_position->first + M * glm::vec3{0, -override_foveation_distance * sin(override_foveation_pitch), -override_foveation_distance};
|
||||
}
|
||||
else
|
||||
{
|
||||
glm::mat3 M = glm::mat3_cast(head_position->second);
|
||||
imgui_ctx->layers()[0].orientation = head_position->second * head_gui_orientation;
|
||||
imgui_ctx->layers()[0].position = head_position->first + M * head_gui_position;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the layer with the GUI
|
||||
@@ -1215,7 +1266,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
}
|
||||
|
||||
// Display the controller rays
|
||||
if (gui_status == gui_status::interactable)
|
||||
if (interactable)
|
||||
{
|
||||
render_world(XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT,
|
||||
world_space,
|
||||
@@ -1289,17 +1340,21 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
|
||||
if (state_1.currentState and state_2.currentState and (state_1.changedSinceLastSync or state_2.changedSinceLastSync))
|
||||
{
|
||||
current_tab = tab::stats;
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::hidden:
|
||||
case gui_status::compact:
|
||||
case gui_status::overlay_only:
|
||||
gui_status = gui_status::interactable;
|
||||
gui_status = gui_status::stats;
|
||||
break;
|
||||
case gui_status::interactable:
|
||||
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
gui_status = gui_status::overlay_only;
|
||||
break;
|
||||
|
||||
case gui_status::foveation_settings:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1508,6 +1563,11 @@ scene::meta & scenes::stream::get_meta_scene()
|
||||
|
||||
{"recenter_left", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||
{"recenter_right", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||
|
||||
{"foveation_pitch", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||
{"foveation_distance", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||
{"foveation_ok", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||
{"foveation_cancel", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||
},
|
||||
.bindings = {
|
||||
suggested_binding{
|
||||
@@ -1535,6 +1595,10 @@ scene::meta & scenes::stream::get_meta_scene()
|
||||
|
||||
{"recenter_left", "/user/hand/left/input/squeeze/value"},
|
||||
{"recenter_right", "/user/hand/right/input/squeeze/value"},
|
||||
{"foveation_pitch", "/user/hand/right/input/thumbstick/y"},
|
||||
{"foveation_distance", "/user/hand/left/input/thumbstick/y"},
|
||||
{"foveation_ok", "/user/hand/right/input/a/click"},
|
||||
{"foveation_cancel", "/user/hand/right/input/b/click"},
|
||||
|
||||
{"plots_toggle_1", "/user/hand/left/input/thumbstick/click"},
|
||||
{"plots_toggle_2", "/user/hand/right/input/thumbstick/click"},
|
||||
|
||||
+16
-11
@@ -138,26 +138,30 @@ private:
|
||||
hidden,
|
||||
overlay_only,
|
||||
compact,
|
||||
interactable
|
||||
stats,
|
||||
settings,
|
||||
foveation_settings
|
||||
};
|
||||
std::atomic<gui_status> gui_status = gui_status::interactable;
|
||||
|
||||
bool is_gui_interactable() const;
|
||||
|
||||
std::atomic<gui_status> gui_status = gui_status::stats;
|
||||
XrAction plots_toggle_1 = XR_NULL_HANDLE;
|
||||
XrAction plots_toggle_2 = XR_NULL_HANDLE;
|
||||
XrAction recenter_left = XR_NULL_HANDLE;
|
||||
XrAction recenter_right = XR_NULL_HANDLE;
|
||||
XrAction foveation_pitch = XR_NULL_HANDLE;
|
||||
XrAction foveation_distance = XR_NULL_HANDLE;
|
||||
XrAction foveation_ok = XR_NULL_HANDLE;
|
||||
XrAction foveation_cancel = XR_NULL_HANDLE;
|
||||
|
||||
// Position of the GUI relative to the view space, in view space axes
|
||||
glm::vec3 head_gui_position{-0.1, -0.3, -1.2}; // Shift 10cm left by default so that the stats are centered accounting for the tab list
|
||||
glm::quat head_gui_orientation{1, 0, 0, 0};
|
||||
|
||||
enum class tab
|
||||
{
|
||||
stats,
|
||||
settings,
|
||||
disconnect,
|
||||
};
|
||||
|
||||
tab current_tab;
|
||||
bool override_foveation_enable;
|
||||
float override_foveation_pitch; // The pitch is the opposite as the height displayed in the GUI
|
||||
float override_foveation_distance;
|
||||
|
||||
// Which controller is used for recentering and position of the GUI relative to the controller, in controller axes, during recentering
|
||||
std::optional<std::tuple<xr::spaces, glm::vec3, glm::quat>> recentering_context;
|
||||
@@ -288,6 +292,7 @@ private:
|
||||
void gui_performance_metrics();
|
||||
void gui_compact_view();
|
||||
void gui_settings();
|
||||
std::vector<XrCompositionLayerQuad> draw_gui(XrTime predicted_display_time);
|
||||
void gui_foveation_settings(float predicted_display_period);
|
||||
std::vector<XrCompositionLayerQuad> draw_gui(XrTime predicted_display_time, XrDuration predicted_display_period);
|
||||
};
|
||||
} // namespace scenes
|
||||
|
||||
@@ -25,7 +25,7 @@ void scenes::stream::read_actions()
|
||||
{
|
||||
from_headset::inputs inputs;
|
||||
|
||||
if (gui_status != gui_status::interactable)
|
||||
if (not is_gui_interactable())
|
||||
{
|
||||
for (const auto & [id, action, action_type]: input_actions)
|
||||
{
|
||||
|
||||
+175
-91
@@ -209,46 +209,6 @@ static bool RadioButtonWithoutCheckBox(const std::string & label, T & v, U v_but
|
||||
return pressed;
|
||||
}
|
||||
|
||||
// TODO factorize with the tooltip function of the lobby
|
||||
static void tooltip(std::string_view text)
|
||||
{
|
||||
// FIXME: this is incorrect if we use the docking branch of imgui
|
||||
ImGuiViewport * viewport = ImGui::GetMainViewport();
|
||||
|
||||
ImVec2 pos{
|
||||
(ImGui::GetItemRectMin().x + ImGui::GetItemRectMax().x) / 2,
|
||||
ImGui::GetItemRectMin().y - constants::style::tooltip_distance,
|
||||
};
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::tooltip_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, constants::style::tooltip_rounding);
|
||||
|
||||
// Clamp position to avoid overflowing on the right
|
||||
auto & style = ImGui::GetStyle();
|
||||
const ImVec2 text_size = ImGui::CalcTextSize(text.data(), text.data() + text.size(), true);
|
||||
const ImVec2 size = {text_size.x + style.WindowPadding.x * 2.0f, text_size.y + style.WindowPadding.y * 2.0f};
|
||||
pos.x = std::min(pos.x, viewport->Pos.x + viewport->Size.x - size.x / 2);
|
||||
ImVec2 pivot = {0.5, 1};
|
||||
|
||||
// Move tooltip below the item if it overflows on the top
|
||||
if (pos.y - size.y <= viewport->Pos.y)
|
||||
{
|
||||
pos.y = ImGui::GetItemRectMax().y + constants::style::tooltip_distance;
|
||||
pivot.y = 0;
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot);
|
||||
if (ImGui::BeginTooltip())
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, 0xffffffff);
|
||||
ImGui::TextUnformatted(text.data(), text.data() + text.size());
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void scenes::stream::gui_performance_metrics()
|
||||
{
|
||||
const ImGuiStyle & style = ImGui::GetStyle();
|
||||
@@ -430,8 +390,8 @@ void scenes::stream::gui_performance_metrics()
|
||||
std::lock_guard lock(tracking_control_mutex);
|
||||
ImGui::Text("%s", fmt::format(_F("Estimated motion to photons latency: {}ms"), std::chrono::duration_cast<std::chrono::milliseconds>(tracking_control.max_offset).count()).c_str());
|
||||
|
||||
if (gui_status == gui_status::interactable)
|
||||
ImGui::Text("%s", _S("Press both thumbsticks to return to the game, press the grip button to move the window"));
|
||||
if (is_gui_interactable())
|
||||
ImGui::Text("%s", _S("Press the grip button to move the window"));
|
||||
else
|
||||
ImGui::Text("%s", _S("Press both thumbsticks to interact"));
|
||||
}
|
||||
@@ -460,7 +420,7 @@ void scenes::stream::gui_compact_view()
|
||||
}
|
||||
}
|
||||
|
||||
std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag);
|
||||
std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag); // TODO declaration in a .h file
|
||||
void scenes::stream::gui_settings()
|
||||
{
|
||||
auto & config = application::get_config();
|
||||
@@ -494,7 +454,7 @@ void scenes::stream::gui_settings()
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
|
||||
imgui_ctx->tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -520,15 +480,117 @@ void scenes::stream::gui_settings()
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
|
||||
imgui_ctx->tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
|
||||
}
|
||||
}
|
||||
ImGui::Unindent();
|
||||
|
||||
bool send_packet = false;
|
||||
bool save_config = false;
|
||||
ImGui::Text("%s", _S("Foveation center override"));
|
||||
ImGui::Indent();
|
||||
{
|
||||
if (ImGui::Checkbox(_S("Enable"), &override_foveation_enable))
|
||||
{
|
||||
send_packet = true;
|
||||
save_config = true;
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
ImGui::BeginDisabled(!override_foveation_enable);
|
||||
ImGui::Text("%s", fmt::format(_F("Height {:.1f} deg"), -override_foveation_pitch * 180 / M_PI).c_str());
|
||||
ImGui::Text("%s", fmt::format(_F("Distance {:.2f} m"), override_foveation_distance).c_str());
|
||||
if (ImGui::Button(_S("Default")))
|
||||
{
|
||||
override_foveation_distance = configuration{}.override_foveation_distance;
|
||||
override_foveation_pitch = configuration{}.override_foveation_pitch;
|
||||
send_packet = true;
|
||||
save_config = true;
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(_S("Change")))
|
||||
gui_status = gui_status::foveation_settings;
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
ImGui::Unindent();
|
||||
|
||||
if (send_packet)
|
||||
{
|
||||
network_session->send_control(from_headset::override_foveation_center{
|
||||
.enabled = override_foveation_enable,
|
||||
.pitch = override_foveation_pitch,
|
||||
.distance = override_foveation_distance,
|
||||
});
|
||||
}
|
||||
|
||||
if (save_config)
|
||||
{
|
||||
auto & config = application::get_config();
|
||||
config.override_foveation_enable = override_foveation_enable;
|
||||
config.override_foveation_pitch = override_foveation_pitch;
|
||||
config.override_foveation_distance = override_foveation_distance;
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
std::vector<XrCompositionLayerQuad> scenes::stream::draw_gui(XrTime predicted_display_time)
|
||||
void scenes::stream::gui_foveation_settings(float predicted_display_period)
|
||||
{
|
||||
ImGui::PushFont(nullptr, constants::gui::font_size_large);
|
||||
ImGui::Text("%s", _S("Use the thumbsticks to move the foveation center"));
|
||||
ImGui::Text("%s", _S("Press A to save or B to cancel"));
|
||||
ImGui::Text("%s", fmt::format(_F("Height {:.1f} deg"), -override_foveation_pitch * 180 / M_PI).c_str());
|
||||
ImGui::Text("%s", fmt::format(_F("Distance {:.2f} m"), override_foveation_distance).c_str());
|
||||
ImGui::PopFont();
|
||||
|
||||
// Maximum speed 1 rad/s
|
||||
float delta_pitch = application::read_action_float(foveation_pitch).value_or(std::pair{0, 0}).second * predicted_display_period;
|
||||
|
||||
// Maximum speed 2m/s @ 1m
|
||||
float delta_distance = std::exp(std::log(2) * application::read_action_float(foveation_distance).value_or(std::pair{0, 0}).second * predicted_display_period);
|
||||
|
||||
override_foveation_pitch = std::clamp<float>(override_foveation_pitch + delta_pitch, -M_PI / 3, M_PI / 3);
|
||||
override_foveation_distance = std::clamp<float>(override_foveation_distance * delta_distance, 0.5, 100);
|
||||
|
||||
bool ok = application::read_action_bool(foveation_ok).value_or(std::pair{0, false}).second;
|
||||
bool cancel = application::read_action_bool(foveation_cancel).value_or(std::pair{0, false}).second;
|
||||
|
||||
if (ok)
|
||||
{
|
||||
gui_status = gui_status::settings;
|
||||
|
||||
// Save settings
|
||||
auto & config = application::get_config();
|
||||
config.override_foveation_enable = true;
|
||||
config.override_foveation_pitch = override_foveation_pitch;
|
||||
config.override_foveation_distance = override_foveation_distance;
|
||||
config.save();
|
||||
}
|
||||
else if (cancel)
|
||||
{
|
||||
gui_status = gui_status::settings;
|
||||
|
||||
// Restore settings
|
||||
const auto & config = application::get_config();
|
||||
override_foveation_enable = config.override_foveation_enable;
|
||||
override_foveation_pitch = config.override_foveation_pitch;
|
||||
override_foveation_distance = config.override_foveation_distance;
|
||||
}
|
||||
|
||||
network_session->send_control(from_headset::override_foveation_center{
|
||||
.enabled = override_foveation_enable,
|
||||
.pitch = override_foveation_pitch,
|
||||
.distance = override_foveation_distance,
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<XrCompositionLayerQuad> scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicted_display_period)
|
||||
{
|
||||
const float TabWidth = 300;
|
||||
const ImVec2 MarginAroundWindow{50, 50};
|
||||
@@ -536,25 +598,35 @@ std::vector<XrCompositionLayerQuad> scenes::stream::draw_gui(XrTime predicted_di
|
||||
const ImGuiStyle & style = ImGui::GetStyle();
|
||||
imgui_ctx->new_frame(predicted_display_time);
|
||||
|
||||
bool interactable = gui_status == gui_status::interactable;
|
||||
bool compact = gui_status == gui_status::compact;
|
||||
bool interactable = gui_status == gui_status::stats or gui_status == gui_status::settings;
|
||||
bool compact = gui_status == gui_status::compact or gui_status == gui_status::foveation_settings;
|
||||
|
||||
ImVec2 content_size{ImGui::GetMainViewport()->Size - ImVec2{TabWidth, 0} - MarginAroundWindow * 2};
|
||||
ImVec2 content_center = MarginAroundWindow + content_size / 2 + ImVec2{TabWidth, 0};
|
||||
|
||||
if (interactable)
|
||||
switch (gui_status)
|
||||
{
|
||||
ImGui::SetNextWindowPos(MarginAroundWindow);
|
||||
ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size - MarginAroundWindow * 2);
|
||||
}
|
||||
else if (compact)
|
||||
{
|
||||
ImGui::SetNextWindowPos(content_center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::SetNextWindowPos(content_center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGui::SetNextWindowSize(content_size);
|
||||
case gui_status::hidden:
|
||||
break;
|
||||
|
||||
case gui_status::overlay_only:
|
||||
ImGui::SetNextWindowPos(content_center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGui::SetNextWindowSize(content_size);
|
||||
break;
|
||||
|
||||
case gui_status::foveation_settings:
|
||||
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->Size / 2, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
break;
|
||||
|
||||
case gui_status::compact:
|
||||
ImGui::SetNextWindowPos(content_center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
break;
|
||||
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
ImGui::SetNextWindowPos(MarginAroundWindow);
|
||||
ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size - MarginAroundWindow * 2);
|
||||
break;
|
||||
}
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0);
|
||||
@@ -566,40 +638,47 @@ std::vector<XrCompositionLayerQuad> scenes::stream::draw_gui(XrTime predicted_di
|
||||
else
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {0, 0});
|
||||
ImGui::Begin("Performance metrics", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
|
||||
ImGui::Begin("Stream settings", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
|
||||
}
|
||||
|
||||
if (interactable)
|
||||
ImGui::SetCursorPos({TabWidth + 20, 20});
|
||||
else if (not compact)
|
||||
ImGui::SetCursorPos({20, 20});
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {8, 8});
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10);
|
||||
if (compact)
|
||||
{
|
||||
gui_compact_view();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
|
||||
switch (current_tab)
|
||||
{
|
||||
case tab::stats:
|
||||
gui_performance_metrics();
|
||||
break;
|
||||
|
||||
case tab::settings:
|
||||
gui_settings();
|
||||
break;
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::hidden:
|
||||
break;
|
||||
|
||||
case tab::disconnect:
|
||||
// TODO disconnect correctly
|
||||
// application::pop_scene();
|
||||
break;
|
||||
}
|
||||
ImGui::EndChild();
|
||||
case gui_status::overlay_only:
|
||||
ImGui::SetCursorPos({20, 20});
|
||||
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
|
||||
gui_performance_metrics();
|
||||
ImGui::EndChild();
|
||||
break;
|
||||
|
||||
case gui_status::compact:
|
||||
gui_compact_view();
|
||||
break;
|
||||
|
||||
case gui_status::stats:
|
||||
ImGui::SetCursorPos({TabWidth + 20, 20});
|
||||
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
|
||||
gui_performance_metrics();
|
||||
ImGui::EndChild();
|
||||
break;
|
||||
|
||||
case gui_status::settings:
|
||||
ImGui::SetCursorPos({TabWidth + 20, 20});
|
||||
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
|
||||
gui_settings();
|
||||
ImGui::EndChild();
|
||||
break;
|
||||
|
||||
case gui_status::foveation_settings:
|
||||
gui_foveation_settings(predicted_display_period * 1.e-9f);
|
||||
break;
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2); // ImGuiStyleVar_WindowPadding, ImGuiStyleVar_FrameRounding
|
||||
|
||||
if (interactable)
|
||||
@@ -610,22 +689,27 @@ std::vector<XrCompositionLayerQuad> scenes::stream::draw_gui(XrTime predicted_di
|
||||
ImGui::BeginChild("Tabs", {TabWidth, ImGui::GetContentRegionMax().y - ImGui::GetWindowContentRegionMin().y});
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10));
|
||||
RadioButtonWithoutCheckBox(ICON_FA_COMPUTER " " + _("Stats"), current_tab, tab::stats, {TabWidth, 0});
|
||||
RadioButtonWithoutCheckBox(ICON_FA_COMPUTER " " + _("Stats"), gui_status, gui_status::stats, {TabWidth, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_GEARS " " + _("Settings"), current_tab, tab::settings, {TabWidth, 0});
|
||||
RadioButtonWithoutCheckBox(ICON_FA_GEARS " " + _("Settings"), gui_status, gui_status::settings, {TabWidth, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
int n_items_at_end = 3;
|
||||
int n_items_at_end = 4;
|
||||
ImGui::SetCursorPosY(ImGui::GetContentRegionMax().y - n_items_at_end * ImGui::GetCurrentContext()->FontSize - (n_items_at_end * 2) * style.FramePadding.y - (n_items_at_end - 1) * style.ItemSpacing.y - style.WindowPadding.y);
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_EYE_SLASH " " + _("Hide"), gui_status, gui_status::hidden, {TabWidth, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_COMPUTER " " + _("Overlay only"), gui_status, gui_status::overlay_only, {TabWidth, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_MINIMIZE " " + _("Compact view"), gui_status, gui_status::compact, {TabWidth, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_DOOR_OPEN " " + _("Disconnect"), current_tab, tab::disconnect, {TabWidth, 0});
|
||||
bool dummy = false;
|
||||
if (RadioButtonWithoutCheckBox(ICON_FA_DOOR_OPEN " " + _("Disconnect"), dummy, true, {TabWidth, 0}))
|
||||
exit();
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
ImGui::PopStyleVar(); // ImGuiStyleVar_FramePadding
|
||||
|
||||
@@ -316,7 +316,7 @@ void scenes::stream::tracking()
|
||||
}
|
||||
|
||||
auto enabled = [&](const to_headset::tracking_control & control, device_id id) -> bool {
|
||||
if (gui_status == gui_status::interactable)
|
||||
if (is_gui_interactable())
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
|
||||
+10
-1
@@ -430,11 +430,19 @@ struct session_state_changed
|
||||
{
|
||||
XrSessionState state;
|
||||
};
|
||||
|
||||
struct user_presence_changed
|
||||
{
|
||||
bool present;
|
||||
};
|
||||
|
||||
struct override_foveation_center
|
||||
{
|
||||
bool enabled;
|
||||
float pitch;
|
||||
float distance;
|
||||
};
|
||||
|
||||
using packets = std::variant<
|
||||
crypto_handshake,
|
||||
pin_check_1,
|
||||
@@ -454,7 +462,8 @@ using packets = std::variant<
|
||||
visibility_mask_changed,
|
||||
refresh_rate_changed,
|
||||
session_state_changed,
|
||||
user_presence_changed>;
|
||||
user_presence_changed,
|
||||
override_foveation_center>;
|
||||
} // namespace from_headset
|
||||
|
||||
namespace to_headset
|
||||
|
||||
@@ -173,9 +173,9 @@ static float angles_to_center(float e, float l, float r)
|
||||
e = tan(e);
|
||||
l = tan(l);
|
||||
r = tan(r);
|
||||
float res = (e - l) / (r - l) * 2 - 1;
|
||||
float res = std::clamp((e - l) / (r - l) * 2 - 1, -1.f, 1.f);
|
||||
// If the center isn't in the FoV, fallback to middle of image
|
||||
if (res < -1 or res > 1 or std::isnan(res))
|
||||
if (std::isnan(res))
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
@@ -194,6 +194,7 @@ static void fill_param_2d(
|
||||
{
|
||||
float scale = float(foveated_dim) / source_dim;
|
||||
auto [a, b] = solve_foveation(scale, c);
|
||||
U_LOG_I("solve_foveation(%.4f, %.4f) => %.4f, %.4f", scale, c, a, b);
|
||||
|
||||
uint16_t last = 0;
|
||||
std::vector<uint16_t> left; // index 0: 1:1 ratio, then 2:1 etc.
|
||||
@@ -274,6 +275,10 @@ void wivrn_foveation::compute_params(
|
||||
const xrt_fov fovs[2])
|
||||
{
|
||||
auto e = yaw_pitch(gaze);
|
||||
|
||||
if (manual_foveation.enabled)
|
||||
e.y = manual_foveation.pitch;
|
||||
|
||||
for (size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
const auto & fov = fovs[i];
|
||||
@@ -281,7 +286,8 @@ void wivrn_foveation::compute_params(
|
||||
size_t extent_w = std::abs(src[i].extent.w);
|
||||
if (foveated_width < extent_w)
|
||||
{
|
||||
auto angle_x = convergence_angle(convergence_distance, eye_x[i], e.x);
|
||||
auto distance = manual_foveation.enabled ? manual_foveation.distance : convergence_distance;
|
||||
auto angle_x = convergence_angle(distance, eye_x[i], e.x);
|
||||
auto center = angles_to_center(angle_x, fov.angle_left, fov.angle_right);
|
||||
fill_param_2d(center, foveated_width, extent_w, params[i].x);
|
||||
}
|
||||
@@ -292,7 +298,7 @@ void wivrn_foveation::compute_params(
|
||||
if (foveated_height < extent_h)
|
||||
{
|
||||
auto angle_y = e.y;
|
||||
if (is_zero_quat(gaze))
|
||||
if (is_zero_quat(gaze) and not manual_foveation.enabled)
|
||||
{
|
||||
// Natural gaze is not straight forward, adjust the angle
|
||||
angle_y += angle_offset;
|
||||
@@ -371,6 +377,12 @@ void wivrn_foveation::update_tracking(const from_headset::tracking & tracking, c
|
||||
}
|
||||
}
|
||||
|
||||
void wivrn_foveation::update_foveation_center_override(const from_headset::override_foveation_center & center)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
manual_foveation = center;
|
||||
}
|
||||
|
||||
std::array<to_headset::foveation_parameter, 2> wivrn_foveation::get_parameters()
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
@@ -395,6 +407,7 @@ static void fill_ubo(
|
||||
const int n_source = std::abs(n_ratio - int(i)) + 1;
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
{
|
||||
assert(count > 0);
|
||||
if (flip)
|
||||
ubo[1] = ubo[0] - n_source;
|
||||
else
|
||||
@@ -441,14 +454,17 @@ vk::CommandBuffer wivrn_foveation::update_foveation_buffer(
|
||||
|
||||
// Check if the last value is still valid
|
||||
std::lock_guard lock(mutex);
|
||||
if (last.flip_y == flip_y //
|
||||
and last.src[0] == source[0] //
|
||||
and last.src[1] == source[1] //
|
||||
and last.fovs[0] == fovs[0] //
|
||||
and last.fovs[1] == fovs[1] //
|
||||
and last.gaze == gaze //
|
||||
and std::abs(last.eye_x[0] - eye_x[0]) < 0.0005 //
|
||||
and std::abs(last.eye_x[1] - eye_x[1]) < 0.0005 //
|
||||
if (last.flip_y == flip_y //
|
||||
and last.src[0] == source[0] //
|
||||
and last.src[1] == source[1] //
|
||||
and last.fovs[0] == fovs[0] //
|
||||
and last.fovs[1] == fovs[1] //
|
||||
and (last.gaze == gaze or manual_foveation.enabled) // Ignore the gaze if foveation center is overridden
|
||||
and std::abs(last.eye_x[0] - eye_x[0]) < 0.0005 //
|
||||
and std::abs(last.eye_x[1] - eye_x[1]) < 0.0005 //
|
||||
and last.manual_foveation.enabled == manual_foveation.enabled //
|
||||
and std::abs(last.manual_foveation.pitch - manual_foveation.pitch) < 0.0005 //
|
||||
and std::abs(last.manual_foveation.distance - manual_foveation.distance) < 0.0005 //
|
||||
)
|
||||
return nullptr;
|
||||
|
||||
@@ -458,6 +474,7 @@ vk::CommandBuffer wivrn_foveation::update_foveation_buffer(
|
||||
.src = {source[0], source[1]},
|
||||
.fovs = {fovs[0], fovs[1]},
|
||||
.eye_x = {eye_x[0], eye_x[1]},
|
||||
.manual_foveation = manual_foveation,
|
||||
};
|
||||
|
||||
compute_params(source, fovs);
|
||||
|
||||
@@ -48,6 +48,7 @@ class wivrn_foveation
|
||||
|
||||
float eye_x[2] = {}; // eye x position
|
||||
xrt_quat gaze = {};
|
||||
from_headset::override_foveation_center manual_foveation = {};
|
||||
std::array<to_headset::foveation_parameter, 2> params;
|
||||
|
||||
vk::raii::CommandPool command_pool;
|
||||
@@ -63,6 +64,8 @@ class wivrn_foveation
|
||||
xrt_rect src[2] = {};
|
||||
xrt_fov fovs[2] = {};
|
||||
float eye_x[2] = {};
|
||||
|
||||
from_headset::override_foveation_center manual_foveation = {};
|
||||
};
|
||||
P last;
|
||||
|
||||
@@ -75,6 +78,7 @@ public:
|
||||
wivrn_foveation(wivrn_vk_bundle &, const xrt_hmd_parts &);
|
||||
|
||||
void update_tracking(const from_headset::tracking &, const clock_offset &);
|
||||
void update_foveation_center_override(const from_headset::override_foveation_center &);
|
||||
std::array<to_headset::foveation_parameter, 2> get_parameters();
|
||||
|
||||
vk::CommandBuffer update_foveation_buffer(
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "wivrn_config.h"
|
||||
#include "wivrn_eye_tracker.h"
|
||||
#include "wivrn_fb_face2_tracker.h"
|
||||
#include "wivrn_foveation.h"
|
||||
#include "wivrn_generic_tracker.h"
|
||||
#include "wivrn_htc_face_tracker.h"
|
||||
#include "wivrn_ipc.h"
|
||||
@@ -502,6 +503,13 @@ void wivrn_session::operator()(const from_headset::tracking & tracking)
|
||||
htc_face_tracker->update_tracking(tracking, offset);
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(from_headset::override_foveation_center && foveation_center)
|
||||
{
|
||||
std::shared_lock lock(comp_target_mutex);
|
||||
if (comp_target)
|
||||
comp_target->foveation->update_foveation_center_override(foveation_center);
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(from_headset::derived_pose && derived)
|
||||
{
|
||||
left_controller.set_derived_pose(derived);
|
||||
|
||||
@@ -189,6 +189,7 @@ public:
|
||||
void operator()(from_headset::session_state_changed &&);
|
||||
void operator()(from_headset::user_presence_changed &&);
|
||||
void operator()(from_headset::refresh_rate_changed &&);
|
||||
void operator()(from_headset::override_foveation_center &&);
|
||||
void operator()(audio_data &&);
|
||||
|
||||
void operator()(to_monado::disconnect &&);
|
||||
|
||||
Reference in New Issue
Block a user