Exemple #1
0
        /// <summary>
        /// Gets the intersection between the convex shape and the ray.
        /// </summary>
        /// <param name="ray">Ray to test.</param>
        /// <param name="transform">Transform of the convex shape.</param>
        /// <param name="maximumLength">Maximum distance to travel in units of the ray direction's length.</param>
        /// <param name="hit">Ray hit data, if any.</param>
        /// <returns>Whether or not the ray hit the target.</returns>
        public virtual bool RayTest(ref Ray ray, ref RigidTransform transform, float maximumLength, out RayHit hit)
        {
            //RayHit newHit;
            //bool newBool = GJKToolbox.RayCast(ray, this, ref transform, maximumLength, out newHit);
            //RayHit oldHit;
            //bool oldBool = OldGJKVerifier.RayCastGJK(ray.Position, ray.Direction, maximumLength, this, transform, out oldHit.Location, out oldHit.Normal, out oldHit.T);
            //bool mprBool = MPRToolbox.RayCast(ray, maximumLength, this, ref transform, out hit);
            ////if (newBool != oldBool || ((newBool && oldBool) && Vector3.DistanceSquared(newHit.Location, hit.Location) > .01f))
            ////    Debug.WriteLine("break.");
            //return mprBool;

            //if (GJKToolbox.RayCast(ray, this, ref transform, maximumLength, out hit))
            //{
            //    //GJK toolbox doesn't normalize the hit normal; it's unnecessary for some other systems so it just saves on time.
            //    //It would be nice if ray tests always normalized it though.
            //    float length = hit.Normal.LengthSquared();
            //    if (length > Toolbox.Epsilon)
            //        Vector3.Divide(ref hit.Normal, (float) Math.Sqrt(length), out hit.Normal);
            //    else
            //        hit.Normal = new Vector3();
            //    return true;
            //}

            //return false;

            return(MPRToolbox.RayCast(ray, maximumLength, this, ref transform, out hit));
        }
Exemple #2
0
 /// <summary>
 /// Gets the intersection between the convex shape and the ray.
 /// </summary>
 /// <param name="ray">Ray to test.</param>
 /// <param name="transform">Transform of the convex shape.</param>
 /// <param name="maximumLength">Maximum distance to travel in units of the ray direction's length.</param>
 /// <param name="hit">Ray hit data, if any.</param>
 /// <returns>Whether or not the ray hit the target.</returns>
 public virtual bool RayTest(ref Ray ray, ref RigidTransform transform, float maximumLength, out RayHit hit)
 {
     return(MPRToolbox.RayCast(ray, maximumLength, this, ref transform, out hit));
 }