public static boolean checkCollision(BoundingBox a, Plane b) { boolean pos = b.distance(a.min) > 0; Vector3 v1 = new Vector3(a.max.getX(), a.min.getY(), a.min.getZ()); Vector3 v2 = new Vector3(a.min.getX(), a.max.getY(), a.min.getZ()); Vector3 v3 = new Vector3(a.min.getX(), a.min.getY(), a.max.getZ()); Vector3 v4 = new Vector3(a.min.getX(), a.max.getY(), a.max.getZ()); Vector3 v5 = new Vector3(a.max.getX(), a.min.getY(), a.max.getZ()); Vector3 v6 = new Vector3(a.max.getX(), a.max.getY(), a.min.getZ()); boolean intersects = pos != b.distance(a.max) > 0 // Planes that are axis-aligned. most cases || pos != b.distance(v1) > 0 || pos != b.distance(v2) > 0 || pos != b.distance(v3) > 0 || pos != b.distance(v4) > 0 || pos != b.distance(v5) > 0 || pos != b.distance(v6) > 0; return intersects; }
public static boolean contains(Plane a, Vector3 b) { return a.distance(b) < MathHelper.FLT_EPSILON; }
public static boolean contains(Plane a, Segment b) { return a.containsPoint(b.origin) && a.containsPoint(b.endpoint); }
public static boolean contains(Plane a, Ray b) { return a.containsPoint(b.origin) && a.containsPoint(b.origin.add(b.direction)); }
public static boolean checkCollision(Segment a, Plane b) { return b.distance(a.origin) > 0 != b.distance(a.endpoint) > 0; }
public static boolean checkCollision(BoundingSphere a, Plane b) { return b.distance(a.center) <= a.radius; }