/// <summary></summary> public static bool Collide(MeshCollider m1, MeshCollider m2) { Sphere s1 = new Sphere(m1.transform.position, 0); Sphere s2 = new Sphere(m2.transform.position, 0); foreach (Point pt in m1.GetVertices()) { float d = DistanceUtil.Dist(pt, s1.position); if (d > s1.radius) { s1.radius = d; } } foreach (Point pt in m2.GetVertices()) { float d = DistanceUtil.Dist(pt, s2.position); if (d > s2.radius) { s2.radius = d; } } if (!Collide(s1, s2)) { return(false); } return(DistanceUtil.Dist(m1, m2) <= 0); }
/// <summary></summary> public static bool Collide(SphereCollider s, Line l) { return(Collide(DistanceUtil.ToSphere(s), l)); }
/// <summary></summary> public static bool Collide(SphereCollider s, Point p) { return(Collide(DistanceUtil.ToSphere(s), p)); }
/// <summary></summary> public static bool Collide(Sphere s1, Sphere s2) { return(DistanceUtil.Dist(s1, s2) <= 0); }
/// <summary></summary> public static bool Collide(Sphere s, Plane p) { return(DistanceUtil.Dist(s, p) <= 0); }
/// <summary></summary> public static bool Collide(Sphere s, Line l) { return(DistanceUtil.Dist(s, l) <= 0); }
/// <summary></summary> public static bool Collide(MeshCollider m, SphereCollider s) { return(Collide(m, DistanceUtil.ToSphere(s))); }
/// <summary></summary> public static bool Collide(MeshCollider m, Point p) { return(DistanceUtil.Dist(m, p) <= 0); }
/// <summary></summary> public static bool Collide(MeshCollider m, Sphere s) { return(DistanceUtil.Dist(m, s) <= 0); }
/// <summary></summary> public static bool Collide(SphereCollider s, BoxCollider b) { return(Collide(DistanceUtil.ToSphere(s), b)); }
/// <summary></summary> public static bool Collide(BoxCollider b, Sphere s) { return(DistanceUtil.Dist(b, s) <= 0); }
/// <summary></summary> public static bool Collide(BoxCollider b, Point p) { return(DistanceUtil.Dist(p, b.ClosestPoint(p)) < 0.000001); }
/// <summary></summary> public static bool Collide(Point[] pts, Plane p) { return(DistanceUtil.Dist(pts, p) <= 0); }
/// <summary></summary> public static bool Collide(SphereCollider s1, SphereCollider s2) { return(Collide(DistanceUtil.ToSphere(s2), DistanceUtil.ToSphere(s2))); }