mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-10 10:02:41 +00:00
V_AdjustXYWithSnap: refactor V_SLIDEIN, separate timer calculation, fix interpolation
- Move timer calculation to ST_CalculateFadeIn, cache in st_fadein - Fix interpolation by using rendertimefrac instead of renderdeltatics
This commit is contained in:
parent
eeda1b3ad5
commit
653db93022
3 changed files with 37 additions and 27 deletions
|
|
@ -117,6 +117,7 @@ void ST_Ticker(boolean run)
|
||||||
// 0 is default, any others are special palettes.
|
// 0 is default, any others are special palettes.
|
||||||
INT32 st_palette = 0;
|
INT32 st_palette = 0;
|
||||||
UINT32 st_translucency = 10;
|
UINT32 st_translucency = 10;
|
||||||
|
fixed_t st_fadein = 0;
|
||||||
|
|
||||||
void ST_doPaletteStuff(void)
|
void ST_doPaletteStuff(void)
|
||||||
{
|
{
|
||||||
|
|
@ -1424,6 +1425,35 @@ void ST_DrawServerSplash(boolean timelimited)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static fixed_t ST_CalculateFadeIn(player_t *player)
|
||||||
|
{
|
||||||
|
const tic_t length = TICRATE/4;
|
||||||
|
|
||||||
|
if (player->tally.hudSlide != 0)
|
||||||
|
{
|
||||||
|
tic_t timer = length - player->tally.hudSlide;
|
||||||
|
|
||||||
|
return ((timer * FRACUNIT) + (FRACUNIT - rendertimefrac)) / length;
|
||||||
|
}
|
||||||
|
|
||||||
|
tic_t timer = lt_exitticker;
|
||||||
|
|
||||||
|
if (K_CheckBossIntro() == true || G_IsTitleCardAvailable() == false)
|
||||||
|
{
|
||||||
|
if (leveltime <= 16)
|
||||||
|
timer = 0;
|
||||||
|
else
|
||||||
|
timer = leveltime-16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timer < length)
|
||||||
|
{
|
||||||
|
return ((timer * FRACUNIT) + rendertimefrac) / length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FRACUNIT;
|
||||||
|
}
|
||||||
|
|
||||||
void ST_Drawer(void)
|
void ST_Drawer(void)
|
||||||
{
|
{
|
||||||
boolean stagetitle = false; // Decide whether to draw the stage title or not
|
boolean stagetitle = false; // Decide whether to draw the stage title or not
|
||||||
|
|
@ -1479,6 +1509,7 @@ void ST_Drawer(void)
|
||||||
for (i = 0; i <= r_splitscreen; i++)
|
for (i = 0; i <= r_splitscreen; i++)
|
||||||
{
|
{
|
||||||
stplyr = &players[displayplayers[i]];
|
stplyr = &players[displayplayers[i]];
|
||||||
|
st_fadein = ST_FadeIn(stplyr);
|
||||||
R_SetViewContext(VIEWCONTEXT_PLAYER1 + i);
|
R_SetViewContext(VIEWCONTEXT_PLAYER1 + i);
|
||||||
R_InterpolateView(rendertimefrac); // to assist with object tracking
|
R_InterpolateView(rendertimefrac); // to assist with object tracking
|
||||||
ST_overlayDrawer();
|
ST_overlayDrawer();
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ boolean ST_SameTeam(player_t *a, player_t *b);
|
||||||
extern boolean st_overlay; // sb overlay on or off when fullscreen
|
extern boolean st_overlay; // sb overlay on or off when fullscreen
|
||||||
extern INT32 st_palette; // 0 is default, any others are special palettes.
|
extern INT32 st_palette; // 0 is default, any others are special palettes.
|
||||||
extern UINT32 st_translucency;
|
extern UINT32 st_translucency;
|
||||||
|
extern fixed_t st_fadein; // transitioning value per player, FRACUNIT = fully in view
|
||||||
|
|
||||||
extern lumpnum_t st_borderpatchnum;
|
extern lumpnum_t st_borderpatchnum;
|
||||||
// patches, also used in intermission
|
// patches, also used in intermission
|
||||||
|
|
|
||||||
|
|
@ -573,33 +573,14 @@ void V_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du
|
||||||
|
|
||||||
if ((options & V_SLIDEIN))
|
if ((options & V_SLIDEIN))
|
||||||
{
|
{
|
||||||
const tic_t length = TICRATE/4;
|
if (st_fadein < FRACUNIT)
|
||||||
tic_t timer = lt_exitticker;
|
|
||||||
|
|
||||||
if (K_CheckBossIntro() == true || G_IsTitleCardAvailable() == false)
|
|
||||||
{
|
|
||||||
if (leveltime <= 16)
|
|
||||||
timer = 0;
|
|
||||||
else
|
|
||||||
timer = leveltime-16;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stplyr->tally.hudSlide != 0)
|
|
||||||
{
|
|
||||||
timer = length - stplyr->tally.hudSlide;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timer < length)
|
|
||||||
{
|
{
|
||||||
if ((options & (V_SNAPTORIGHT|V_SNAPTOLEFT|V_SPLITSCREEN)) != 0)
|
if ((options & (V_SNAPTORIGHT|V_SNAPTOLEFT|V_SPLITSCREEN)) != 0)
|
||||||
{
|
{
|
||||||
boolean slidefromright = false;
|
boolean slidefromright = false;
|
||||||
|
|
||||||
const INT32 offsetAmount = (screenwidth * FRACUNIT/2) / length;
|
const fixed_t offsetAmount = (screenwidth * FRACUNIT/2);
|
||||||
fixed_t offset = (screenwidth * FRACUNIT/2) - (timer * offsetAmount);
|
INT32 offset = (offsetAmount - FixedMul(offsetAmount, st_fadein)) / FRACUNIT;
|
||||||
|
|
||||||
offset += FixedMul(offsetAmount, renderdeltatics);
|
|
||||||
offset /= FRACUNIT;
|
|
||||||
|
|
||||||
if (r_splitscreen > 1)
|
if (r_splitscreen > 1)
|
||||||
{
|
{
|
||||||
|
|
@ -621,11 +602,8 @@ void V_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const INT32 offsetAmount = (screenheight * FRACUNIT/2) / length;
|
const fixed_t offsetAmount = (screenheight * FRACUNIT/2);
|
||||||
fixed_t offset = (screenheight * FRACUNIT/2) - (timer * offsetAmount);
|
INT32 offset = (offsetAmount - FixedMul(offsetAmount, st_fadein)) / FRACUNIT;
|
||||||
|
|
||||||
offset += FixedMul(offsetAmount, renderdeltatics);
|
|
||||||
offset /= FRACUNIT;
|
|
||||||
|
|
||||||
if (options & V_SNAPTOBOTTOM)
|
if (options & V_SNAPTOBOTTOM)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue