BEPUphysics.CollisionShapes.ConvexShapes.TriangleShape.RayTest C# (CSharp) Метод

RayTest() публичный Метод

Gets the intersection between the triangle and the ray.
public RayTest ( BEPUutilities.Ray &ray, RigidTransform &transform, float maximumLength, RayHit &hit ) : bool
ray BEPUutilities.Ray Ray to test against the triangle.
transform BEPUutilities.RigidTransform Transform to apply to the triangle shape for the test.
maximumLength float Maximum distance to travel in units of the direction vector's length.
hit BEPUutilities.RayHit Hit data of the ray cast, if any.
Результат bool
        public override bool RayTest(ref Ray ray, ref RigidTransform transform, float maximumLength, out RayHit hit)
        {
            Matrix3x3 orientation;
            Matrix3x3.CreateFromQuaternion(ref transform.Orientation, out orientation);
            Ray localRay;
            Quaternion conjugate;
            Quaternion.Conjugate(ref transform.Orientation, out conjugate);
            Vector3.Transform(ref ray.Direction, ref conjugate, out localRay.Direction);
            Vector3.Subtract(ref ray.Position, ref transform.Position, out localRay.Position);
            Vector3.Transform(ref localRay.Position, ref conjugate, out localRay.Position);

            bool toReturn = Toolbox.FindRayTriangleIntersection(ref localRay, maximumLength, sidedness, ref vA, ref vB, ref vC, out hit);
            //Move the hit back into world space.
            Vector3.Multiply(ref ray.Direction, hit.T, out hit.Location);
            Vector3.Add(ref ray.Position, ref hit.Location, out hit.Location);
            Vector3.Transform(ref hit.Normal, ref transform.Orientation, out hit.Normal);
            return toReturn;
        }