From e51b9038c804028dfb6ef89e15a5198414efc05e Mon Sep 17 00:00:00 2001 From: Mike Lester Date: Fri, 3 Jan 2025 18:47:24 -0700 Subject: [PATCH] Wind Waker: Fix black bar issue when title demo ends Previously, as soon as the Title demo ended the camera would reset to cinematic trimming mode (because `globals.scnPlay.demo.getName()` is null), then immediately transition back to default trimming. Now the camera stores its trim height via `setTrimHeight()` which is reset on scene creation. This is closer to the game logic. --- src/ZeldaWindWaker/Main.ts | 3 ++- src/ZeldaWindWaker/d_camera.ts | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/ZeldaWindWaker/Main.ts b/src/ZeldaWindWaker/Main.ts index 1c41087c5..46cb16541 100644 --- a/src/ZeldaWindWaker/Main.ts +++ b/src/ZeldaWindWaker/Main.ts @@ -31,7 +31,7 @@ import { LegacyActor__RegisterFallbackConstructor } from './LegacyActor.js'; import { dDlst_2DStatic_c, d_a__RegisterConstructors } from './d_a.js'; import { d_a_sea } from './d_a_sea.js'; import { dBgS } from './d_bg.js'; -import { dCamera_c } from './d_camera.js'; +import { CameraTrimHeight, dCamera_c } from './d_camera.js'; import { EDemoMode, dDemo_manager_c } from './d_demo.js'; import { dDlst_list_Set, dDlst_list_c } from './d_drawlist.js'; import { dKankyo_create, dKy__RegisterConstructors, dKy_setLight, dScnKy_env_light_c } from './d_kankyo.js'; @@ -968,6 +968,7 @@ class DemoDesc extends SceneDesc implements Viewer.SceneDesc { if (demoData !== null) { globals.scnPlay.demo.create(this.id, demoData, this.offsetPos, this.rotY / 180.0 * Math.PI, this.startFrame); + globals.camera.setTrimHeight(this.id != 'title' ? CameraTrimHeight.Cinematic : CameraTrimHeight.Default) globals.camera.snapToCinematic(); } else { console.warn('Failed to load demo data:', this.stbFilename); diff --git a/src/ZeldaWindWaker/d_camera.ts b/src/ZeldaWindWaker/d_camera.ts index 871ca7870..6eb8fd02b 100644 --- a/src/ZeldaWindWaker/d_camera.ts +++ b/src/ZeldaWindWaker/d_camera.ts @@ -22,6 +22,12 @@ const enum CameraMode { Cinematic } +export const enum CameraTrimHeight { + Default, + Cinematic, + Vista, +} + export class dCamera_c extends leafdraw_class { public static PROCESS_NAME = dProcName_e.d_camera; @@ -55,10 +61,9 @@ export class dCamera_c extends leafdraw_class { private demoFov = 0; private demoRoll = 0; private trimHeight = 0; + private trimMode = CameraTrimHeight.Default; private scissor = vec4.create(); - private static trimHeightCinematic = 65.0; - public finishSetup(): void { mat4.invert(this.viewFromWorldMatrix, this.worldFromViewMatrix); mat4.mul(this.clipFromWorldMatrix, this.clipFromViewMatrix, this.viewFromWorldMatrix); @@ -89,6 +94,10 @@ export class dCamera_c extends leafdraw_class { this.cameraModeBlendVal = 1.0; } + public setTrimHeight(trimMode: CameraTrimHeight) { + this.trimMode = trimMode; + } + public override load(globals: dGlobals, userData: any): cPhs__Status { globals.camera = this; fopDwTg_ToDrawQ(globals.frameworkGlobals, this, this.drawPriority); @@ -132,8 +141,13 @@ export class dCamera_c extends leafdraw_class { globals.sceneContext.inputManager.isMouseEnabled = true; } - // From dCamera_c::SetTrimSize() and defaultTriming() - const trimSize = globals.scnPlay.demo.getName() != 'title' ? dCamera_c.trimHeightCinematic : 0; + // From dCamera_c::CalcTrimSize() + let trimSize = 0; + switch (this.trimMode) { + case CameraTrimHeight.Cinematic: trimSize = 65.0; break; + case CameraTrimHeight.Vista: trimSize = 35.0; break; + case CameraTrimHeight.Default: trimSize = 0.0; break; + } // Adapted from dCamera_c::CalcTrimSize() // When switching between Cinematic and Regular camera modes (e.g. when pausing a cutscene),