Beispiel #1
0
        /// <summary>
        /// Attempts to manually initiate a grasp on the argument interaction object. A grasp
        /// will only begin if a finger and thumb are both in contact with the interaction
        /// object. If this method successfully initiates a grasp, it will return true,
        /// otherwise it will return false.
        /// </summary>
        protected override bool checkShouldGraspAtemporal(IInteractionBehaviour intObj)
        {
            if (grabClassifier.TryGrasp(intObj, leapHand))
            {
                var tempControllers = Pool <List <InteractionController> > .Spawn();

                try {
                    tempControllers.Add(this);
                    intObj.BeginGrasp(tempControllers);
                    return(true);
                }
                finally {
                    tempControllers.Clear();
                    Pool <List <InteractionController> > .Recycle(tempControllers);
                }
            }

            return(false);
        }
        /// <summary>
        /// If the provided object is within range of this VR controller's grasp point and
        /// the grasp button is currently held down, this method will manually initiate a
        /// grasp and return true. Otherwise, the method returns false.
        /// </summary>
        protected override bool checkShouldGraspAtemporal(IInteractionBehaviour intObj)
        {
            bool shouldGrasp = !isGraspingObject &&
                               _graspButtonLastFrame &&
                               intObj.GetHoverDistance(graspPoint.position) < maxGraspDistance;

            if (shouldGrasp)
            {
                var tempControllers = Pool <List <InteractionController> > .Spawn();

                try {
                    intObj.BeginGrasp(tempControllers);
                }
                finally {
                    tempControllers.Clear();
                    Pool <List <InteractionController> > .Recycle(tempControllers);
                }
            }

            return(shouldGrasp);
        }