From 5b28472d477bab101dee2a0f469fe2aee2c58a01 Mon Sep 17 00:00:00 2001 From: quarrel07 <178681861+quarrel07@users.noreply.github.com> Date: Sun, 26 Jul 2026 22:00:47 -0700 Subject: Fix garbage frame flash on cinematic camera cuts (#720) * Fix garbage frame flash on cinematic camera cuts Frame interpolation blended matrices across instant camera teleports in attract/demo and post-race cameras, flashing 1-2 frames of sheared geometry. Complete the existing camera-epoch mechanism: flag a cut in func_80019890 when the camera moves >100 units, and have the interpolator snap that frame to the new view instead of blending. Co-Authored-By: Claude Fable 5 * Retrigger CI (transient 502 downloading libogg from gitlab.xiph.org) * Name the cinematic shot dispatcher Review feedback on #720: func_80019890 -> camera_start_cinematic_shot. It starts whichever shot D_80164680 has selected for a camera, dispatching to the per-shot setup that teleports the camera to the shot's opening position, which is why the cut detection lives there. Co-Authored-By: Claude Fable 5 * Apply fix to freecam Added FrameInterpolation_DontInterpolateCamera calls to improve camera behavior when changing target players. --------- Co-authored-by: Claude Fable 5 Co-authored-by: MegaMech --- src/code_80005FD0.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'src/code_80005FD0.c') diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 04b6107bc..b0e8210e8 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -41,6 +41,7 @@ #include #include "port/Game.h" +#include "port/interpolation/FrameInterpolation.h" #include "engine/tracks/Track.h" #include "engine/RaceManager.h" @@ -6550,12 +6551,19 @@ void func_80019760(Camera* camera, UNUSED Player* player, UNUSED s32 arg2, s32 c camera->rot[2] = 0; } -void func_80019890(s32 playerId, s32 cameraId) { +// Starts the cinematic shot selected in D_80164680[cameraId]: dispatches to the +// per-shot setup, which teleports the camera to the shot's opening position. +void camera_start_cinematic_shot(s32 playerId, s32 cameraId) { s32 pathIndex; + f32 prevX, prevY, prevZ, dx, dy, dz; Camera* camera = camera1; camera += cameraId; camera->playerId = playerId; + prevX = camera->pos[0]; + prevY = camera->pos[1]; + prevZ = camera->pos[2]; + D_801646C0[cameraId] = 0; pathIndex = gPathIndexByPlayerId[playerId]; @@ -6614,6 +6622,15 @@ void func_80019890(s32 playerId, s32 cameraId) { if ((s16) D_80164680[cameraId] == 9) { D_80163DD8[cameraId] = (s32) pathIndex; } + + // Flag a camera cut only when the camera teleported to a new shot; + // small moves are continuous tracking updates that should stay smooth. + dx = camera->pos[0] - prevX; + dy = camera->pos[1] - prevY; + dz = camera->pos[2] - prevZ; + if ((dx * dx + dy * dy + dz * dz) > 100.0f * 100.0f) { + FrameInterpolation_DontInterpolateCamera(); + } } void func_80019B50(s32 cameraIndex, u16 arg1) { @@ -6737,11 +6754,11 @@ void func_80019DF4(void) { void func_80019E58(void) { D_80164680[0] = 1; - func_80019890(0, 0); + camera_start_cinematic_shot(0, 0); D_80164670[0] = D_80164678[0]; D_80164678[0] = 1; D_80164680[1] = 9; - func_80019890(0, 1); + camera_start_cinematic_shot(0, 1); D_80164670[1] = D_80164678[1]; D_80164678[1] = 0; } @@ -6866,7 +6883,7 @@ void func_8001A348(s32 cameraId, f32 arg1, s32 arg2) { playerId = cameras[cameraId].playerId; D_80164688[cameraId] = arg1; D_80164680[cameraId] = func_8001A310((s32) gNearestPathPointByCameraId[cameraId], arg2); - func_80019890(playerId, cameraId); + camera_start_cinematic_shot(playerId, cameraId); } void func_8001A3D8(s32 arg0, f32 arg1, s32 arg2) { @@ -6876,7 +6893,7 @@ void func_8001A3D8(s32 arg0, f32 arg1, s32 arg2) { D_80164688[arg0] = arg1; if (arg2 != D_80164680[arg0]) { D_80164680[arg0] = arg2; - func_80019890(playerId, arg0); + camera_start_cinematic_shot(playerId, arg0); } } @@ -6891,7 +6908,7 @@ void func_8001A450(s32 playerId, s32 arg1, s32 arg2) { temp_v0 = func_8001A310(waypoint, (temp_v1 + 1) % 10); if ((temp_v0 != temp_v1) || (arg2 != playerId)) { D_80164680[arg1] = temp_v0; - func_80019890(arg2, arg1); + camera_start_cinematic_shot(arg2, arg1); } } } @@ -6938,7 +6955,7 @@ void func_8001A588(UNUSED u16* localD_80152300, Camera* camera, Player* player, } else { func_8001A124((s32) playerId, cameraIndex); } - func_80019890((s32) playerId, cameraIndex); + camera_start_cinematic_shot((s32) playerId, cameraIndex); } if ((D_80164680[cameraIndex] == 14) || (D_80164680[cameraIndex] == 0)) { -- cgit v1.2.3