[DesktopVRSwitch] Handle CVRWorld- Post Processing & FOV settings.

This commit is contained in:
NotAKidoS 2023-06-20 18:23:23 -05:00
parent 70ae268149
commit 900c6646af
17 changed files with 62 additions and 48 deletions

View file

@ -1,5 +1,4 @@
using ABI_RC.Core.Savior;
using UnityEngine;
namespace NAK.DesktopVRSwitch.VRModeTrackers;

View file

@ -0,0 +1,51 @@
using ABI.CCK.Components;
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using UnityEngine;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class CVRWorldTracker : VRModeTracker
{
public override void TrackerInit()
{
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
}
public override void TrackerDestroy()
{
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
}
private void OnPostSwitch(bool intoVR)
{
CVRWorld _cvrWorld = CVRWorld.Instance;
if (_cvrWorld == null)
{
DesktopVRSwitch.Logger.Error("Error while getting CVRWorld!");
return;
}
DesktopVRSwitch.Logger.Msg("Configuring CVRWorld. Updating PostProcessing & DesktopCameraController FOV settings.");
// some post processing settings aren't used in VR
_cvrWorld.UpdatePostProcessing();
UpdateCVRDesktopCameraController(_cvrWorld);
}
private void UpdateCVRDesktopCameraController(CVRWorld _cvrWorld)
{
// Just making sure- Starting in VR will not call Start() as rig is disabled
if (CVR_DesktopCameraController._cam == null)
CVR_DesktopCameraController._cam = PlayerSetup.Instance.desktopCamera.GetComponent<Camera>();
CVR_DesktopCameraController.defaultFov = Mathf.Clamp(_cvrWorld.fov, 60f, 120f);
CVR_DesktopCameraController.zoomFov = CVR_DesktopCameraController.defaultFov * 0.5f;
CVR_DesktopCameraController.enableZoom = _cvrWorld.enableZoom;
CVR_DesktopCameraController.UpdateFov(); // must happen after PlayerSetupTracker
CVR_MenuManager.Instance.coreData.instance.current_game_rule_no_zoom = !_cvrWorld.enableZoom;
// UICamera has a script that copies the FOV from the desktop cam.
// Toggling the cameras on/off resets the aspect ratio,
// so when rigs switch, that is already handled.
}
}

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.InteractionSystem;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class CVR_InteractableManagerTracker : VRModeTracker

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.InteractionSystem;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class CVR_MenuManagerTracker : VRModeTracker

View file

@ -5,10 +5,11 @@ namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class CameraFacingObjectTracker : MonoBehaviour
{
internal CameraFacingObject _cameraFacingObject;
CameraFacingObject _cameraFacingObject;
void Start()
{
_cameraFacingObject = GetComponent<CameraFacingObject>();
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
}
@ -19,6 +20,7 @@ public class CameraFacingObjectTracker : MonoBehaviour
public void OnPostSwitch(bool intoVR)
{
// TODO: cache camera
_cameraFacingObject.m_Camera = Utils.GetPlayerCameraObject(intoVR).GetComponent<Camera>();
}
}

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.Savior;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class CheckVRTracker : VRModeTracker

View file

@ -1,6 +1,5 @@
using ABI_RC.Core;
using ABI_RC.Core.UI;
using UnityEngine;
namespace NAK.DesktopVRSwitch.VRModeTrackers;

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.Player;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class HudOperationsTracker : VRModeTracker

View file

@ -2,7 +2,6 @@
using ABI_RC.Systems.IK.SubSystems;
using ABI_RC.Systems.IK.TrackingModules;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class IKSystemTracker : VRModeTracker

View file

@ -57,14 +57,12 @@ public class MetaPortTracker : VRModeTracker
if (intoVR)
{
// Testing
XRSettings.eyeTextureResolutionScale = 1;
XRSettings.gameViewRenderMode = DesktopVRSwitch.EntryRenderVRGameView.Value ? GameViewRenderMode.LeftEye : GameViewRenderMode.None;
//XRSettings.gameViewRenderMode = DesktopVRSwitch.EntryRenderVRGameView.Value ? GameViewRenderMode.LeftEye : GameViewRenderMode.None;
XRSettings.eyeTextureResolutionScale = 1; // unsure if will cause issues with FSR?
SteamVR_Settings.instance.pauseGameWhenDashboardVisible = false;
if (MetaPort.Instance.settings.GetSettingsBool("InteractionTobiiEyeTracking", false))
{
MetaPort.Instance.TobiiXrInitializer.Initialize();
}
return;
}

View file

@ -23,6 +23,7 @@ public class MovementSystemTracker : VRModeTracker
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
}
// why do i do this
private MovementSystem GetMovementSystemInstance()
{
MovementSystem _movementSystem = MovementSystem.Instance;

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.Player;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class PlayerSetupTracker : VRModeTracker
@ -27,16 +26,5 @@ public class PlayerSetupTracker : VRModeTracker
_playerSetup.desktopCameraRig.SetActive(!intoVR);
_playerSetup.vrCameraRig.SetActive(intoVR);
// This might error if we started in VR.
// '_cam' is not set until Start().
if (CVR_DesktopCameraController._cam == null)
CVR_DesktopCameraController._cam = _playerSetup.desktopCamera.GetComponent<UnityEngine.Camera>();
CVR_DesktopCameraController.UpdateFov();
// UICamera has a script that copies the FOV from the desktop cam.
// Toggling the cameras on/off resets the aspect ratio,
// so when rigs switch, that is already handled.
}
}

View file

@ -1,6 +1,5 @@
using ABI_RC.Systems.Camera;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class PortableCameraTracker : VRModeTracker

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.Player;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class VRTrackerManagerTracker : VRModeTracker

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.InteractionSystem;
namespace NAK.DesktopVRSwitch.VRModeTrackers;
public class ViewManagerTracker : VRModeTracker