/// <summary> /// 检查当前包围球是否与指定包围盒相交 /// </summary> /// <param name="box">指定包围盒</param> /// <param name="result">[输出属性] 相交true,不相交false </param> public void Intersects(ref BoundingBox box, out bool result) { float num; Vector3 vector; Vector3.Clamp(ref this.Center, ref box.Min, ref box.Max, out vector); Vector3.DistanceSquared(ref this.Center, ref vector, out num); result = num <= (this.Radius * this.Radius); }
/// <summary> /// 检查当前包围球是否与指定包围盒相交 /// </summary> /// <param name="box">指定包围盒</param> /// <returns>相交true,不相交false </returns> public bool Intersects(BoundingBox box) { float num; Vector3 vector; Vector3.Clamp(ref this.Center, ref box.Min, ref box.Max, out vector); Vector3.DistanceSquared(ref this.Center, ref vector, out num); return(num <= (this.Radius * this.Radius)); }
/// <summary> /// 检查当前包围盒是否与指定包围球相交 /// </summary> /// <param name="sphere">指定的包围球</param> /// <param name="result">[OutAttribute] 相交true,不相交false</param> public void Intersects(ref BoundingSphere sphere, out bool result) { float num; Vector3 vector; Vector3.Clamp(ref sphere.Center, ref this.Min, ref this.Max, out vector); Vector3.DistanceSquared(ref sphere.Center, ref vector, out num); result = num <= (sphere.Radius * sphere.Radius); }
/// <summary> /// 检查当前包围盒是否与指定包围球相交 /// </summary> /// <param name="sphere">指定的包围球</param> /// <returns>相交true,不相交false</returns> public bool Intersects(BoundingSphere sphere) { float num; Vector3 vector; Vector3.Clamp(ref sphere.Center, ref this.Min, ref this.Max, out vector); Vector3.DistanceSquared(ref sphere.Center, ref vector, out num); return(num <= (sphere.Radius * sphere.Radius)); }
/// <summary> /// 检测当前包围盒是否包含指定包围球 /// </summary> /// <param name="sphere">指定包围球</param> /// <param name="result">[输出属性] 表明关系的枚举类型</param> public void Contains(ref BoundingSphere sphere, out ClipStatus result) { float num2; Vector3 vector; Vector3.Clamp(ref sphere.Center, ref this.Min, ref this.Max, out vector); Vector3.DistanceSquared(ref sphere.Center, ref vector, out num2); float radius = sphere.Radius; if (num2 > (radius * radius)) { result = ClipStatus.Outside; } else { result = (((((this.Min.X + radius) <= sphere.Center.X) && (sphere.Center.X <= (this.Max.X - radius))) && (((this.Max.X - this.Min.X) > radius) && ((this.Min.Y + radius) <= sphere.Center.Y))) && (((sphere.Center.Y <= (this.Max.Y - radius)) && ((this.Max.Y - this.Min.Y) > radius)) && ((((this.Min.Z + radius) <= sphere.Center.Z) && (sphere.Center.Z <= (this.Max.Z - radius))) && ((this.Max.X - this.Min.X) > radius)))) ? ClipStatus.Inside : ClipStatus.Intersecting; } }
/// <summary> /// 检测当前包围盒是否包含指定包围球 /// </summary> /// <param name="sphere">指定包围球</param> /// <returns>表明关系的枚举类型</returns> public ClipStatus Contains(BoundingSphere sphere) { float num2; Vector3 vector; Vector3.Clamp(ref sphere.Center, ref this.Min, ref this.Max, out vector); Vector3.DistanceSquared(ref sphere.Center, ref vector, out num2); float radius = sphere.Radius; if (num2 > (radius * radius)) { return(ClipStatus.Outside); } if (((((this.Min.X + radius) <= sphere.Center.X) && (sphere.Center.X <= (this.Max.X - radius))) && (((this.Max.X - this.Min.X) > radius) && ((this.Min.Y + radius) <= sphere.Center.Y))) && (((sphere.Center.Y <= (this.Max.Y - radius)) && ((this.Max.Y - this.Min.Y) > radius)) && ((((this.Min.Z + radius) <= sphere.Center.Z) && (sphere.Center.Z <= (this.Max.Z - radius))) && ((this.Max.X - this.Min.X) > radius)))) { return(ClipStatus.Inside); } return(ClipStatus.Intersecting); }