1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-17 20:42:29 +00:00

spring function clarification

This commit is contained in:
Sam Hellawell 2024-05-10 17:57:11 +01:00
parent 340252007b
commit bce97f49b4

View File

@ -83,31 +83,32 @@ namespace MWRender
} }
} }
float springOutGeneric(float x, float lambda, float w) float springOutGeneric(float x, float lambda)
{ {
// Higher lambda = lower swing amplitude. 1 = 150% swing amplitude. // Higher lambda = lower swing amplitude. 1 = 150% swing amplitude.
// W corresponds to the amount of overswings, more = more. 4.71 = 1 overswing, 7.82 = 2 // w corresponds to the frequency of oscillation in the easing function, controlling the amount of overswing
constexpr float w = 1.5f * osg::PIf; // 4.71238
return 1 - expf(-lambda * x) * cos(w * x); return 1 - expf(-lambda * x) * cos(w * x);
} }
float springOutWeak(float x) float springOutWeak(float x)
{ {
return springOutGeneric(x, 4, 4.71); return springOutGeneric(x, 4);
} }
float springOutMed(float x) float springOutMed(float x)
{ {
return springOutGeneric(x, 3, 4.71); return springOutGeneric(x, 3);
} }
float springOutStrong(float x) float springOutStrong(float x)
{ {
return springOutGeneric(x, 2, 4.71); return springOutGeneric(x, 2);
} }
float springOutTooMuch(float x) float springOutTooMuch(float x)
{ {
return springOutGeneric(x, 1, 4.71); return springOutGeneric(x, 1);
} }
const std::unordered_map<std::string, EasingFn> easingsMap = { const std::unordered_map<std::string, EasingFn> easingsMap = {