@@ -32,9 +32,6 @@ public partial class AvatarShapeVisibilitySystem : BaseUnityLoopSystem
3232
3333 private SingleInstanceEntity camera ;
3434 private GameObject ? playerCamera ;
35- // Camera the cached frustum planes were built for. IsVisibleInCamera validates against this so a
36- // caller cannot read planes computed for a different camera (or before any were computed).
37- private Camera ? planesCamera ;
3835
3936 public AvatarShapeVisibilitySystem ( World world , IUserBlockingCache userBlockingCache , IRendererFeaturesCache outlineFeature , float startFadeDithering , float endFadeDithering , bool includeBannedUsersFromScene ) : base ( world )
4037 {
@@ -68,27 +65,21 @@ protected override void Update(float t)
6865
6966 if ( outlineFeature != null && outlineFeature . isActive )
7067 {
71- Camera cam = camera . GetCameraComponent ( World ) . Camera ;
72- CalculateFrustumPlanes ( cam ) ;
73- GetAvatarsVisibleWithOutlineQuery ( World , cam ) ;
68+ CameraComponent cameraComponent = camera . GetCameraComponent ( World ) ;
69+ CalculateFrustumPlanes ( cameraComponent . Camera ) ;
70+ GetAvatarsVisibleWithOutlineQuery ( World , cameraComponent ) ;
7471 }
7572 }
7673
77- public void CalculateFrustumPlanes ( Camera camera )
74+ internal void CalculateFrustumPlanes ( Camera camera )
7875 {
7976 GeometryUtility . CalculateFrustumPlanes ( camera , planes ) ;
80- planesCamera = camera ;
8177 }
8278
8379 // Tests the AABB against the frustum planes cached by the most recent CalculateFrustumPlanes call.
84- // Extraction runs once per tick in Update (not per avatar), so this does not recompute the planes;
85- // the camera argument is validated to match the camera those cached planes were built for.
86- public bool IsVisibleInCamera ( Camera camera , Bounds bounds )
87- {
88- UnityEngine . Assertions . Assert . IsTrue ( ReferenceEquals ( planesCamera , camera ) ,
89- "IsVisibleInCamera reads planes cached by CalculateFrustumPlanes; call it for this camera in the current tick first." ) ;
90- return GeometryUtility . TestPlanesAABB ( planes , bounds ) ;
91- }
80+ // Extraction runs once per tick in Update (not per avatar), so this does not recompute the planes.
81+ internal bool IsVisibleInCamera ( Bounds bounds ) =>
82+ GeometryUtility . TestPlanesAABB ( planes , bounds ) ;
9283
9384 public bool IsWithinCameraDistance ( Camera camera , Transform objectTransform , float maxDistancesquared )
9485 {
@@ -98,9 +89,9 @@ public bool IsWithinCameraDistance(Camera camera, Transform objectTransform, flo
9889 }
9990
10091 [ Query ]
101- private void GetAvatarsVisibleWithOutline ( [ Data ] Camera cam , in AvatarBase avatarBase , ref AvatarShapeComponent avatarShape )
92+ private void GetAvatarsVisibleWithOutline ( [ Data ] in CameraComponent cameraComponent , in AvatarBase avatarBase , ref AvatarShapeComponent avatarShape )
10293 {
103- if ( avatarShape . IsPreview || ( IsWithinCameraDistance ( cam , avatarBase . HeadAnchorPoint , 64.0f ) && IsVisibleInCamera ( cam , avatarBase . AvatarSkinnedMeshRenderer . bounds ) ) )
94+ if ( avatarShape . IsPreview || ( IsWithinCameraDistance ( cameraComponent . Camera , avatarBase . HeadAnchorPoint , 64.0f ) && IsVisibleInCamera ( avatarBase . AvatarSkinnedMeshRenderer . bounds ) ) )
10495 {
10596 RendererFeature_AvatarOutline . m_AvatarOutlineRenderers . AddRange ( avatarShape . OutlineCompatibleRenderers ) ;
10697 }
0 commit comments