From 82668aa71902c7b7000f9063ee3b1b7c9d8b6df2 Mon Sep 17 00:00:00 2001 From: Hermanest Date: Wed, 24 Jul 2024 15:48:06 +0300 Subject: [PATCH 1/5] Fixed events not being unsubscribed after camera destroy. --- Source/CustomAvatar/Rendering/MainCamera.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/CustomAvatar/Rendering/MainCamera.cs b/Source/CustomAvatar/Rendering/MainCamera.cs index fa393eac..bf60bd30 100644 --- a/Source/CustomAvatar/Rendering/MainCamera.cs +++ b/Source/CustomAvatar/Rendering/MainCamera.cs @@ -138,6 +138,7 @@ private void OnDisable() private void OnDestroy() { + OnDisable(); RemoveFromPlayerSpaceManager(); } From fe04fa3d2490b24a70c9953b06623e87bbf6a6d7 Mon Sep 17 00:00:00 2001 From: Hermanest Date: Wed, 24 Jul 2024 19:05:25 +0300 Subject: [PATCH 2/5] Fixed CustomAvatar attempting to get BeatLeader replayer camera when it is not available (cam2 + fpfc). --- Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs b/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs index 7c849dab..dfc1561d 100644 --- a/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs +++ b/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs @@ -128,13 +128,14 @@ private void HandleBeatLeaderSpectatorCamera() var controller = (Component)_container.TryResolve(BeatLeaderReflection.kCameraControllerType); var originComponent = (Component)_container.TryResolve(BeatLeaderReflection.kOriginComponentType); + var camera = BeatLeaderReflection.kCameraField(controller); - if (controller == null || originComponent == null) + if (controller == null || originComponent == null || camera == null) { return; } - - SpectatorCamera spectatorCameraController = _container.InstantiateComponent(BeatLeaderReflection.kCameraField(controller).gameObject); + + SpectatorCamera spectatorCameraController = _container.InstantiateComponent(camera.gameObject); spectatorCameraController.origin = BeatLeaderReflection.kReplayerCoreGetter(originComponent); spectatorCameraController.playerSpace = BeatLeaderReflection.kReplayerCenterAdjustGetter(originComponent); } From eec0b80097dbdba618ff7f77d7859e6f1584bfee Mon Sep 17 00:00:00 2001 From: Hermanest Date: Wed, 24 Jul 2024 19:15:46 +0300 Subject: [PATCH 3/5] Fixed CustomAvatar attempting to get TrackedPoseDriver even if it does not exist. --- Source/CustomAvatar/Rendering/MainCamera.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/CustomAvatar/Rendering/MainCamera.cs b/Source/CustomAvatar/Rendering/MainCamera.cs index bf60bd30..ced56fb8 100644 --- a/Source/CustomAvatar/Rendering/MainCamera.cs +++ b/Source/CustomAvatar/Rendering/MainCamera.cs @@ -154,11 +154,13 @@ private void OnFpfcSettingsChanged(IFPFCSettings fpfcSettings) private void OnFocusChanged(bool hasFocus) { - _trackedPoseDriver.UseRelativeTransform = !hasFocus; - _trackedPoseDriver.originPose = hasFocus ? Pose.identity : new Pose( - Vector3.Project(Quaternion.Euler(0, 180, 0) * -transform.localPosition * 2, Vector3.right) + new Vector3(0, 0, 1.5f), - Quaternion.Euler(0, 180, 0)); - + if (_trackedPoseDriver != null) + { + _trackedPoseDriver.UseRelativeTransform = !hasFocus; + _trackedPoseDriver.originPose = hasFocus ? Pose.identity : new Pose( + Vector3.Project(Quaternion.Euler(0, 180, 0) * -transform.localPosition * 2, Vector3.right) + new Vector3(0, 0, 1.5f), + Quaternion.Euler(0, 180, 0)); + } UpdateCameraMask(); } From 0e854bef2c87c748aaf48c4a239d3b3414c7ecd5 Mon Sep 17 00:00:00 2001 From: Nicolas Gnyra Date: Wed, 31 Jul 2024 08:02:58 -0400 Subject: [PATCH 4/5] Fix double subscription in multiplayer --- Source/CustomAvatar/Rendering/MainCamera.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/CustomAvatar/Rendering/MainCamera.cs b/Source/CustomAvatar/Rendering/MainCamera.cs index ced56fb8..645711c7 100644 --- a/Source/CustomAvatar/Rendering/MainCamera.cs +++ b/Source/CustomAvatar/Rendering/MainCamera.cs @@ -68,16 +68,19 @@ private void OnEnable() { if (_settings != null) { + _settings.cameraNearClipPlane.changed -= OnCameraNearClipPlaneChanged; _settings.cameraNearClipPlane.changed += OnCameraNearClipPlaneChanged; } if (_fpfcSettings != null) { + _fpfcSettings.Changed -= OnFpfcSettingsChanged; _fpfcSettings.Changed += OnFpfcSettingsChanged; } if (_beatSaberUtilities != null) { + _beatSaberUtilities.focusChanged -= OnFocusChanged; _beatSaberUtilities.focusChanged += OnFocusChanged; OnFocusChanged(_beatSaberUtilities.hasFocus); } @@ -138,7 +141,6 @@ private void OnDisable() private void OnDestroy() { - OnDisable(); RemoveFromPlayerSpaceManager(); } From b9d11c3838c07c27cdb6c5d85cfbbdbb2ba6145c Mon Sep 17 00:00:00 2001 From: Nicolas Gnyra Date: Wed, 31 Jul 2024 08:03:18 -0400 Subject: [PATCH 5/5] Fix styling --- Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs | 4 ++-- Source/CustomAvatar/Rendering/MainCamera.cs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs b/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs index dfc1561d..8a02bf66 100644 --- a/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs +++ b/Source/CustomAvatar/Player/GameEnvironmentObjectManager.cs @@ -128,13 +128,13 @@ private void HandleBeatLeaderSpectatorCamera() var controller = (Component)_container.TryResolve(BeatLeaderReflection.kCameraControllerType); var originComponent = (Component)_container.TryResolve(BeatLeaderReflection.kOriginComponentType); - var camera = BeatLeaderReflection.kCameraField(controller); + Camera camera = BeatLeaderReflection.kCameraField(controller); if (controller == null || originComponent == null || camera == null) { return; } - + SpectatorCamera spectatorCameraController = _container.InstantiateComponent(camera.gameObject); spectatorCameraController.origin = BeatLeaderReflection.kReplayerCoreGetter(originComponent); spectatorCameraController.playerSpace = BeatLeaderReflection.kReplayerCenterAdjustGetter(originComponent); diff --git a/Source/CustomAvatar/Rendering/MainCamera.cs b/Source/CustomAvatar/Rendering/MainCamera.cs index 645711c7..0445762c 100644 --- a/Source/CustomAvatar/Rendering/MainCamera.cs +++ b/Source/CustomAvatar/Rendering/MainCamera.cs @@ -163,6 +163,7 @@ private void OnFocusChanged(bool hasFocus) Vector3.Project(Quaternion.Euler(0, 180, 0) * -transform.localPosition * 2, Vector3.right) + new Vector3(0, 0, 1.5f), Quaternion.Euler(0, 180, 0)); } + UpdateCameraMask(); }