private IEnumerable <GameObject> FindObjectsInGaze(IEnumerable <GazePoint> gazePoints, Camera camera) { var points = new List <Vector2>(); /*Note: Do not use LINQ here - too inefficient to be called every update.*/ foreach (var gazePoint in gazePoints) { if (gazePoint.IsValid) { points.Add(gazePoint.Screen); } } var objectsInGaze = new List <GameObject>(); IEnumerable <RaycastHit> hitInfos; if (HitTestFromPoint.FindMultipleObjectsInWorldFromMultiplePoints(out hitInfos, points, camera, MaximumDistance, LayerMask)) { /*Note: Do not use LINQ here - too inefficient to be called every update.*/ foreach (var raycastHit in hitInfos) { objectsInGaze.Add(raycastHit.collider.gameObject); } } return(objectsInGaze); }
private IEnumerable <GameObject> FindObjectsInGaze(Vector2 gazePoint, Camera camera) { var objectsInGaze = new List <GameObject>(); float fovealAngle = 2.0f; float distanceGazeOriginToScreen_inches = 24f; // ~ 60 cm var dpi = Screen.dpi > 0 ? Screen.dpi : 100; float fovealRadius_inches = Mathf.Tan(fovealAngle * Mathf.Deg2Rad) * distanceGazeOriginToScreen_inches; int fovealRadius_pixels = Mathf.RoundToInt(fovealRadius_inches * dpi); var points = PatternGenerator.CreateCircularAreaUniformPattern(gazePoint, fovealRadius_pixels, 4); IEnumerable <RaycastHit> hitInfos; if (HitTestFromPoint.FindMultipleObjectsInWorldFromMultiplePoints(out hitInfos, points, camera, MaximumDistance, LayerMask)) { foreach (var raycastHit in hitInfos) { objectsInGaze.Add(raycastHit.collider.gameObject); } } return(objectsInGaze); }