public static bool Intersect(Bounding.Frustum a, BoundingBox b, out object intersection) { intersection = null; var rel = SpatialRelation.Relation(b, a); return(rel != RSpatialRelation.Outside); }
// ---------------------------------------------------------------------------------------------- // -- Frustum ----------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------- public static bool Intersect(Bounding.Frustum a, Vector3 b, out object intersection) { intersection = null; foreach (Plane p in a.planes) { if (Vector3.Dot(p.Normal, b) + p.D > 0) { return(false); } } return(true); }
public static RSpatialRelation Relation(BoundingBox a, Bounding.Frustum b) { Vector3 min, max; RSpatialRelation rel = RSpatialRelation.AInsideB; for (int i = 0; i < b.planes.Length; i++) { if (b.planes[i].Normal.X > 0) { min.X = a.Minimum.X; max.X = a.Maximum.X; } else { min.X = a.Maximum.X; max.X = a.Minimum.X; } if (b.planes[i].Normal.Y > 0) { min.Y = a.Minimum.Y; max.Y = a.Maximum.Y; } else { min.Y = a.Maximum.Y; max.Y = a.Minimum.Y; } if (b.planes[i].Normal.Z > 0) { min.Z = a.Minimum.Z; max.Z = a.Maximum.Z; } else { min.Z = a.Maximum.Z; max.Z = a.Minimum.Z; } if (Vector3.Dot(b.planes[i].Normal, min) + b.planes[i].D > 0) { return(RSpatialRelation.Outside); } if (Vector3.Dot(b.planes[i].Normal, max) + b.planes[i].D >= 0) { rel = RSpatialRelation.Intersect; } } return(rel); }
public static bool Intersect(Bounding.Frustum a, Vector2 b, out object intersection) { return(Intersect(a, new Vector3(b, 0), out intersection)); }