public static SphereCollider ScaleCollider(SphereCollider sphere, PhysicsScale scale)
 {
     CheckNoOrUniformScale(scale, ColliderType.Sphere);
     sphere.center *= scale.scale.x;
     sphere.radius *= scale.scale.x;
     return(sphere);
 }
Example #2
0
 private static void CheckNoOrValidScale(PhysicsScale scale, ColliderType type)
 {
     if (scale.state == PhysicsScale.State.NonComputable)
     {
         throw new InvalidOperationException("The collider cannot be scaled with a noncomputable scale");
     }
 }
Example #3
0
 public static BoxCollider ScaleCollider(BoxCollider box, PhysicsScale scale)
 {
     CheckNoOrValidScale(scale, ColliderType.Box);
     box.center   *= scale.scale;
     box.halfSize *= scale.scale;
     return(box);
 }
 public static CapsuleCollider ScaleCollider(CapsuleCollider capsule, PhysicsScale scale)
 {
     CheckNoOrUniformScale(scale, ColliderType.Capsule);
     capsule.pointA *= scale.scale.x;
     capsule.pointB *= scale.scale.x;
     capsule.radius *= scale.scale.x;
     return(capsule);
 }
Example #5
0
        public static Collider ScaleCollider(Collider collider, PhysicsScale scale)
        {
            switch (collider.type)
            {
            case ColliderType.Sphere: return(ScaleCollider((SphereCollider)collider, scale));

            case ColliderType.Capsule: return(ScaleCollider((CapsuleCollider)collider, scale));

            default: throw new InvalidOperationException("Collider type not supported yet.");
            }
        }
Example #6
0
        public static CompoundCollider ScaleCollider(CompoundCollider compound, PhysicsScale scale)
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            if (scale.state == PhysicsScale.State.NonComputable | scale.state == PhysicsScale.State.NonUniform)
            {
                throw new InvalidOperationException("Error: Compound Collider must be scaled with no scale or uniform scale.");
            }
#endif
            compound.scale *= scale.scale.x;
            return(compound);
        }
Example #7
0
        public static SphereCollider ScaleCollider(SphereCollider sphere, PhysicsScale scale)
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            if (scale.state == PhysicsScale.State.NonComputable | scale.state == PhysicsScale.State.NonUniform)
            {
                throw new InvalidOperationException("Error: Sphere Collider must be scaled with no scale or uniform scale.");
            }
#endif
            sphere.center *= scale.scale.x;
            sphere.radius *= scale.scale.x;
            return(sphere);
        }
Example #8
0
        public static CapsuleCollider ScaleCollider(CapsuleCollider capsule, PhysicsScale scale)
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            if (scale.state == PhysicsScale.State.NonComputable | scale.state == PhysicsScale.State.NonUniform)
            {
                throw new InvalidOperationException("Error: Capsule Collider must be scaled with no scale or uniform scale.");
            }
#endif
            capsule.pointA *= scale.scale.x;
            capsule.pointB *= scale.scale.x;
            capsule.radius *= scale.scale.x;
            return(capsule);
        }
        public static Collider ScaleCollider(Collider collider, PhysicsScale scale)
        {
            switch (collider.type)
            {
            case ColliderType.Sphere: return(ScaleCollider((SphereCollider)collider, scale));

            case ColliderType.Capsule: return(ScaleCollider((CapsuleCollider)collider, scale));

            case ColliderType.Compound: return(ScaleCollider((CompoundCollider)collider, scale));

            default: ThrowUnsupportedType(); return(new Collider());
            }
        }
        private static void CheckNoOrUniformScale(PhysicsScale scale, ColliderType type)
        {
            if (scale.state == PhysicsScale.State.NonComputable | scale.state == PhysicsScale.State.NonUniform)
            {
                switch (type)
                {
                case ColliderType.Sphere: throw new InvalidOperationException("Sphere Collider must be scaled with no scale or uniform scale.");

                case ColliderType.Capsule: throw new InvalidOperationException("Capsule Collider must be scaled with no scale or uniform scale.");

                case ColliderType.Compound: throw new InvalidOperationException("Compound Collider must be scaled with no scale or uniform scale.");

                default: throw new InvalidOperationException("Failed to scale unknown collider type.");
                }
            }
        }
 public static CompoundCollider ScaleCollider(CompoundCollider compound, PhysicsScale scale)
 {
     CheckNoOrUniformScale(scale, ColliderType.Compound);
     compound.scale *= scale.scale.x;
     return(compound);
 }