2020-11-27 22:47:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using MessagePack;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
|
using static Unity.Mathematics.math;
|
|
|
|
|
|
|
|
|
|
|
|
[Serializable, MessagePackObject, JsonObject]
|
|
|
|
|
|
public class ExponentialCurve
|
|
|
|
|
|
{
|
|
|
|
|
|
[JsonProperty("exponent"), Key(0)]
|
|
|
|
|
|
public float Exponent;
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty("multiplier"), Key(1)]
|
|
|
|
|
|
public float Multiplier;
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty("constant"), Key(2)]
|
|
|
|
|
|
public float Constant;
|
|
|
|
|
|
|
|
|
|
|
|
public float Evaluate(float value) => Multiplier * pow(value, Exponent) + Constant;
|
|
|
|
|
|
}
|
2020-11-29 22:50:12 +00:00
|
|
|
|
|
|
|
|
|
|
[Serializable, MessagePackObject, JsonObject]
|
2020-12-01 00:16:11 +00:00
|
|
|
|
public class ExponentialLerp
|
2020-11-29 22:50:12 +00:00
|
|
|
|
{
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("exponent"), Key(0)]
|
|
|
|
|
|
public float Exponent;
|
2020-11-29 22:50:12 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("max"), Key(1)]
|
|
|
|
|
|
public float Minimum;
|
2020-11-29 22:50:12 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("min"), Key(2)]
|
|
|
|
|
|
public float Maximum;
|
2020-11-29 22:50:12 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
public float Evaluate(float value) => Minimum + pow(saturate(value), Exponent) * (Maximum - Minimum);
|
2020-11-29 22:50:12 +00:00
|
|
|
|
}
|