idTech4.idBounds.FromBoundsRotation C# (CSharp) Method

FromBoundsRotation() public static method

Most tight bounds for the rotational movement of the given bounds.
public static FromBoundsRotation ( idBounds bounds, Vector3 origin, Matrix axis, idRotation rotation ) : idBounds
bounds idBounds
origin Vector3
axis Matrix
rotation idRotation
return idBounds
		public static idBounds FromBoundsRotation(idBounds bounds, Vector3 origin, Matrix axis, idRotation rotation)
		{
			idBounds result = idBounds.Zero;
			Vector3 point = Vector3.Zero;
			float radius;

			if(idMath.Abs(rotation.Angle) < 180.0f)
			{
				// TODO: result = BoundsForPointRotation(bounds.Min * axis + origin, rotation);
				point = Vector3.Zero;

				for(int i = 1; i < 8; i++)
				{
					point.X = (((i ^ (i >> 1)) & 1) == 0) ? bounds.Min.X : bounds.Max.X;
					point.Y = (((i >> 1) & 1) == 0) ? bounds.Min.Y : bounds.Max.Y;
					point.Z = (((i >> 2) & 1) == 0) ? bounds.Min.Z : bounds.Max.Z;

					result = idBounds.Zero;
					//TODO : result += BoundsForPointRotation(point * axis + origin, rotation);
				}
			}
			else
			{
				point = (bounds.Max - bounds.Min) * 0.5f;
				radius = (bounds.Max - point).Length() + (point - rotation.Origin).Length();

				result = new idBounds();
				result.Min = new Vector3(-radius, -radius, -radius);
				result.Max = new Vector3(radius, radius, radius);
			}

			return result;
		}