public BoundingBox3 Union(BoundingBox3 right) { if (IsEmpty) { return(right); } if (right.IsEmpty) { return(this); } return(new BoundingBox3 { _min = new Vector3(Math.Min(Min.X, right.Min.X), Math.Min(Min.Y, right.Min.Y), Math.Min(Min.Z, right.Min.Z)), _max = new Vector3(Math.Max(Max.X, right.Max.X), Math.Max(Max.Y, right.Max.Y), Math.Max(Max.Z, right.Max.Z)) }); }
public bool?GetSide(BoundingBox3 box) { var max = box.Max; var min = box.Min; var isXpos = Normal.X > 0; var isYpos = Normal.Y > 0; var isZpos = Normal.Z > 0; var farmost = new Vector3(isXpos ? max.X : min.X, isYpos ? max.Y : min.Y, isZpos ? max.Z : min.Z); var nearest = new Vector3(isXpos ? min.X : max.X, isYpos ? min.Y : max.Y, isZpos ? min.Z : max.Z); var farSide = GetSide(farmost); var nearSide = GetSide(nearest); if (farSide != nearSide) { return(null); } return(farSide); }
public void Union(ref BoundingBox3 right, out BoundingBox3 res) { if (IsEmpty) { res = right; return; } if (right.IsEmpty) { res = this; return; } res = new BoundingBox3 { min = new Vector3(Math.Min(Min.X, right.Min.X), Math.Min(Min.Y, right.Min.Y), Math.Min(Min.Z, right.Min.Z)), max = new Vector3(Math.Max(Max.X, right.Max.X), Math.Max(Max.Y, right.Max.Y), Math.Max(Max.Z, right.Max.Z)) }; }
public bool Contains(ref BoundingBox3 box) { return(box._min.X >= _min.X && box._max.X <= _max.X && box._min.Y >= _min.Y && box._max.Y <= _max.Y && box._min.Z >= _min.Z && box._max.Z <= _max.Z); }
public bool Equals(BoundingBox3 other) { return(_min.Equals(other._min) && _max.Equals(other._max)); }
public bool Contains(ref BoundingBox3 box) { return((box.min.X >= min.X) && (box.max.X <= max.X) && (box.min.Y >= min.Y) && (box.max.Y <= max.Y) && (box.min.Z >= min.Z) && (box.max.Z <= max.Z)); }
public bool Equals(BoundingBox3 other) { return(min.Equals(other.min) && max.Equals(other.max)); }