Skip to content

Commit

Permalink
Set camera mask instead of messing with avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco007 committed May 23, 2024
1 parent 50c8c16 commit d6c4cb0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
13 changes: 1 addition & 12 deletions Source/CustomAvatar/Player/PlayerAvatarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ private void OnEnable()
_settings.enableLocomotion.changed += OnEnableLocomotionChanged;

_beatSaberUtilities.roomAdjustChanged += OnRoomAdjustChanged;
_beatSaberUtilities.focusChanged += OnFocusChanged;

_activeOriginManager.changed += OnActiveOriginChanged;
}
Expand Down Expand Up @@ -193,7 +192,6 @@ private void OnDisable()
_settings.enableLocomotion.changed -= OnEnableLocomotionChanged;

_beatSaberUtilities.roomAdjustChanged -= OnRoomAdjustChanged;
_beatSaberUtilities.focusChanged -= OnFocusChanged;

_activeOriginManager.changed -= OnActiveOriginChanged;
}
Expand Down Expand Up @@ -425,11 +423,6 @@ private void OnRoomAdjustChanged(Vector3 roomCenter, Quaternion roomRotation)
ResizeCurrentAvatar();
}

private void OnFocusChanged(bool hasFocus)
{
UpdateFirstPersonVisibility();
}

private void UpdateConstraints()
{
_logger.LogTrace("Updating constraints");
Expand Down Expand Up @@ -527,11 +520,7 @@ private void UpdateFirstPersonVisibility()

FirstPersonVisibility visibility = FirstPersonVisibility.Hidden;

if (!_beatSaberUtilities.hasFocus)
{
visibility = FirstPersonVisibility.Visible;
}
else if (_settings.isAvatarVisibleInFirstPerson)
if (_settings.isAvatarVisibleInFirstPerson)
{
visibility = ignoreFirstPersonExclusions ? FirstPersonVisibility.Visible : FirstPersonVisibility.VisibleWithExclusionsApplied;
}
Expand Down
4 changes: 3 additions & 1 deletion Source/CustomAvatar/Rendering/MainCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ private void OnFocusChanged(bool hasFocus)
_trackedPoseDriver.originPose = hasFocus ? Pose.identity : new Pose(
Vector3.ProjectOnPlane(Quaternion.Euler(0, 180, 0) * -transform.localPosition * 2, Vector3.up) + Vector3.ProjectOnPlane(transform.localRotation * Vector3.forward, Vector3.up).normalized * 1.5f,
Quaternion.Euler(0, 180, 0));

UpdateCameraMask();
}

private void UpdateCameraMask()
Expand All @@ -156,7 +158,7 @@ private void UpdateCameraMask()
int mask = _camera.cullingMask | AvatarLayers.kAlwaysVisibleMask;

// FPFC basically ends up being a 3rd person camera
if (_fpfcSettings.Enabled)
if (_fpfcSettings.Enabled || !_beatSaberUtilities.hasFocus)
{
mask |= AvatarLayers.kOnlyInThirdPersonMask;
}
Expand Down

0 comments on commit d6c4cb0

Please sign in to comment.