From 6584e3fdd53343bb9655d0dba5c09c92325f33a6 Mon Sep 17 00:00:00 2001 From: Florian Spiess Date: Tue, 23 Jan 2024 09:56:15 +0100 Subject: [PATCH] Vive Streaming fix / workaround (#30) * Update DRES API to 2.0.0-RC2 * Implement default evaluation ID selection * Implement workaround for #28 * Fix quick submit (frame -> milliseconds) --- Assets/Scenes/ModularInputScene.unity | 37 ++++++++++++++++++- .../VitrivrVR/Config/VitrivrVrConfig.cs | 7 ++++ .../VitrivrVR/Util/ViveStreamingFix.cs | 36 ++++++++++++++++++ .../VitrivrVR/Util/ViveStreamingFix.cs.meta | 3 ++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 Assets/Scripts/VitrivrVR/Util/ViveStreamingFix.cs create mode 100644 Assets/Scripts/VitrivrVR/Util/ViveStreamingFix.cs.meta diff --git a/Assets/Scenes/ModularInputScene.unity b/Assets/Scenes/ModularInputScene.unity index f57979b..af6fa54 100644 --- a/Assets/Scenes/ModularInputScene.unity +++ b/Assets/Scenes/ModularInputScene.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.009389741, g: 0.010874605, b: 0.014736945, a: 1} + m_IndirectSpecularColor: {r: 0.009389737, g: 0.0108745955, b: 0.014736922, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -4672,7 +4672,42 @@ PrefabInstance: type: 3} insertIndex: -1 addedObject: {fileID: 0} + - targetCorrespondingSourceObject: {fileID: 6317846110913897978, guid: 9e86f8938bf545645ac69df2d86083ec, + type: 3} + insertIndex: -1 + addedObject: {fileID: 6317846112967465990} m_SourcePrefab: {fileID: 100100000, guid: 9e86f8938bf545645ac69df2d86083ec, type: 3} +--- !u!1 &6317846112967465988 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 6317846110913897978, guid: 9e86f8938bf545645ac69df2d86083ec, + type: 3} + m_PrefabInstance: {fileID: 6317846112967465987} + m_PrefabAsset: {fileID: 0} +--- !u!114 &6317846112967465989 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 6317846110913897976, guid: 9e86f8938bf545645ac69df2d86083ec, + type: 3} + m_PrefabInstance: {fileID: 6317846112967465987} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6317846112967465988} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &6317846112967465990 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6317846112967465988} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7908bddc6dc44f86ad92b95c64d33d04, type: 3} + m_Name: + m_EditorClassIdentifier: + uiInputModule: {fileID: 6317846112967465989} --- !u!224 &7101856252187588039 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 5350470879762543667, guid: a064c784b84570846be74dc3380b0743, diff --git a/Assets/Scripts/VitrivrVR/Config/VitrivrVrConfig.cs b/Assets/Scripts/VitrivrVR/Config/VitrivrVrConfig.cs index 440a462..59c518a 100644 --- a/Assets/Scripts/VitrivrVR/Config/VitrivrVrConfig.cs +++ b/Assets/Scripts/VitrivrVR/Config/VitrivrVrConfig.cs @@ -167,6 +167,12 @@ public enum SpeechToText /// Path to location where log files are to be written. /// public string logFileLocation; + + /// + /// Enables a fix for the Vive streaming bug by periodically disabling and re-enabling UI interactions when no + /// interactions are detected. + /// + public bool viveStreamingFixEnabled; private VitrivrVrConfig() { @@ -204,6 +210,7 @@ private VitrivrVrConfig() interactionLogSubmissionInterval = 10f; writeLogsToFile = false; logFileLocation = "session_logs/"; + viveStreamingFixEnabled = false; } public static VitrivrVrConfig GetDefault() diff --git a/Assets/Scripts/VitrivrVR/Util/ViveStreamingFix.cs b/Assets/Scripts/VitrivrVR/Util/ViveStreamingFix.cs new file mode 100644 index 0000000..ffba725 --- /dev/null +++ b/Assets/Scripts/VitrivrVR/Util/ViveStreamingFix.cs @@ -0,0 +1,36 @@ +using System; +using UnityEngine; +using UnityEngine.InputSystem.UI; +using VitrivrVR.Config; + +namespace VitrivrVR.Util +{ + public class ViveStreamingFix : MonoBehaviour + { + public InputSystemUIInputModule uiInputModule; + private float _timer; + + private void Awake() + { + if (ConfigManager.Config.viveStreamingFixEnabled) return; + + Destroy(this); + } + + private void FixedUpdate() + { + _timer += Time.fixedDeltaTime; + if (!(_timer >= 1)) return; + + var res0 = uiInputModule.GetLastRaycastResult(0); + var res1 = uiInputModule.GetLastRaycastResult(1); + if (!res0.isValid && !res1.isValid) + { + uiInputModule.enabled = false; + uiInputModule.enabled = true; + } + + _timer %= 1; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/VitrivrVR/Util/ViveStreamingFix.cs.meta b/Assets/Scripts/VitrivrVR/Util/ViveStreamingFix.cs.meta new file mode 100644 index 0000000..bd50b9c --- /dev/null +++ b/Assets/Scripts/VitrivrVR/Util/ViveStreamingFix.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7908bddc6dc44f86ad92b95c64d33d04 +timeCreated: 1704478433 \ No newline at end of file