/// <summary> /// Determines whether there is an intersection between a <see cref="MyRay"/> and a <see cref="MyOrientedBoundingBox"/>. /// </summary> /// <param name="ray">The ray to test.</param> /// <param name="point">When the method completes, contains the point of intersection, /// or <see cref="MyVector3.Zero"/> if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref MyRay ray, out MyVector3 point) { // Put ray in box space MyMatrix invTrans; MyMatrix.Invert(ref Transformation, out invTrans); MyRay bRay; MyVector3.TransformNormal(ref ray.Direction, ref invTrans, out bRay.Direction); MyVector3.TransformCoordinate(ref ray.Position, ref invTrans, out bRay.Position); //Perform a regular ray to BoundingBox check var bb = new MyBoundingBox(-Extents, Extents); var intersects = MyCollision.RayIntersectsBox(ref bRay, ref bb, out point); //Put the result intersection back to world if (intersects) MyVector3.TransformCoordinate(ref point, ref Transformation, out point); return intersects; }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="MyRay"/>. /// </summary> /// <param name="ray">The ray to test.</param> /// <param name="point">When the method completes, contains the point of intersection, /// or <see cref="MyVector3.Zero"/> if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref MyRay ray, out MyVector3 point) { return(MyCollision.RayIntersectsBox(ref ray, ref this, out point)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="MyRay"/>. /// </summary> /// <param name="ray">The ray to test.</param> /// <param name="distance">When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref MyRay ray, out float distance) { return(MyCollision.RayIntersectsBox(ref ray, ref this, out distance)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="MyBoundingBox"/>. /// </summary> /// <param name="box">The box to test.</param> /// <param name="point">When the method completes, contains the point of intersection, /// or <see cref="MyVector3.Zero"/> if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref MyBoundingBox box, out MyVector3 point) { return(MyCollision.RayIntersectsBox(ref this, ref box, out point)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="MyBoundingBox"/>. /// </summary> /// <param name="box">The box to test.</param> /// <param name="distance">When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref MyBoundingBox box, out float distance) { return(MyCollision.RayIntersectsBox(ref this, ref box, out distance)); }