Exemple #1
0
        public bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info, float max_distance)
        {
            var hit_info = new RaycastHit();
            var result   = realCollider
                                ? realCollider.Raycast(ray, out hit_info, max_distance)
                                : false;

            iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
            return(result);
        }
        static int RaycastBufferToIsoRaycastHits(int hit_count, IsoRaycastHit[] results)
        {
            var min_hit_count = Mathf.Min(hit_count, results.Length);

            for (var i = 0; i < min_hit_count; ++i)
            {
                results[i] = new IsoRaycastHit(_raycastNonAllocBuffer[i]);
            }
            System.Array.Clear(_raycastNonAllocBuffer, 0, hit_count);
            return(min_hit_count);
        }
Exemple #3
0
        public bool SweepTest(Vector3 direction, out IsoRaycastHit iso_hit_info,
                              float max_distance = Mathf.Infinity,
                              QueryTriggerInteraction query_trigger_interaction = QueryTriggerInteraction.UseGlobal)
        {
            var hit_info = new RaycastHit();
            var result   = realRigidbody
                                ? realRigidbody.SweepTest(direction, out hit_info, max_distance, query_trigger_interaction)
                                : false;

            iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
            return(result);
        }
        //
        // Linecast
        //

        public static bool Linecast(
            Vector3 start, Vector3 end, out IsoRaycastHit iso_hit_info,
            int layer_mask = UnityEngine.Physics.DefaultRaycastLayers,
            QueryTriggerInteraction query_trigger_interaction = QueryTriggerInteraction.UseGlobal)
        {
            var hit_info = new RaycastHit();
            var result   = UnityEngine.Physics.Linecast(start, end, out hit_info,
                                                        layer_mask,
                                                        query_trigger_interaction);

            iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
            return(result);
        }
        //
        // Raycast
        //

        public static bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info,
                                   float max_distance = Mathf.Infinity,
                                   int layer_mask     = UnityEngine.Physics.DefaultRaycastLayers,
                                   QueryTriggerInteraction query_trigger_interaction = QueryTriggerInteraction.UseGlobal)
        {
            var hit_info = new RaycastHit();
            var result   = UnityEngine.Physics.Raycast(ray, out hit_info,
                                                       max_distance,
                                                       layer_mask,
                                                       query_trigger_interaction);

            iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
            return(result);
        }
        //
        // SphereCast
        //

        public static bool SphereCast(
            Vector3 origin, float radius, Vector3 direction, out IsoRaycastHit iso_hit_info,
            float max_distance = Mathf.Infinity,
            int layer_mask     = UnityEngine.Physics.DefaultRaycastLayers,
            QueryTriggerInteraction query_trigger_interaction = QueryTriggerInteraction.UseGlobal)
        {
            var hit_info = new RaycastHit();
            var result   = UnityEngine.Physics.SphereCast(
                origin, radius, direction, out hit_info,
                max_distance,
                layer_mask,
                query_trigger_interaction);

            iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
            return(result);
        }
        //
        // BoxCast
        //

        public static bool BoxCast(
            Vector3 center, Vector3 half_extents, Vector3 direction, out IsoRaycastHit iso_hit_info,
            float max_distance = Mathf.Infinity,
            int layer_mask     = UnityEngine.Physics.DefaultRaycastLayers,
            QueryTriggerInteraction query_trigger_interaction = QueryTriggerInteraction.UseGlobal)
        {
            var hit_info = new RaycastHit();
            var result   = UnityEngine.Physics.BoxCast(
                center, half_extents, direction, out hit_info,
                Quaternion.identity,
                max_distance,
                layer_mask,
                query_trigger_interaction);

            iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
            return(result);
        }