From b45f7cc3d4c0bf5ecbfaf6114598bb8fd514c965 Mon Sep 17 00:00:00 2001 From: MelonSpeedruns Date: Mon, 16 May 2022 11:38:25 -0400 Subject: [PATCH] Camera resets to Auto when going through doors or changing maps --- soh/include/z64player.h | 4 ++++ soh/src/code/z_camera.c | 16 ++++++---------- soh/src/code/z_play.c | 4 ++++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/soh/include/z64player.h b/soh/include/z64player.h index 9bce60ffe..1b7525254 100644 --- a/soh/include/z64player.h +++ b/soh/include/z64player.h @@ -5,6 +5,10 @@ struct Player; +bool manualCamera; +f32 camX; +f32 camY; + typedef enum { /* 0 */ PLAYER_SWORD_NONE, /* 1 */ PLAYER_SWORD_KOKIRI, diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index 114593fd7..dbbe24d03 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -1410,10 +1410,6 @@ s32 Camera_Noop(Camera* camera) { return true; } -bool manualCamera; -f32 camX; -f32 camY; - s32 SetCameraManual(Camera* camera) { f32 newCamX = -D_8015BD7C->state.input[0].cur.cam_x; f32 newCamY = D_8015BD7C->state.input[0].cur.cam_y; @@ -1441,6 +1437,7 @@ s32 Camera_Free(Camera* camera) { f32 playerHeight = Player_GetHeight(camera->player); f32 sp94; CamColChk camBgChk; + PosRot* playerPosRot = &camera->playerPosRot; Vec3f at; sCameraInterfaceFlags = norm1->interfaceFlags; @@ -1475,14 +1472,14 @@ s32 Camera_Free(Camera* camera) { VecSph eyeAdjustment; const f32 camSpeed = 0.5f; - camera->animState = 1; + camera->animState = 0; at.x = Camera_LERPCeilF(camera->player->actor.world.pos.x, camera->at.x, camSpeed, 1.0f); at.y = Camera_LERPCeilF(camera->player->actor.world.pos.y + (camera->player->rideActor != NULL ? Player_GetHeight(camera->player) / 2 - : Player_GetHeight(camera->player)) / 1.2f, - camera->at.y, - camSpeed, 1.0f); + : Player_GetHeight(camera->player)) / + 1.2f, + camera->at.y, camSpeed, 1.0f); at.z = Camera_LERPCeilF(camera->player->actor.world.pos.z, camera->at.z, camSpeed, 1.0f); OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment, &at, &camera->eye); @@ -1496,8 +1493,7 @@ s32 Camera_Free(Camera* camera) { if (rad > 150) { camera->dist = eyeAdjustment.r = Camera_LERPCeilF(150.0f, camera->dist, camSpeed / 4, 1.0f); - } - else { + } else { camera->dist = eyeAdjustment.r = rad; } } else { diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 632ed41f6..c46f7bcc6 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -446,6 +446,10 @@ void Gameplay_Update(GlobalContext* globalCtx) { ActorOverlayTable_LogPrint(); } + if (CVar_GetS32("gFreeCamera", 0) && Player_InCsMode(globalCtx)) { + manualCamera = false; + } + gSegments[4] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment); gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment);