private void UpdateFocusConfidenceScore(IEnumerable <GameObject> objectsInGaze) { foreach (var objectInGaze in objectsInGaze) { var instanceId = objectInGaze.GetInstanceID(); if (!_scoredObjects.ContainsKey(instanceId)) { if (!GazeFocus.IsFocusableObject(objectInGaze)) { continue; } _scoredObjects.Add(objectInGaze.GetInstanceID(), new ScoredObject(objectInGaze, GainGazeDwellTime, LoseGazeDwellTime)); } ScoredObject hitObject = _scoredObjects[instanceId]; hitObject.AddHit(Time.time, Time.deltaTime); } ClearFocusedObjectIfOld(); }
public FocusedObject GetFocusedObject(IEnumerable <GazePoint> lastGazePoints, Camera camera) { var gazePoint = lastGazePoints.Last(); if (!gazePoint.IsWithinScreenBounds) { return(FocusedObject.Invalid); } GameObject focusedObject = null; RaycastHit hitInfo; if (HitTestFromPoint.FindObjectInWorld(out hitInfo, gazePoint.Screen, camera, MaximumDistance, LayerMask)) { if (GazeFocus.IsFocusableObject(hitInfo.collider.gameObject)) { focusedObject = hitInfo.collider.gameObject; } } return(new FocusedObject(focusedObject)); }