TerrainDisplay.Collision.Intersection.TestMovingSphereSphere C# (CSharp) Method

TestMovingSphereSphere() public static method

public static TestMovingSphereSphere ( BoundingSphere s0, BoundingSphere s1, System.Vector3 v0, System.Vector3 v1, float &t ) : bool
s0 BoundingSphere
s1 BoundingSphere
v0 System.Vector3
v1 System.Vector3
t float
return bool
        public static bool TestMovingSphereSphere(BoundingSphere s0, BoundingSphere s1, Vector3 v0, Vector3 v1, ref float t)
        {
            var vector = s1.Center - s0.Center;
            var vector2 = v1 - v0;
            var num = s1.Radius + s0.Radius;
            var num2 = Vector3.Dot(vector, vector) - (num * num);
            if (num2 < 0f)
            {
                t = 0f;
                return true;
            }
            var num3 = Vector3.Dot(vector2, vector2);
            if (num3 < 0.0001f)
            {
                return false;
            }
            var num4 = Vector3.Dot(vector2, vector);
            if (num4 >= 0f)
            {
                return false;
            }
            var num5 = (num4 * num4) - (num3 * num2);
            if (num5 < 0f)
            {
                return false;
            }
            t = (-num4 - ((float)Math.Sqrt(num5))) / num3;
            return true;
        }