Esempio n. 1
0
        public static bool sweepSphereBox(SphereShape sphere, VInt3 fromPos, VInt3 ToPos, BoxShape box, VIntTransform boxTransform,
                                          ref VFixedPoint dist, ref VInt3 normal)
        {
            VFixedPoint tmp;

            VInt3 dir = ToPos - fromPos;

            if (SphereBoxCollisionAlgorithm.getSphereDistance(box, boxTransform, fromPos, sphere.getRadius(), out normal, out tmp))
            {
                normal = (fromPos - ToPos).Normalize();
                dist   = VFixedPoint.Zero;
                return(true);
            }

            VInt3 aabbMin = boxTransform.position - box.getHalfExtent(), aabbMax = boxTransform.position + box.getHalfExtent();

            aabbMax += VInt3.one * sphere.getRadius();
            aabbMin -= VInt3.one * sphere.getRadius();
            return(BoxRaytestAlgorithm.rayTestBox(fromPos, ToPos, aabbMax, boxTransform, ref dist, ref normal));
        }