Exemple #1
0
        public static Vec2 SmoothDamp(Vec2 current, Vec2 target, ref Vec2 currentVelocity, float smoothTime, float maxSpeed, float deltaTime)
        {
            smoothTime = UMath.Max(0.0001f, smoothTime);
            float num       = 2f / smoothTime;
            float num2      = num * deltaTime;
            float d         = 1f / (1f + num2 + 0.48f * num2 * num2 + 0.235f * num2 * num2 * num2);
            Vec2  vector    = current - target;
            Vec2  Vec2      = target;
            float maxLength = maxSpeed * smoothTime;

            vector = ClampMagnitude(vector, maxLength);
            target = current - vector;
            Vec2 vector3 = (currentVelocity + num * vector) * deltaTime;

            currentVelocity = (currentVelocity - num * vector3) * d;
            Vec2 vector4 = target + (vector + vector3) * d;

            if (Dot(Vec2 - current, vector4 - Vec2) > 0f)
            {
                vector4         = Vec2;
                currentVelocity = (vector4 - Vec2) / deltaTime;
            }
            return(vector4);
        }
Exemple #2
0
 public override int GetHashCode()
 {
     return(UMath.Max(x + y + z, int.MaxValue).GetHashCode());
 }