Пример #1
0
        public static FVec3 SmoothDamp(FVec3 current, FVec3 target, ref FVec3 currentVelocity, Fix64 smoothTime, Fix64 maxSpeed,
                                       Fix64 deltaTime)
        {
            smoothTime = Fix64.Max(Fix64.Epsilon, smoothTime);

            Fix64 num       = ( Fix64 )2 / smoothTime;
            Fix64 num2      = num * deltaTime;
            Fix64 num3      = Fix64.One / (Fix64.One + num2 + ( Fix64 )0.48 * num2 * num2 + ( Fix64 )0.235 * num2 * num2 * num2);
            Fix64 maxLength = maxSpeed * smoothTime;
            FVec3 vector    = current - target;

            vector.ClampMagnitude(maxLength);

            target = current - vector;
            FVec3 vec3 = (currentVelocity + (vector * num)) * deltaTime;

            currentVelocity = (currentVelocity - (vec3 * num)) * num3;

            var vector4 = target + (vector + vec3) * num3;

            if (Dot(target - current, vector4 - target) > Fix64.Zero)
            {
                vector4 = target;
                currentVelocity.Set(Fix64.Zero, Fix64.Zero, Fix64.Zero);
            }
            return(vector4);
        }
Пример #2
0
 public static FVec3 Max(FVec3 v, FVec3 v1)
 {
     return(new FVec3(Fix64.Max(v.x, v1.x), Fix64.Max(v.y, v1.y), Fix64.Max(v.z, v1.z)));
 }
Пример #3
0
 public static FVec3 Max(FVec3 v, Fix64 value)
 {
     return(new FVec3(Fix64.Max(v.x, value), Fix64.Max(v.y, value), Fix64.Max(v.z, value)));
 }
Пример #4
0
 public static FVec4 Max(FVec4 v, FVec4 values)
 {
     return(new FVec4(Fix64.Max(v.x, values.x), Fix64.Max(v.y, values.y), Fix64.Max(v.z, values.z),
                      Fix64.Max(v.w, values.w)));
 }
Пример #5
0
 public static FVec4 Max(FVec4 v, Fix64 value)
 {
     return(new FVec4(Fix64.Max(v.x, value), Fix64.Max(v.y, value), Fix64.Max(v.z, value),
                      Fix64.Max(v.w, value)));
 }