2026-06-13 04:56:50 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2020-12-22 03:13:43 +00:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
|
using System;
|
2020-11-27 22:47:33 +00:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using MessagePack;
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
using static Unity.Mathematics.math;
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[Serializable, MessagePackObject]
|
2020-11-27 22:47:33 +00:00
|
|
|
public class ExponentialCurve
|
|
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Key(0), Inspectable]
|
2020-11-27 22:47:33 +00:00
|
|
|
public float Exponent;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
|
|
|
|
[Key(1), Inspectable]
|
2020-11-27 22:47:33 +00:00
|
|
|
public float Multiplier;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
|
|
|
|
[Key(2), Inspectable]
|
2020-11-27 22:47:33 +00:00
|
|
|
public float Constant;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
2020-11-27 22:47:33 +00:00
|
|
|
public float Evaluate(float value) => Multiplier * pow(value, Exponent) + Constant;
|
|
|
|
|
}
|
2020-11-29 22:50:12 +00:00
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[Serializable, MessagePackObject]
|
2020-12-01 00:16:11 +00:00
|
|
|
public class ExponentialLerp
|
2020-11-29 22:50:12 +00:00
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Key(0), Inspectable]
|
2020-12-01 00:16:11 +00:00
|
|
|
public float Exponent;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
|
|
|
|
[Key(1), Inspectable]
|
2020-12-01 00:16:11 +00:00
|
|
|
public float Minimum;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
|
|
|
|
[Key(2), Inspectable]
|
2020-12-01 00:16:11 +00:00
|
|
|
public float Maximum;
|
2026-06-13 04:56:50 +01: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
|
|
|
}
|