Skip to content

Commit

Permalink
So frame interpolation is incoming.
Browse files Browse the repository at this point in the history
This is a huge change, but it sets up all the interpolation things and handles view and things.

Sectors/segs are done, except I introduced a clipping bug. That will come in very soon.

Line scrollers are simple from here.
  • Loading branch information
GooberMan committed Jul 20, 2022
1 parent a6f786a commit 0102007
Show file tree
Hide file tree
Showing 18 changed files with 401 additions and 102 deletions.
9 changes: 7 additions & 2 deletions src/doom/d_main.c
Expand Up @@ -215,8 +215,8 @@ boolean D_Display (void)
boolean redrawsbar;
patch_t* pausepatch;

boolean ispaused = paused
|| ( gamestate == GS_LEVEL && !demoplayback && dashboardactive && dashboardpausesplaysim && ( solonetgame || !netgame ) );
boolean ispaused = renderpaused = ( paused
|| ( gamestate == GS_LEVEL && !demoplayback && dashboardactive && dashboardpausesplaysim && ( solonetgame || !netgame ) ) );

M_PROFILE_PUSH( __FUNCTION__, __FILE__, __LINE__ );

Expand Down Expand Up @@ -492,6 +492,8 @@ boolean D_GrabMouseCallback(void)
// D_RunFrame
//

uint64_t frametime = 0;

void D_RunFrame()
{
uint64_t nowtime;
Expand All @@ -504,6 +506,7 @@ void D_RunFrame()

boolean dofinishupdate = true;

uint64_t start = I_GetTimeUS();
M_ProfileNewFrame();
M_PROFILE_PUSH( __FUNCTION__, __FILE__, __LINE__ );

Expand Down Expand Up @@ -557,6 +560,8 @@ void D_RunFrame()
{
I_FinishUpdate( NULL );
}

frametime = I_GetTimeUS() - start;
}

//
Expand Down
3 changes: 3 additions & 0 deletions src/doom/d_player.h
Expand Up @@ -92,6 +92,9 @@ typedef struct player_s
// bounded/scaled total momentum.
fixed_t bob;

rend_fixed_t prevviewz;
rend_fixed_t currviewz;

// This is only used between levels,
// mo->health is used during levels.
int health;
Expand Down
1 change: 1 addition & 0 deletions src/doom/doomstat.h
Expand Up @@ -150,6 +150,7 @@ extern int32_t dashboardactive; // R&R Dashboard, powered by Dear ImGui
extern int32_t dashboardremappingkey;
extern int32_t dashboardpausesplaysim;
extern boolean paused; // Game Pause?
extern boolean renderpaused;


extern boolean viewactive;
Expand Down
7 changes: 4 additions & 3 deletions src/doom/g_game.c
Expand Up @@ -109,7 +109,8 @@ int32_t gameflags;

int timelimit;

boolean paused;
boolean paused;
boolean renderpaused;
boolean sendpause; // send a pause event next tic
boolean sendsave; // send a save event next tic
boolean usergame; // ok to save / end game
Expand Down Expand Up @@ -859,8 +860,8 @@ boolean G_Responder (event_t* ev)

case ev_mouse:
SetMouseButtons(ev->data1);
mousex = ev->data2*(mouseSensitivity+5)/10;
mousey = ev->data3*(mouseSensitivity+5)/10;
mousex += ev->data2*(mouseSensitivity+5)/10;
mousey += ev->data3*(mouseSensitivity+5)/10;
return true; // eat events

case ev_joystick:
Expand Down
1 change: 1 addition & 0 deletions src/doom/info.h
Expand Up @@ -26,6 +26,7 @@

typedef enum
{
SPR_INVALID = -1,
SPR_TROO,
SPR_SHTG,
SPR_PUNG,
Expand Down
12 changes: 12 additions & 0 deletions src/doom/m_menu.c
Expand Up @@ -2902,6 +2902,7 @@ void M_DashboardOptionsWindow( const char* itemname, void* data )
extern int32_t show_diskicon;
extern int32_t grabmouse;
extern int32_t novert;
extern int32_t enable_frame_interpolation;

controlsection_t* currsection;

Expand All @@ -2925,6 +2926,17 @@ void M_DashboardOptionsWindow( const char* itemname, void* data )
igColumns( 2, "", false );
igSetColumnWidth( 0, columwidth );

igText( "Frame interpolation" );
igNextColumn();
WorkingBool = !!enable_frame_interpolation;
igPushIDPtr( &enable_frame_interpolation );
if( igCheckbox( "", &WorkingBool ) )
{
enable_frame_interpolation = (int32_t)WorkingBool;
}
igPopID();
igNextColumn();

igText( "Show text startup" );
igNextColumn();
WorkingBool = !!show_text_startup;
Expand Down
22 changes: 18 additions & 4 deletions src/doom/p_mobj.c
Expand Up @@ -558,11 +558,23 @@ P_SpawnMobj
mobj->ceilingz = mobj->subsector->sector->ceilingheight;

if (z == ONFLOORZ)
mobj->z = mobj->floorz;
mobj->z = mobj->floorz;
else if (z == ONCEILINGZ)
mobj->z = mobj->ceilingz - mobj->info->height;
mobj->z = mobj->ceilingz - mobj->info->height;
else
mobj->z = z;
mobj->z = z;

mobj->curr.x = FixedToRendFixed( mobj->x );
mobj->curr.y = FixedToRendFixed( mobj->y );
mobj->curr.z = FixedToRendFixed( mobj->z );
mobj->curr.angle = mobj->angle;
mobj->curr.frame = -1;
mobj->curr.sprite = SPR_INVALID;

mobj->prev = mobj->curr;

mobj->curr.frame = mobj->frame;
mobj->curr.sprite = mobj->sprite;

mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker;

Expand Down Expand Up @@ -604,7 +616,7 @@ void P_RemoveMobj (mobj_t* mobj)
S_StopSound (mobj);

// free block
P_RemoveThinker ((thinker_t*)mobj);
P_RemoveThinker (&mobj->thinker);
}


Expand Down Expand Up @@ -731,6 +743,8 @@ void P_SpawnPlayer (mapthing_t* mthing)
p->extralight = 0;
p->fixedcolormap = 0;
p->viewheight = VIEWHEIGHT;
p->viewz = mobj->z + p->viewheight;
p->prevviewz = p->currviewz = FixedToRendFixed( p->viewz );

// setup gun psprite
P_SetupPsprites (p);
Expand Down
5 changes: 4 additions & 1 deletion src/doom/p_mobj.h
Expand Up @@ -201,7 +201,7 @@ typedef struct mobjinstance_s
rend_fixed_t x;
rend_fixed_t y;
rend_fixed_t z;
rend_fixed_t angle;
angle_t angle;
spritenum_t sprite;
int32_t frame;
} mobjinstance_t;
Expand All @@ -227,6 +227,9 @@ typedef struct mobj_s
spritenum_t sprite; // used to find patch_t and flip value
int frame; // might be ORed with FF_FULLBRIGHT

mobjinstance_t curr;
mobjinstance_t prev;

// Interaction info, by BLOCKMAP.
// Links in blocks (if needed).
struct mobj_s* bnext;
Expand Down
7 changes: 7 additions & 0 deletions src/doom/p_saveg.c
Expand Up @@ -308,12 +308,15 @@ static void saveg_read_mobj_t(mobj_t *str)

// fixed_t x;
str->x = saveg_read32();
str->prev.x = str->curr.x = FixedToRendFixed( str->x );

// fixed_t y;
str->y = saveg_read32();
str->prev.y = str->y = FixedToRendFixed( str->y );

// fixed_t z;
str->z = saveg_read32();
str->prev.z = str->z = FixedToRendFixed( str->z );

// struct mobj_s* snext;
str->snext = saveg_readp();
Expand All @@ -323,12 +326,15 @@ static void saveg_read_mobj_t(mobj_t *str)

// angle_t angle;
str->angle = saveg_read32();
str->prev.angle = str->curr.angle = str->angle;

// spritenum_t sprite;
str->sprite = saveg_read_enum();
str->prev.sprite = str->curr.sprite = str->sprite;

// int frame;
str->frame = saveg_read32();
str->prev.frame = str->curr.frame = str->frame;

// struct mobj_s* bnext;
str->bnext = saveg_readp();
Expand Down Expand Up @@ -654,6 +660,7 @@ static void saveg_read_player_t(player_t *str)

// fixed_t viewz;
str->viewz = saveg_read32();
str->prevviewz = str->currviewz = FixedToRendFixed( str->viewz );

// fixed_t viewheight;
str->viewheight = saveg_read32();
Expand Down

0 comments on commit 0102007

Please sign in to comment.