- interpolations transitioned.

This commit is contained in:
Christoph Oelckers 2020-06-30 11:55:01 +02:00
parent e92ca71fe5
commit fc11447e59
9 changed files with 57 additions and 215 deletions

View file

@ -19,6 +19,7 @@ set( PCH_SOURCES
src/hudweapon_d.cpp
src/hudweapon_r.cpp
src/input.cpp
src/interpolate.cpp
src/player.cpp
src/player_d.cpp
src/player_r.cpp
@ -40,7 +41,6 @@ set( PCH_SOURCES
src/zz_demo.cpp
src/zz_game.cpp
src/zz_global.cpp
src/zz_interpolate.cpp
src/zz_namesdyn.cpp
src/zz_net.cpp
src/zz_osdcmds.cpp

View file

@ -321,33 +321,14 @@ enum
extern int32_t numinterpolations;
extern int32_t* curipos[MAXINTERPOLATIONS];
extern int32_t bakipos[MAXINTERPOLATIONS];
void G_UpdateInterpolations(void);
void G_RestoreInterpolations(void);
int G_SetInterpolation(int32_t* const posptr);
void G_StopInterpolation(const int32_t* const posptr);
void G_DoInterpolations(int smoothRatio);
// old names as porting help.
inline void updateinterpolations()
{
G_UpdateInterpolations();
}
inline void restoreinterpolations()
{
G_RestoreInterpolations();
}
inline int setinterpolation(int32_t* posptr)
{
return G_SetInterpolation(posptr);
}
inline void stopinterpolation(int32_t* posptr)
{
G_SetInterpolation(posptr);
}
inline void dointerpolations(int smoothratio)
{
G_DoInterpolations(smoothratio);
}
void updateinterpolations();
void restoreinterpolations();
void setinterpolation(int* posptr);
void stopinterpolation(int* posptr);
void dointerpolations(int smoothratio);
// Hack struct to allow old code to access the EDuke-style player data without changing it.

View file

@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
aint with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Original Source: 1996 - Todd Replogle
@ -32,19 +32,32 @@ source as it is released.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "global.h"
BEGIN_DUKE_NS
#define MAXINTERPOLATIONS MAXSPRITES
int32_t numinterpolations;
int32_t g_interpolationLock;
int32_t oldipos[MAXINTERPOLATIONS];
int32_t *curipos[MAXINTERPOLATIONS];
int32_t bakipos[MAXINTERPOLATIONS];
void updateinterpolations() //Stick at beginning of domovethings
{
long i;
int i;
for(i=numinterpolations-1;i>=0;i--) oldipos[i] = *curipos[i];
}
void setinterpolation(long *posptr)
void setinterpolation(int *posptr)
{
long i;
int i;
if (numinterpolations >= MAXINTERPOLATIONS) return;
for(i=numinterpolations-1;i>=0;i--)
@ -54,11 +67,11 @@ void setinterpolation(long *posptr)
numinterpolations++;
}
void stopinterpolation(long *posptr)
void stopinterpolation(int *posptr)
{
long i;
int i;
for(i=numinterpolations-1;i>=startofdynamicinterpolations;i--)
for(i=numinterpolations-1;i>=0;i--)
if (curipos[i] == posptr)
{
numinterpolations--;
@ -68,9 +81,9 @@ void stopinterpolation(long *posptr)
}
}
void dointerpolations(long smoothratio) //Stick at beginning of drawscreen
void dointerpolations(int smoothratio) //Stick at beginning of drawscreen
{
long i, j, odelta, ndelta;
int i, j, odelta, ndelta;
ndelta = 0; j = 0;
for(i=numinterpolations-1;i>=0;i--)
@ -84,18 +97,19 @@ void dointerpolations(long smoothratio) //Stick at beginning of drawscreen
void restoreinterpolations() //Stick at end of drawscreen
{
long i;
int i;
for(i=numinterpolations-1;i>=0;i--) *curipos[i] = bakipos[i];
}
void setsectinterpolate(short i)
void setsectinterpolate(int i)
{
long j, k, startwall,endwall;
int j, k, startwall,endwall;
auto sect = &sector[sprite[i].sectnum];
startwall = sector[SECT].wallptr;
endwall = startwall+sector[SECT].wallnum;
startwall = sect->wallptr;
endwall = startwall+sect->wallnum;
for(j=startwall;j<endwall;j++)
{
@ -116,9 +130,10 @@ void setsectinterpolate(short i)
void clearsectinterpolate(short i)
{
short j,startwall,endwall;
auto sect = &sector[sprite[i].sectnum];
startwall = sector[SECT].wallptr;
endwall = startwall+sector[SECT].wallnum;
startwall = sect->wallptr;
endwall = startwall + sect->wallnum;
for(j=startwall;j<endwall;j++)
{
stopinterpolation(&wall[j].x);
@ -131,3 +146,5 @@ void clearsectinterpolate(short i)
}
}
END_DUKE_NS

View file

@ -31,20 +31,6 @@ BEGIN_DUKE_NS
#define DELETE_SPRITE_AND_CONTINUE(KX) do { A_DeleteSprite(KX); goto next_sprite; } while (0)
void G_ClearCameraView(DukePlayer_t *ps)
{
ps->newowner = -1;
ps->pos = ps->opos;
ps->q16ang = ps->oq16ang;
updatesector(ps->pos.x, ps->pos.y, &ps->cursectnum);
P_UpdateScreenPal(ps);
for (bssize_t SPRITES_OF(STAT_ACTOR, k))
if (sprite[k].picnum==TILE_CAMERA1)
sprite[k].yvel = 0;
}
// deletesprite() game wrapper
void A_DeleteSprite(int spriteNum)
{
@ -57,36 +43,6 @@ void A_DeleteSprite(int spriteNum)
void insertspriteq(int i);
static int32_t G_ToggleWallInterpolation(int32_t wallNum, int32_t setInterpolation)
{
if (setInterpolation)
{
return G_SetInterpolation(&wall[wallNum].x) || G_SetInterpolation(&wall[wallNum].y);
}
else
{
G_StopInterpolation(&wall[wallNum].x);
G_StopInterpolation(&wall[wallNum].y);
return 0;
}
}
void Sect_ToggleInterpolation(int sectNum, int setInterpolation)
{
for (bssize_t j = sector[sectNum].wallptr, endwall = sector[sectNum].wallptr + sector[sectNum].wallnum; j < endwall; j++)
{
G_ToggleWallInterpolation(j, setInterpolation);
int const nextWall = wall[j].nextwall;
if (nextWall >= 0)
{
G_ToggleWallInterpolation(nextWall, setInterpolation);
G_ToggleWallInterpolation(wall[nextWall].point2, setInterpolation);
}
}
}
int g_canSeePlayer = 0;
int G_WakeUp(spritetype *const pSprite, int const playerNum)

View file

@ -247,20 +247,11 @@ int LocateTheLocator(int const tag, int const sectNum);
int A_IncurDamage(int spriteNum);
void A_DeleteSprite(int spriteNum);
int G_SetInterpolation(int32_t *posptr);
void G_ClearCameraView(DukePlayer_t *ps);
void clearcamera(player_struct* ps);
void G_DoInterpolations(int smoothRatio);
void G_RefreshLights(void);
void G_StopInterpolation(const int32_t *posptr);
// PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly
// Note: The entire interpolation system needs to be a lot smarter than what's backing these functions.
void Sect_ToggleInterpolation(int sectnum, int setInterpolation);
static FORCE_INLINE void Sect_ClearInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 0); }
static FORCE_INLINE void Sect_SetInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 1); }
static FORCE_INLINE void clearsectinterpolate(int sprnum) { Sect_ToggleInterpolation(sprite[sprnum].sectnum, 0); }
static FORCE_INLINE void setsectinterpolate(int sprnum) { Sect_ToggleInterpolation(sprite[sprnum].sectnum, 1); }
void clearsectinterpolate(int sprnum);
void setsectinterpolate(int sprnum);
#if KRANDDEBUG
# define ACTOR_INLINE __fastcall

View file

@ -206,12 +206,8 @@ void G_GameExit(const char *msg)
I_Error("%s", msg);
}
}
if (!RR)
{
endoomName = VOLUMEALL ? "duke3d.bin" : "dukesw.bin";
endoomName = RR? "redneck.bin" : VOLUMEALL ? "duke3d.bin" : "dukesw.bin";
ST_Endoom();
}
else throw CExitEvent(0);
}
@ -688,7 +684,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
CAMERA(sect) = pPlayer->cursectnum;
G_DoInterpolations(smoothRatio);
dointerpolations(smoothRatio);
G_AnimateCamSprite(smoothRatio);
if (ud.camerasprite >= 0)
@ -1077,7 +1073,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
#endif
}
G_RestoreInterpolations();
restoreinterpolations();
if (!RRRA || !fogactive)
{
@ -1182,9 +1178,9 @@ static void Yax_SetBunchInterpolation(int32_t sectnum, int32_t cf)
return;
for (SECTORS_OF_BUNCH(bunchnum, YAX_CEILING, i))
G_SetInterpolation(&sector[i].ceilingz);
setinterpolation(&sector[i].ceilingz);
for (SECTORS_OF_BUNCH(bunchnum, YAX_FLOOR, i))
G_SetInterpolation(&sector[i].floorz);
setinterpolation(&sector[i].floorz);
}
#else
# define Yax_SetBunchInterpolation(sectnum, cf)
@ -2369,7 +2365,7 @@ int G_DoMoveThings(void)
movefifoplc++;
G_UpdateInterpolations();
updateinterpolations();
g_moveThingsCount++;

View file

@ -1,99 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "global.h"
BEGIN_DUKE_NS
// No need to revert this to the original state - to be robust this needs to be redone entirely, so this code will disappear anyway.
#define MAXINTERPOLATIONS MAXSPRITES
int32_t numinterpolations;
int32_t g_interpolationLock;
int32_t oldipos[MAXINTERPOLATIONS];
int32_t *curipos[MAXINTERPOLATIONS];
int32_t bakipos[MAXINTERPOLATIONS];
int G_SetInterpolation(int32_t *const posptr)
{
if (numinterpolations >= MAXINTERPOLATIONS)
return 1;
for (bssize_t i = 0; i < numinterpolations; ++i)
if (curipos[i] == posptr)
return 0;
curipos[numinterpolations] = posptr;
oldipos[numinterpolations] = *posptr;
numinterpolations++;
return 0;
}
void G_StopInterpolation(const int32_t * const posptr)
{
for (bssize_t i = 0; i < numinterpolations; ++i)
if (curipos[i] == posptr)
{
numinterpolations--;
oldipos[i] = oldipos[numinterpolations];
bakipos[i] = bakipos[numinterpolations];
curipos[i] = curipos[numinterpolations];
}
}
void G_DoInterpolations(int smoothRatio)
{
if (g_interpolationLock++)
return;
int32_t ndelta = 0;
for (bssize_t i = 0, j = 0; i < numinterpolations; ++i)
{
int32_t const odelta = ndelta;
bakipos[i] = *curipos[i];
ndelta = (*curipos[i]) - oldipos[i];
if (odelta != ndelta)
j = mulscale16(ndelta, smoothRatio);
*curipos[i] = oldipos[i] + j;
}
}
void G_UpdateInterpolations(void) //Stick at beginning of G_DoMoveThings
{
for (bssize_t i=numinterpolations-1; i>=0; i--) oldipos[i] = *curipos[i];
}
void G_RestoreInterpolations(void) //Stick at end of drawscreen
{
int32_t i=numinterpolations-1;
if (--g_interpolationLock)
return;
for (; i>=0; i--) *curipos[i] = bakipos[i];
}
END_DUKE_NS

View file

@ -79,15 +79,15 @@ void G_ResetInterpolations(void)
switch (sprite[k].lotag)
{
case SE_31_FLOOR_RISE_FALL:
G_SetInterpolation(&sector[sprite[k].sectnum].floorz);
setinterpolation(&sector[sprite[k].sectnum].floorz);
break;
case SE_32_CEILING_RISE_FALL:
G_SetInterpolation(&sector[sprite[k].sectnum].ceilingz);
setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case SE_17_WARP_ELEVATOR:
case SE_25_PISTON:
G_SetInterpolation(&sector[sprite[k].sectnum].floorz);
G_SetInterpolation(&sector[sprite[k].sectnum].ceilingz);
setinterpolation(&sector[sprite[k].sectnum].floorz);
setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case SE_0_ROTATING_SECTOR:
case SE_5_BOSS:
@ -98,7 +98,7 @@ void G_ResetInterpolations(void)
case SE_16_REACTOR:
case SE_26:
case SE_30_TWO_WAY_TRAIN:
Sect_SetInterpolation(sprite[k].sectnum);
setsectinterpolate(k);
break;
}
@ -107,7 +107,7 @@ void G_ResetInterpolations(void)
for (i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i];
for (i = g_animateCnt-1; i>=0; i--)
G_SetInterpolation(g_animatePtr[i]);
setinterpolation(g_animatePtr[i]);
}

View file

@ -751,7 +751,7 @@ void G_DisplayRest(int32_t smoothratio)
{
// smoothratio = min(max(smoothratio,0),65536);
smoothratio = calc_smoothratio(totalclock, ototalclock);
G_DoInterpolations(smoothratio);
dointerpolations(smoothratio);
if (ud.scrollmode == 0)
{
@ -798,7 +798,7 @@ void G_DisplayRest(int32_t smoothratio)
}
G_DrawOverheadMap(cposx, cposy, pp->zoom, cang);
G_RestoreInterpolations();
restoreinterpolations();
if (/*textret == 0 &&*/ ud.overhead_on == 2)
{