12#define M_PI 3.14159265358979323846
19float clamp01(
float t) {
return std::clamp(
t, 0.f, 1.f); }
37 buffer_[index_] =
value;
53 if (!x_ || !y_ || !z_) {
65 if (!
kind ||
kind[0] ==
'\0' || std::strcmp(
kind,
"linear") == 0)
return t;
66 if (std::strcmp(
kind,
"inQuad") == 0)
return t *
t;
67 if (std::strcmp(
kind,
"outQuad") == 0)
return 1.f - (1.f -
t) * (1.f -
t);
68 if (std::strcmp(
kind,
"inOutQuad") == 0)
69 return t < 0.5f ? 2.f *
t *
t : 1.f - std::pow(-2.f *
t + 2.f, 2.f) * 0.5f;
70 if (std::strcmp(
kind,
"inCubic") == 0)
return t *
t *
t;
71 if (std::strcmp(
kind,
"outCubic") == 0)
return 1.f - std::pow(1.f -
t, 3.f);
72 if (std::strcmp(
kind,
"inOutCubic") == 0)
73 return t < 0.5f ? 4.f *
t *
t *
t : 1.f - std::pow(-2.f *
t + 2.f, 3.f) * 0.5f;
74 if (std::strcmp(
kind,
"inSine") == 0)
return 1.f - std::cos(
t *
float(
M_PI) * 0.5f);
75 if (std::strcmp(
kind,
"outSine") == 0)
return std::sin(
t *
float(
M_PI) * 0.5f);
76 if (std::strcmp(
kind,
"inOutSine") == 0)
return -(std::cos(
float(
M_PI) *
t) - 1.f) * 0.5f;
77 if (std::strcmp(
kind,
"inExpo") == 0)
return t <= 0.f ? 0.f : std::pow(2.f, 10.f *
t - 10.f);
78 if (std::strcmp(
kind,
"outExpo") == 0)
return t >= 1.f ? 1.f : 1.f - std::pow(2.f, -10.f *
t);
79 if (std::strcmp(
kind,
"inOutExpo") == 0) {
80 if (
t <= 0.f)
return 0.f;
81 if (
t >= 1.f)
return 1.f;
82 return t < 0.5f ? std::pow(2.f, 20.f *
t - 10.f) * 0.5f
83 : (2.f - std::pow(2.f, -20.f *
t + 10.f)) * 0.5f;
87 constexpr float backS = 1.70158f;
88 if (std::strcmp(
kind,
"inBack") == 0)
return t *
t * ((backS + 1.f) *
t - backS);
89 if (std::strcmp(
kind,
"outBack") == 0) {
90 const float u =
t - 1.f;
91 return u *
u * ((backS + 1.f) *
u + backS) + 1.f;
93 if (std::strcmp(
kind,
"inOutBack") == 0) {
94 const float s = backS * 1.525f;
96 const float u =
t * 2.f;
97 return 0.5f * (
u *
u * ((
s + 1.f) *
u -
s));
99 const float u =
t * 2.f - 2.f;
100 return 0.5f * (
u *
u * ((
s + 1.f) *
u +
s) + 2.f);
104 if (std::strcmp(
kind,
"inElastic") == 0) {
105 if (t <= 0.f || t >= 1.f)
return t;
106 return -std::pow(2.f, 10.f *
t - 10.f) *
107 std::sin((
t * 10.f - 10.75f) * (2.f *
float(
M_PI) / 3.f));
109 if (std::strcmp(
kind,
"outElastic") == 0) {
110 if (t <= 0.f || t >= 1.f)
return t;
111 return std::pow(2.f, -10.f *
t) *
112 std::sin((
t * 10.f - 0.75f) * (2.f *
float(
M_PI) / 3.f)) +
115 if (std::strcmp(
kind,
"inOutElastic") == 0) {
116 if (t <= 0.f || t >= 1.f)
return t;
118 return -0.5f * std::pow(2.f, 20.f *
t - 10.f) *
119 std::sin((20.f *
t - 11.125f) * (2.f *
float(
M_PI) / 4.5f));
121 return std::pow(2.f, -20.f *
t + 10.f) *
122 std::sin((20.f *
t - 11.125f) * (2.f *
float(
M_PI) / 4.5f)) * 0.5f +
127 auto outBounce = [](
float x) {
128 constexpr float n1 = 7.5625f;
129 constexpr float d1 = 2.75f;
130 if (
x < 1.f / d1)
return n1 *
x *
x;
133 return n1 *
x *
x + 0.75f;
137 return n1 *
x *
x + 0.9375f;
140 return n1 *
x *
x + 0.984375f;
142 if (std::strcmp(
kind,
"inBounce") == 0)
return 1.f - outBounce(1.f -
t);
143 if (std::strcmp(
kind,
"outBounce") == 0)
return outBounce(
t);
144 if (std::strcmp(
kind,
"inOutBounce") == 0) {
145 return t < 0.5f ? (1.f - outBounce(1.f - 2.f *
t)) * 0.5f
146 : (1.f + outBounce(2.f *
t - 1.f)) * 0.5f;
154 if (!r_ || !g_ || !b_ || !a_) {
166 if (!x_ || !y_ || !z_ || !w_) {
178 if (!(
t > 0.f) || !(
t < 1.f) || frequency < 1)
return 0.f;
179 if (!std::isfinite(
t) || !std::isfinite(dampingRatio))
return 0.f;
180 const float freq =
static_cast<float>(frequency);
181 const float angular = freq * float(
M_PI);
182 const float dampingFactor = dampingRatio * freq / (2.f * float(
M_PI));
183 return std::sin(angular *
t) * std::exp(-dampingFactor *
t);
187 if (frequency < 1) frequency = 1;
188 const float clamped = std::clamp(
t, 0.f, 1.f);
189 const int step =
static_cast<int>(clamped *
static_cast<float>(frequency) * 2.f);
190 std::uint32_t
h =
seed;
191 h ^= 0x9E3779B9u * (
static_cast<std::uint32_t
>(axis) + 1u);
192 h ^= 0x85EBCA6Bu * (
static_cast<std::uint32_t
>(
step) + 1u);
193 h ^=
static_cast<std::uint32_t
>(frequency) * 0xC2B2AE35u;
200 const float u =
static_cast<float>(
h & 0x00FFFFFFu) /
static_cast<float>(0x00FFFFFFu);
201 return u * 2.f - 1.f;
206 a.a + (
b.a -
a.a) *
t};
211 const float len = std::sqrt(
q.x *
q.x +
q.y *
q.y +
q.z *
q.z +
q.w *
q.w);
212 if (!(len > 0.f))
return MotionQuat{0.f, 0.f, 0.f, 1.f};
213 const float inv = 1.f / len;
218 float dot =
a.x *
b.x +
a.y *
b.y +
a.z *
b.z +
a.w *
b.w;
223 constexpr float kEps = 0.9995f;
226 a.z + (
b.z -
a.z) *
t,
a.w + (
b.w -
a.w) *
t});
228 const float theta0 = std::acos(std::clamp(dot, -1.f, 1.f));
229 const float theta = theta0 *
t;
230 const float sinTheta0 = std::sin(theta0);
231 const float s0 = std::sin(theta0 - theta) / sinTheta0;
232 const float s1 = std::sin(theta) / sinTheta0;
234 a.w * s0 +
b.w * s1};
Stable, structured diagnostics shared by engine modules.
std::array< double, 10 > q
LitMotion-style typed motion handles, values, and sink interfaces.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
EVENGINE_API_FOUNDATION public API.
Move-only operation result carrying either a value or Status.
static Result success(T value)
Construct a successful result owning value.
static Result failure(Status status)
Construct a failed result from a structured status.
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
eve::Result< void > write(MotionColor value) override
Writes .
eve::Result< void > write(float value) override
Writes .
eve::Result< void > write(float value) override
Writes .
eve::Result< void > write(MotionQuat value) override
Writes .
eve::Result< void > write(MotionVec2 value) override
Writes .
eve::Result< void > write(MotionVec3 value) override
Writes .
MotionQuat slerpMotionQuat(MotionQuat a, MotionQuat b, float t)
Spherical linear interpolation for MotionQuat (shortest path).
float evaluateMotionOscillation(float t, int frequency, float dampingRatio)
LitMotion-style damped sine envelope in [0,1] progress.
MotionColor lerpMotionColor(MotionColor a, MotionColor b, float t)
Component-wise lerp for MotionColor.
float evaluateMotionShakeSign(std::uint32_t seed, int frequency, float t, int axis)
Deterministic shake sign in [-1,1] for axis (0..n).
float evaluateMotionEase(float t, const char *kind)
Evaluate an ease curve; kinds match Math.ease / Tween.
Compact RGBA color used by motion adapters.
Compact quaternion used by motion adapters (xyzw).
Compact float2 used by motion adapters (avoids graphics math deps).
Compact float3 used by motion adapters.