public static bool ColliderCast(SphereCollider sphereToCast,
                                        RigidTransform castStart,
                                        float3 castEnd,
                                        SphereCollider targetSphere,
                                        RigidTransform targetSphereTransform,
                                        out ColliderCastResult result)
        {
            var cso = targetSphere;

            cso.radius += sphereToCast.radius;
            var  start = math.transform(castStart, sphereToCast.center);
            var  ray   = new Ray(start, start + castEnd - castStart.pos);
            bool hit   = Raycast(ray, cso, targetSphereTransform, out var raycastResult);

            if (hit)
            {
                var hitTransform = castStart;
                hitTransform.pos += raycastResult.position - start;
                DistanceBetween(sphereToCast, hitTransform, targetSphere, targetSphereTransform, 1f, out var distanceResult);
                result = new ColliderCastResult
                {
                    hitpointOnCaster         = distanceResult.hitpointA,
                    hitpointOnTarget         = distanceResult.hitpointB,
                    normalOnSweep            = distanceResult.normalA,
                    normalOnTarget           = distanceResult.normalB,
                    subColliderIndexOnCaster = distanceResult.subColliderIndexA,
                    subColliderIndexOnTarget = distanceResult.subColliderIndexB,
                    distance = math.distance(hitTransform.pos, castStart.pos)
                };
                return(true);
            }
            result = default;
            return(false);
        }
        public static bool ColliderCast(SphereCollider sphereToCast,
                                        RigidTransform castStart,
                                        float3 castEnd,
                                        BoxCollider targetBox,
                                        RigidTransform targetBoxTransform,
                                        out ColliderCastResult result)
        {
            var  start = math.transform(castStart, sphereToCast.center);
            var  casterInTargetSpace = math.mul(math.inverse(targetBoxTransform), castStart);
            var  ray = new Ray(math.transform(casterInTargetSpace, start), math.transform(casterInTargetSpace, start + castEnd - castStart.pos));
            bool hit = Raycasting.RaycastRoundedBox(ray, targetBox, sphereToCast.radius, out var fraction, out var normal);

            if (hit)
            {
                var hitTransform = castStart;
                hitTransform.pos = math.lerp(castStart.pos, castEnd, fraction);
                DistanceBetween(sphereToCast, hitTransform, targetBox, targetBoxTransform, 1f, out var distanceResult);
                result = new ColliderCastResult
                {
                    hitpointOnCaster         = distanceResult.hitpointA,
                    hitpointOnTarget         = distanceResult.hitpointB,
                    normalOnSweep            = distanceResult.normalA,
                    normalOnTarget           = distanceResult.normalB,
                    subColliderIndexOnCaster = distanceResult.subColliderIndexA,
                    subColliderIndexOnTarget = distanceResult.subColliderIndexB,
                    distance = math.distance(hitTransform.pos, castStart.pos)
                };
                return(true);
            }
            result = default;
            return(false);
        }
        public static bool ColliderCast(SphereCollider sphereToCast,
                                        RigidTransform castStart,
                                        float3 castEnd,
                                        CompoundCollider targetCompound,
                                        RigidTransform targetCompoundTransform,
                                        out ColliderCastResult result)
        {
            bool hit = false;

            result          = default;
            result.distance = float.MaxValue;
            ref var blob          = ref targetCompound.compoundColliderBlob.Value;
        public static bool ColliderCast(Collider colliderToCast,
                                        RigidTransform castStart,
                                        float3 castEnd,
                                        CapsuleCollider targetCapsule,
                                        RigidTransform targetCapsuleTransform,
                                        out ColliderCastResult result)
        {
            switch (colliderToCast.type)
            {
            case ColliderType.Sphere:
            {
                SphereCollider col = colliderToCast;
                return(ColliderCast(col, castStart, castEnd, targetCapsule, targetCapsuleTransform, out result));
            }

            case ColliderType.Capsule:
            {
                CapsuleCollider col = colliderToCast;
                return(ColliderCast(col, castStart, castEnd, targetCapsule, targetCapsuleTransform, out result));
            }

            case ColliderType.Box:
            {
                BoxCollider col = colliderToCast;
                return(ColliderCast(col, castStart, castEnd, targetCapsule, targetCapsuleTransform, out result));
            }

            case ColliderType.Compound:
            {
                CompoundCollider col = colliderToCast;
                return(ColliderCast(col, castStart, castEnd, targetCapsule, targetCapsuleTransform, out result));
            }

            default:
                result = default;
                return(false);
            }
        }