From 9c6031c98683af6114d71d0f1f8c0ffbab5c7306 Mon Sep 17 00:00:00 2001 From: SteelT Date: Sun, 14 Sep 2025 22:58:18 -0400 Subject: [PATCH] Camera height affects hud transparency of HUD elements like new lap, position bulb... Not the most pretty code written as ideally there would be a common codepath, but it's functional. --- src/k_hud.cpp | 23 ++++++++++++++--------- src/k_hud.h | 2 ++ src/p_local.h | 2 ++ src/p_user.c | 3 +++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 9a9ecc66d..5e9f47a07 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6741,7 +6741,9 @@ static void K_drawKartStartBulbs(void) } } - V_DrawFixedPatch(x, y, FRACUNIT, V_SNAPTOTOP|V_SPLITSCREEN, + INT32 hudtransflags = (camera[R_GetViewNumber()].chaseheight > HUDTRANS_CAMHEIGHT_MAX) ? V_30TRANS : 0; + + V_DrawFixedPatch(x, y, FRACUNIT, V_SNAPTOTOP|V_SPLITSCREEN|hudtransflags, (r_splitscreen ? kp_prestartbulb_split[patchnum] : kp_prestartbulb[patchnum]), NULL); x += spacing; } @@ -6794,6 +6796,7 @@ static void K_drawKartStartBulbs(void) static void K_drawKartStartCountdown(void) { INT32 pnum = 0; + INT32 hudtransflags = (camera[R_GetViewNumber()].chaseheight > HUDTRANS_CAMHEIGHT_MAX) ? V_30TRANS : 0; if (leveltime >= introtime && leveltime < starttime-(3*TICRATE)) { @@ -6835,7 +6838,7 @@ static void K_drawKartStartCountdown(void) if (r_splitscreen) // splitscreen pnum += 10; - V_DrawScaledPatch(STCD_X - (SHORT(kp_startcountdown[pnum]->width)/2), STCD_Y - (SHORT(kp_startcountdown[pnum]->height)/2), V_SPLITSCREEN, kp_startcountdown[pnum]); + V_DrawScaledPatch(STCD_X - (SHORT(kp_startcountdown[pnum]->width)/2), STCD_Y - (SHORT(kp_startcountdown[pnum]->height)/2), V_SPLITSCREEN|hudtransflags, kp_startcountdown[pnum]); } } @@ -7107,9 +7110,11 @@ static void K_drawLapStartAnim(void) oldval = (48 - (32 * std::max(0, progressOld - 76))) * FRACUNIT; interpy = R_InterpolateFixed(oldval, newval); + INT32 hudtransflags = (camera[R_GetViewNumber()].chaseheight > HUDTRANS_CAMHEIGHT_MAX) ? V_30TRANS : V_HUDTRANS; + V_DrawFixedPatch( interpx, interpy, - FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, + FRACUNIT, V_SNAPTOTOP|hudtransflags, (modeattacking ? kp_lapanim_emblem[1] : kp_lapanim_emblem[0]), colormap); if (stplyr->karthud[khud_laphand] >= 1 && stplyr->karthud[khud_laphand] <= 3) @@ -7120,7 +7125,7 @@ static void K_drawLapStartAnim(void) V_DrawFixedPatch( interpx, interpy, - FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, + FRACUNIT, V_SNAPTOTOP|hudtransflags, kp_lapanim_hand[stplyr->karthud[khud_laphand]-1], NULL); } @@ -7133,7 +7138,7 @@ static void K_drawLapStartAnim(void) V_DrawFixedPatch( interpx, // 27 30*FRACUNIT, // 24 - FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, + FRACUNIT, V_SNAPTOTOP|hudtransflags, kp_lapanim_final[std::min(progress/2, 10)], NULL); if (progress/2-12 >= 0) @@ -7145,7 +7150,7 @@ static void K_drawLapStartAnim(void) V_DrawFixedPatch( interpx, // 194 30*FRACUNIT, // 24 - FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, + FRACUNIT, V_SNAPTOTOP|hudtransflags, kp_lapanim_lap[std::min(progress/2-12, 6)], NULL); } } @@ -7158,7 +7163,7 @@ static void K_drawLapStartAnim(void) V_DrawFixedPatch( interpx, // 61 30*FRACUNIT, // 24 - FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, + FRACUNIT, V_SNAPTOTOP|hudtransflags, kp_lapanim_lap[std::min(progress/2, 6)], NULL); if (progress/2-8 >= 0) @@ -7170,7 +7175,7 @@ static void K_drawLapStartAnim(void) V_DrawFixedPatch( interpx, // 194 30*FRACUNIT, // 24 - FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, + FRACUNIT, V_SNAPTOTOP|hudtransflags, kp_lapanim_number[(((UINT32)stplyr->latestlap) / 10)][std::min(progress/2-8, 2)], NULL); if (progress/2-10 >= 0) @@ -7182,7 +7187,7 @@ static void K_drawLapStartAnim(void) V_DrawFixedPatch( interpx, // 221 30*FRACUNIT, // 24 - FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, + FRACUNIT, V_SNAPTOTOP|hudtransflags, kp_lapanim_number[(((UINT32)stplyr->latestlap) % 10)][std::min(progress/2-10, 2)], NULL); } } diff --git a/src/k_hud.h b/src/k_hud.h index d0b5ba81a..885715402 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -27,6 +27,8 @@ extern "C" { #define MARGINLEVELS 24 +#define HUDTRANS_CAMHEIGHT_MAX (120*FRACUNIT) // The camera height past this point where hud transparency should take affect + extern INT32 MINI_X, MINI_Y; struct trackingResult_t diff --git a/src/p_local.h b/src/p_local.h index 8723dca5c..fab69dc5c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -97,6 +97,8 @@ struct camera_t angle_t aiming; + fixed_t chaseheight; // Effective chasecam height, unscaled + // Things used by FS cameras. fixed_t viewheight; angle_t startangle; diff --git a/src/p_user.c b/src/p_user.c index 6eb62efda..3a945c39b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3439,6 +3439,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } } + thiscam->chaseheight = FixedDiv(camheight, cameraScale); + // CONS_Printf("thiscam camheight %d\n", thiscam->chaseheight/FRACUNIT); + if (loop_in < loop->zoom_in_speed) { fixed_t f = loop_out < loop->zoom_out_speed