Esempio n. 1
0
        //This part knows nothing about shapes and works only with raw data

        internal static bool CollidePoints(Vector2 one, Transform oneTransform, Vector2 another, Transform anotherTransform, out CollisionResult result)
        {
            Vector2 onePoint     = oneTransform.Mul(one);
            Vector2 anotherPoint = anotherTransform.Mul(another);

            Vector2 dir          = onePoint - anotherPoint;
            float   distanceSqrd = dir.LengthSquared();

            if (distanceSqrd > float.Epsilon)
            {
                result = default(CollisionResult);
                return(false);
            }

#if !USE_MATHF
            dir /= (float)Math.Sqrt(distanceSqrd); // that function requires define and additional check
#else
            dir *= Math.InvSqrt(distanceSqrd);
#endif
            result = new CollisionResult(onePoint, dir);

            return(true);
        }