public static int OverlapGeomAgainst(IPhysicsGeom geom, ICollection<Collider> results, IEnumerable<Collider> colliders, int layerMask = Physics.AllLayers, QueryTriggerInteraction query = QueryTriggerInteraction.UseGlobal) { if (results == null) throw new System.ArgumentNullException("results"); if (geom == null) return 0; if (colliders == null) return 0; int cnt = 0; using (var set = TempCollection.GetSet<Collider>()) { if (geom.Overlap(set, layerMask, query) > 0) { var e = LightEnumerator.Create<Collider>(colliders); while (e.MoveNext()) { if (set.Contains(e.Current)) { cnt++; results.Add(e.Current); } } } } return cnt; }
public static bool CheckGeomAgainst(IPhysicsGeom geom, IEnumerable <Collider> colliders, int layerMask = Physics.AllLayers, QueryTriggerInteraction query = QueryTriggerInteraction.UseGlobal) { if (geom == null) { return(false); } if (colliders == null) { return(false); } using (var set = TempCollection.GetSet <Collider>()) { if (geom.Overlap(set, layerMask, query) > 0) { var e = LightEnumerator.Create <Collider>(colliders); while (e.MoveNext()) { if (set.Contains(e.Current)) { return(true); } } } } return(false); }
/// <summary> /// Raycast against a collection of colliders. /// </summary> /// <param name="pos"></param> /// <param name="dir"></param> /// <param name="colliders"></param> /// <returns></returns> public static bool RaycastAgainst(Ray ray, IEnumerable<Collider> colliders, float maxDistance = float.PositiveInfinity) { RaycastHit hit; var e = LightEnumerator.Create<Collider>(colliders); while (e.MoveNext()) { if (e.Current.Raycast(ray, out hit, maxDistance)) return true; } return false; }