keyframmable expressions

This commit is contained in:
Dominicentek 2023-12-12 17:43:20 +01:00
parent a0350469f4
commit 60dea755b2
4 changed files with 23 additions and 1 deletions

View file

@ -90,7 +90,6 @@ s32 is_anim_past_end(struct MarioState *m) {
* Sets Mario's animation without any acceleration, running at its default rate.
*/
s16 force_set_mario_animation(struct MarioState *m, s32 targetAnimID) {
printf("%d\n", targetAnimID);
struct Object *o = m->marioObj;
struct Animation *targetAnim = m->animation->targetAnim;

View file

@ -621,6 +621,12 @@ void saturn_keyframe_window() {
(*keyframe).value[3] = anim_state->speed;
(*keyframe).value[4] = anim_state->id;
}
if (timeline.type == KFTYPE_EXPRESSION) {
Model* model = (Model*)timeline.dest;
for (int i = 0; i < model->Expressions.size(); i++) {
(*keyframe).value[i] = model->Expressions[i].CurrentIndex;
}
}
if (timeline.behavior != KFBEH_DEFAULT) (*keyframe).curve = InterpolationCurve::WAIT;
}
}
@ -1140,6 +1146,12 @@ void saturn_create_keyframe(std::string id, InterpolationCurve curve) {
keyframe.value.push_back(anim_state->speed);
keyframe.value.push_back(anim_state->id);
}
if (timeline.type == KFTYPE_EXPRESSION) {
Model* model = (Model*)timeline.dest;
for (int i = 0; i < model->Expressions.size(); i++) {
keyframe.value.push_back(model->Expressions[i].CurrentIndex);
}
}
keyframe.curve = curve;
k_frame_keys[id].second.push_back(keyframe);
saturn_keyframe_sort(&k_frame_keys[id].second);

View file

@ -501,6 +501,11 @@ void sdynos_imgui_menu() {
}
ImGui::Separator();
ImGui::Text("Keyframe expressions");
saturn_keyframe_popout_next_line("k_mario_expr");
ImGui::Separator();
// Model Metadata
if (!current_model.Author.empty()) {
string metaLabelText = (ICON_FK_USER " " + current_model.Name);

View file

@ -489,6 +489,12 @@ bool saturn_keyframe_apply(std::string id, int frame) {
chainer_index = 0;
anim_play_button();
}
if (timeline.type == KFTYPE_EXPRESSION) {
Model* dest = (Model*)timeline.dest;
for (int i = 0; i < keyframes[idx].value.size(); i++) {
dest->Expressions[i].CurrentIndex = keyframes[idx].value[i];
}
}
return idx + 1 == keyframes.size();
}