mirror of
https://github.com/Llennpie/Saturn.git
synced 2025-01-22 15:43:05 -05:00
change interpolations
This commit is contained in:
parent
32bb085a83
commit
549cdfd67e
3 changed files with 10 additions and 13 deletions
|
@ -630,10 +630,7 @@ void saturn_keyframe_window() {
|
|||
if (timeline.behavior != KFBEH_DEFAULT) (*keyframe).curve = InterpolationCurve::WAIT;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (k_popout_focused)
|
||||
saturn_keyframe_apply(entry.first, k_current_frame);
|
||||
}
|
||||
else saturn_keyframe_apply(entry.first, k_current_frame);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
|
|
@ -471,9 +471,9 @@ float saturn_keyframe_setup_interpolation(std::string id, int frame, int* keyfra
|
|||
// Interpolate, formulas from easings.net
|
||||
float x = (frame - keyframes[*keyframe].position) / (float)(keyframes[*keyframe + 1].position - keyframes[*keyframe].position);
|
||||
if (*last) x = 1;
|
||||
else if (keyframes[*keyframe].curve == InterpolationCurve::SINE) x = -(cosf(3.141592f * x) - 1) / 2;
|
||||
else if (keyframes[*keyframe].curve == InterpolationCurve::QUADRATIC) x = x < 0.5 ? 2 * x * x : 1 - pow(-2 * x + 2, 2) / 2;
|
||||
else if (keyframes[*keyframe].curve == InterpolationCurve::CUBIC) x = x < 0.5 ? 4 * x * x * x : 1 - pow(-2 * x + 2, 3) / 2;
|
||||
else if (keyframes[*keyframe].curve == InterpolationCurve::SLOW) x = x * x;
|
||||
else if (keyframes[*keyframe].curve == InterpolationCurve::FAST) x = 1 - (1 - x) * (1 - x);
|
||||
else if (keyframes[*keyframe].curve == InterpolationCurve::SMOOTH) x = x < 0.5 ? 2 * x * x : 1 - pow(-2 * x + 2, 2) / 2;
|
||||
else if (keyframes[*keyframe].curve == InterpolationCurve::WAIT) x = floor(x);
|
||||
|
||||
return x;
|
||||
|
|
|
@ -100,9 +100,9 @@ extern float extraction_progress;
|
|||
|
||||
enum InterpolationCurve {
|
||||
LINEAR,
|
||||
SINE,
|
||||
QUADRATIC,
|
||||
CUBIC,
|
||||
SLOW,
|
||||
FAST,
|
||||
SMOOTH,
|
||||
WAIT
|
||||
};
|
||||
enum KeyframeType {
|
||||
|
@ -114,9 +114,9 @@ enum KeyframeType {
|
|||
|
||||
inline std::string curveNames[] = {
|
||||
"Linear",
|
||||
"Sine",
|
||||
"Quadratic",
|
||||
"Cubic",
|
||||
"Start Slow",
|
||||
"Start Fast",
|
||||
"Smooth",
|
||||
"Hold"
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue