55using System ;
66using System . Collections . Generic ;
77using UnityEngine ;
8+ using UnityEngine . Profiling ;
89
910namespace Microsoft . MixedReality . Toolkit
1011{
1112 /// <summary>
12- /// Camera extension methods to test if colliders are within an FOV cone . Uses
13+ /// Camera extension methods to test if colliders are within camera's FOV. Uses
1314 /// caching to improve performance and ensure values are only computed once per frame
1415 /// </summary>
1516 public static class CameraFOVChecker
1617 {
1718
1819 // Help to clear caches when new frame runs
19- static private int inFOVConeLastCalculatedFrame = - 1 ;
20+ static private int inFOVLastCalculatedFrame = - 1 ;
2021 // Map from grabbable => is the grabbable in FOV for this frame. Cleared every frame
21- private static Dictionary < Tuple < Collider , Camera > , bool > inFOVConeColliderCache = new Dictionary < Tuple < Collider , Camera > , bool > ( ) ;
22+ private static Dictionary < Tuple < Collider , Camera > , bool > inFOVColliderCache = new Dictionary < Tuple < Collider , Camera > , bool > ( ) ;
2223 // List of corners shared across all sphere pointer query instances --
2324 // used to store list of corners for a bounds. Shared and static
2425 // to avoid allocating memory each frame
@@ -41,12 +42,12 @@ public static bool IsInFOVCached(this Camera cam, Collider myCollider)
4142
4243 Tuple < Collider , Camera > cameraColliderPair = new Tuple < Collider , Camera > ( myCollider , cam ) ;
4344 bool result = false ;
44- if ( inFOVConeLastCalculatedFrame != Time . frameCount )
45+ if ( inFOVLastCalculatedFrame != Time . frameCount )
4546 {
46- inFOVConeColliderCache . Clear ( ) ;
47- inFOVConeLastCalculatedFrame = Time . frameCount ;
47+ inFOVColliderCache . Clear ( ) ;
48+ inFOVLastCalculatedFrame = Time . frameCount ;
4849 }
49- else if ( inFOVConeColliderCache . TryGetValue ( cameraColliderPair , out result ) )
50+ else if ( inFOVColliderCache . TryGetValue ( cameraColliderPair , out result ) )
5051 {
5152 return result ;
5253 }
@@ -68,7 +69,7 @@ public static bool IsInFOVCached(this Camera cam, Collider myCollider)
6869
6970 if ( isInFOV )
7071 {
71- inFOVConeColliderCache . Add ( cameraColliderPair , true ) ;
72+ inFOVColliderCache . Add ( cameraColliderPair , true ) ;
7273 return true ;
7374 }
7475
@@ -94,7 +95,7 @@ public static bool IsInFOVCached(this Camera cam, Collider myCollider)
9495 && yMin < 1 // Bottom edge is not too high.
9596 && yMax > 0 ; // Top edge is not too low.
9697
97- inFOVConeColliderCache . Add ( cameraColliderPair , result ) ;
98+ inFOVColliderCache . Add ( cameraColliderPair , result ) ;
9899
99100 return result ;
100101 }
0 commit comments