Beispiel #1
0
        private G2OM(G2OM_Description description)
        {
            var expectedNumberOfCandidates = description.ExpectedNumberOfObjects;

            _context = description.Context;
            _context.Setup(expectedNumberOfCandidates); // TODO: What if this fails???

            _howLongToKeepCandidatesInMemory = description.HowLongToKeepCandidatesInSeconds;

            _objectFinder = description.ObjectFinder;
            _objectFinder.SetLayerMask(description.LayerMask);

            _colliderDataProvider = description.ColliderDataProvider;
            _objectDistinguisher  = description.Distinguisher;
            _postTicker           = description.PostTicker;

            _newCandidates      = new Dictionary <int, GameObject>(expectedNumberOfCandidates);
            _internalCandidates = new Dictionary <int, InternalCandidate>(expectedNumberOfCandidates);

            _gazeFocusedObjects = new List <FocusedCandidate>(expectedNumberOfCandidates);
            _keysToRemove       = new List <int>(expectedNumberOfCandidates);

            _nativeCandidates       = new G2OM_Candidate[expectedNumberOfCandidates];
            _nativeCandidatesResult = new G2OM_CandidateResult[expectedNumberOfCandidates];
        }
Beispiel #2
0
        private G2OM(G2OM_Description description)
        {
            _internalCapacity = (int)description.Options.capacity;
            _howLongToKeepCandidatesInMemory = description.HowLongToKeepCandidatesInSeconds;

            _context = description.Context;
            _context.Setup(description.Options);

            _objectFinder = description.ObjectFinder;
            _objectFinder.Setup(_context, description.LayerMask);

            _colliderDataProvider = description.ColliderDataProvider;
            _distinguisher        = description.Distinguisher;
            _postTicker           = description.PostTicker;

            _newCandidates      = new Dictionary <int, GameObject>(_internalCapacity);
            _internalCandidates = new Dictionary <int, InternalCandidate>(_internalCapacity);

            _gazeFocusedObjects = new List <FocusedCandidate>(_internalCapacity);
            _keysToRemove       = new List <int>(_internalCapacity);

            _nativeCandidates       = new G2OM_Candidate[_internalCapacity];
            _nativeCandidatesResult = new G2OM_CandidateResult[_internalCapacity];
        }
Beispiel #3
0
        private static void UpdateListOfFocusedCandidates(G2OM_CandidateResult[] result, Dictionary <int, InternalCandidate> allCandidates, List <FocusedCandidate> focusedObjects, IG2OM_ObjectFinder objectFinder)
        {
            focusedObjects.Clear();

            for (int i = 0; i < allCandidates.Count; i++)
            {
                var candidate = result[i];

                if (candidate.score <= Mathf.Epsilon)
                {
                    break;
                }

                var gazeFocusedObject = new FocusedCandidate
                {
                    GameObject = allCandidates[candidate.Id].GameObject,
                    IsRayValid = candidate.adjustedCombinedRay.IsValid,
                    Direction  = candidate.adjustedCombinedRay.ray.direction.Vector,
                    Origin     = candidate.adjustedCombinedRay.ray.origin.Vector,
                };

                focusedObjects.Add(gazeFocusedObject);
            }
        }