fix camera timeline

This commit is contained in:
dominicentek 2023-09-01 19:49:01 +02:00
parent acffdf4806
commit c791fb7fa3
2 changed files with 39 additions and 27 deletions

View file

@ -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;
}
}

View file

@ -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;