public FocusedObject GetFocusedObject(IEnumerable <GazePoint> lastGazePoints, Camera camera)
        {
            var gazePoints = new List <GazePoint>();

            /*Note: Do not use LINQ here - too inefficient to be called every update.*/
            foreach (var gazePoint in lastGazePoints)
            {
                if (gazePoint.IsValid)
                {
                    gazePoints.Add(gazePoint);
                }
            }

            foreach (var gazePoint in gazePoints)
            {
                var objectsInGaze = FindObjectsInGaze(gazePoint.Screen, camera);
                UpdateFocusConfidenceScore(objectsInGaze);
            }

            var focusChallenger = FindFocusChallenger();

            if (focusChallenger.GetScore() > _focusedObject.GetScore() + Threshold)
            {
                _focusedObject = focusChallenger;
            }

            return(FocusedGameObject);
        }
        public FocusedObject GetFocusedObject(IEnumerable <GazePoint> lastGazePoints, Camera camera)
        {
            var objectsInGaze = FindObjectsInGaze(lastGazePoints, camera);

            UpdateFocusConfidenceScore(objectsInGaze);
            var focusChallenger = FindFocusChallenger();

            if (focusChallenger.GetScore()
                > _focusedObject.GetScore() + Threshold)
            {
                _focusedObject = focusChallenger;
            }

            return(FocusedGameObject);
        }
        private ScoredObject FindFocusChallenger()
        {
            ScoredObject topFocusChallenger = ScoredObject.Empty();
            float        topScore           = 0.0f;

            foreach (var key in _scoredObjects.Keys)
            {
                ScoredObject scoredObject = _scoredObjects[key];

                var score = scoredObject.GetScore(Time.unscaledTime - LoseGazeDwellTime, Time.unscaledTime - GainGazeDwellTime);

                if (score > topScore)
                {
                    topScore           = score;
                    topFocusChallenger = scoredObject;
                }
            }

            return(topFocusChallenger);
        }