From c791fb7fa3dc469918b4250d5a1c2c2cd675768c Mon Sep 17 00:00:00 2001 From: dominicentek Date: Fri, 1 Sep 2023 19:49:01 +0200 Subject: [PATCH] fix camera timeline --- src/game/level_update.c | 14 ++++++++- src/saturn/imgui/saturn_imgui.cpp | 52 +++++++++++++++---------------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 09b86890..ef58ac02 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1021,9 +1021,21 @@ s32 play_mode_normal(void) { if (gCurrLevelNum == LEVEL_SA && gGlobalTimer < 120) { gMarioState->faceAngle[1] = 0; - if (gCamera) { + if (gCamera) { // i hate the sm64 camera system aaaaaaaaaaaaaaaaaa + float dist = 0; + s16 yaw, pitch; vec3f_set(gCamera->pos, 0.f, 192.f, 264.f); vec3f_set(gCamera->focus, 0.f, 181.f, 28.f); + vec3f_copy(freezecamPos, gCamera->pos); + vec3f_get_dist_and_angle(gCamera->pos, gCamera->focus, &dist, &pitch, &yaw); + freezecamYaw = (float)yaw; + freezecamPitch = (float)pitch; + vec3f_copy(gLakituState.pos, gCamera->pos); + vec3f_copy(gLakituState.focus, gCamera->focus); + vec3f_copy(gLakituState.goalPos, gCamera->pos); + vec3f_copy(gLakituState.goalFocus, gCamera->focus); + gCamera->yaw = calculate_yaw(gCamera->focus, gCamera->pos); + gLakituState.yaw = gCamera->yaw; } } diff --git a/src/saturn/imgui/saturn_imgui.cpp b/src/saturn/imgui/saturn_imgui.cpp index d082f12e..de0ad20b 100644 --- a/src/saturn/imgui/saturn_imgui.cpp +++ b/src/saturn/imgui/saturn_imgui.cpp @@ -400,7 +400,6 @@ void saturn_keyframe_window() { if (timeline.forceWait) keyframe.curve = InterpolationCurve::WAIT; keyframes->push_back(keyframe); } - saturn_keyframe_sort(keyframes); } else saturn_keyframe_apply(entry.first, k_current_frame); @@ -422,6 +421,31 @@ void saturn_keyframe_window() { } } + if (camera_frozen) { + if (keyframe_playing || k_current_frame != k_previous_frame) { + should_update_cam_from_keyframes = false; + vec3f_copy(gCamera->pos, freezecamPos); + vec3f_set_dist_and_angle(gCamera->pos, gCamera->focus, 100, freezecamPitch, freezecamYaw); + gLakituState.roll = freezecamRoll; + } + else { + float dist; + s16 yaw; + s16 pitch; + vec3f_copy(freezecamPos, gCamera->pos); + vec3f_get_dist_and_angle(gCamera->pos, gCamera->focus, &dist, &pitch, &yaw); + freezecamYaw = (float)yaw; + freezecamPitch = (float)pitch; + freezecamRoll = (float)gLakituState.roll; + } + vec3f_copy(gLakituState.pos, gCamera->pos); + vec3f_copy(gLakituState.focus, gCamera->focus); + vec3f_copy(gLakituState.goalPos, gCamera->pos); + vec3f_copy(gLakituState.goalFocus, gCamera->focus); + gCamera->yaw = calculate_yaw(gCamera->focus, gCamera->pos); + gLakituState.yaw = gCamera->yaw; + } + k_previous_frame = k_current_frame; } @@ -780,31 +804,6 @@ void saturn_imgui_update() { //ImGui::ShowDemoWindow(); } - if (camera_frozen) { - if (keyframe_playing || k_current_frame != k_previous_frame) { - should_update_cam_from_keyframes = false; - vec3f_copy(gCamera->pos, freezecamPos); - vec3f_set_dist_and_angle(gCamera->pos, gCamera->focus, 100, freezecamPitch, freezecamYaw); - gLakituState.roll = freezecamRoll; - } - else { - float dist; - s16 yaw; - s16 pitch; - vec3f_copy(freezecamPos, gCamera->pos); - vec3f_get_dist_and_angle(gCamera->pos, gCamera->focus, &dist, &pitch, &yaw); - freezecamYaw = (float)yaw; - freezecamPitch = (float)pitch; - freezecamRoll = (float)gLakituState.roll; - } - vec3f_copy(gLakituState.pos, gCamera->pos); - vec3f_copy(gLakituState.focus, gCamera->focus); - vec3f_copy(gLakituState.goalPos, gCamera->pos); - vec3f_copy(gLakituState.goalFocus, gCamera->focus); - gCamera->yaw = calculate_yaw(gCamera->focus, gCamera->pos); - gLakituState.yaw = gCamera->yaw; - } - is_cc_editing = windowCcEditor; ImGui::Render(); @@ -923,6 +922,7 @@ void saturn_keyframe_camera_popout(string value_name, string id) { else { // Add the timeline for (int i = 0; i < IM_ARRAYSIZE(values); i++) { KeyframeTimeline timeline = KeyframeTimeline(); + timeline.type = KFTYPE_FLOAT; timeline.dest = values[i].second.second; timeline.name = value_name + " " + values[i].first.second; timeline.forceWait = false;