1 #include "animation/keyframe_double.hpp"
2 #include "generated/core_registry.hpp"
6 // This whole class is intentionally misnamed to match our editor code. The
7 // editor uses doubles (float64) for numeric values but at runtime 32 bit
8 // floating point numbers suffice. So even though this is a "double keyframe" to
9 // match editor names, the actual values are stored and applied in 32 bits.
11 static void applyDouble(Core* object, int propertyKey, float mix, float value)
15 CoreRegistry::setDouble(object, propertyKey, value);
19 float mixi = 1.0 - mix;
20 CoreRegistry::setDouble(
23 CoreRegistry::getDouble(object, propertyKey) * mixi + value * mix);
27 void KeyFrameDouble::apply(Core* object, int propertyKey, float mix)
29 applyDouble(object, propertyKey, mix, value());
32 void KeyFrameDouble::applyInterpolation(Core* object,
35 const KeyFrame* nextFrame,
38 auto kfd = nextFrame->as<KeyFrameDouble>();
39 const KeyFrameDouble& nextDouble = *kfd;
40 float f = (currentTime - seconds()) / (nextDouble.seconds() - seconds());
42 if (CubicInterpolator* cubic = interpolator())
44 f = cubic->transform(f);
48 object, propertyKey, mix, value() + (nextDouble.value() - value()) * f);