Exemple #1
0
        public static bool CapsuleCast <T>(ref T target, float3 point1, float3 point2, float radius, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
            where T : struct, ICollidable
        {
            var  collector = new ClosestHitCollector <ColliderCastHit>(1.0f);
            bool hasHit    = target.CapsuleCastCustom(point1, point2, radius, direction, maxDistance, ref collector, filter, queryInteraction);

            hitInfo = collector.ClosestHit;
            return(hasHit);
        }
Exemple #2
0
        public static bool BoxCast <T>(ref T target, float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
            where T : struct, ICollidable
        {
            var  collector = new ClosestHitCollector <ColliderCastHit>(1.0f);
            bool hasHit    = target.BoxCastCustom(center, orientation, halfExtents, direction, maxDistance, ref collector, filter, queryInteraction);

            hitInfo = collector.ClosestHit;
            return(hasHit);
        }
Exemple #3
0
        public static bool CalculateDistance <T>(ref T target, ColliderDistanceInput input, out DistanceHit result) where T : struct, ICollidable
        {
            var collector = new ClosestHitCollector <DistanceHit>(input.MaxDistance);

            if (target.CalculateDistance(input, ref collector))
            {
                result = collector.ClosestHit;  // TODO: would be nice to avoid this copy
                return(true);
            }

            result = new DistanceHit();
            return(false);
        }
Exemple #4
0
        public static bool ColliderCast <T>(ref T target, ColliderCastInput input, out ColliderCastHit result) where T : struct, ICollidable
        {
            var collector = new ClosestHitCollector <ColliderCastHit>(1.0f);

            if (target.CastCollider(input, ref collector))
            {
                result = collector.ClosestHit;  // TODO: would be nice to avoid this copy
                return(true);
            }

            result = new ColliderCastHit();
            return(false);
        }
Exemple #5
0
        public static bool RayCast <T>(ref T target, RaycastInput input, out RaycastHit closestHit) where T : struct, ICollidable
        {
            var collector = new ClosestHitCollector <RaycastHit>(1.0f);

            if (target.CastRay(input, ref collector))
            {
                closestHit = collector.ClosestHit;  // TODO: would be nice to avoid this copy
                return(true);
            }

            closestHit = new RaycastHit();
            return(false);
        }