/// <summary> /// Casts a ray to find all collisions. /// </summary> /// <param name="tracerRaycast">The ray to cast with.</param> /// <returns><see langword="true"/> if a valid surface is located.</returns> protected virtual bool FindAllCollisions(Ray tracerRaycast) { ArraySegment <RaycastHit> raycastHits = PhysicsCast.RaycastAll( PhysicsCast, tracerRaycast, MaximumDistance, Physics.IgnoreRaycastLayer); ArraySortExtensions <RaycastHit> .Sort(raycastHits.Array, raycastHits.Offset, raycastHits.Count, Comparer, Comparison); foreach (RaycastHit collision in (HeapAllocationFreeReadOnlyList <RaycastHit>)raycastHits) { if (LocatorTermination?.Interface != null && CollisionMatchesRule(collision, LocatorTermination)) { break; } if (CollisionMatchesRule(collision, TargetValidity)) { SetSurfaceData(collision); return(true); } } return(false); }
/// <summary> /// Casts a ray to find all collisions. /// </summary> /// <param name="tracerRaycast">The ray to cast with.</param> /// <returns><see langword="true"/> if a valid surface is located.</returns> protected virtual bool FindAllCollisions(Ray tracerRaycast) { ArraySegment <RaycastHit> raycastHits = PhysicsCast.RaycastAll( PhysicsCast, tracerRaycast, MaximumDistance, Physics.IgnoreRaycastLayer); ArraySortExtensions <RaycastHit> .Sort(raycastHits.Array, raycastHits.Offset, raycastHits.Count, Comparer, Comparison); foreach (RaycastHit collision in (HeapAllocationFreeReadOnlyList <RaycastHit>)raycastHits) { if (ValidSurface(collision)) { SetSurfaceData(collision); return(true); } } return(false); }