- migrated Duke's interpolations to the common system and added handling for texture scrollers.

This commit is contained in:
Christoph Oelckers 2020-11-26 16:03:40 +01:00
parent 87111a2fbc
commit b9477f147e
10 changed files with 49 additions and 102 deletions

View file

@ -241,11 +241,6 @@ bool movementBlocked(int snum);
void loadcons();
void recordoldspritepos();
void updateinterpolations();
void restoreinterpolations();
void setinterpolation(int* posptr);
void stopinterpolation(int* posptr);
void dointerpolations(int smoothratio);
int* animateptr(int i);
void backuppos(player_struct* p, bool noclipping = false);

View file

@ -44,6 +44,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "glbackend/glbackend.h"
#include "gamestate.h"
#include "dukeactor.h"
#include "interpolate.h"
BEGIN_DUKE_NS
@ -267,7 +268,7 @@ void drawoverlays(double smoothratio)
if (automapMode != am_off)
{
dointerpolations(smoothratio);
DoInterpolations(smoothratio / 65536.);
if (pp->newOwner == nullptr && playrunning())
{
@ -291,7 +292,7 @@ void drawoverlays(double smoothratio)
cang = pp->angle.oang.asbuild();
}
DrawOverheadMap(cposx, cposy, cang);
restoreinterpolations();
RestoreInterpolations();
}
}

View file

@ -34,6 +34,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "m_argv.h"
#include "mapinfo.h"
#include "texturemanager.h"
#include "interpolate.h"
#include "glbackend/glbackend.h"
BEGIN_DUKE_NS
@ -60,7 +61,7 @@ void GameInterface::Ticker()
show_shareware--;
}
updateinterpolations();
UpdateInterpolations();
if (playrunning())
{

View file

@ -13,12 +13,6 @@
BEGIN_DUKE_NS
extern user_defs ud;
// Interpolation code is the same in all games with slightly different naming - this needs to be unified and cleaned up.
// Interpolations are reconstructed on load and do not need to be saved.
enum { MAXINTERPOLATIONS = MAXSPRITES };
extern int numinterpolations;
extern int* curipos[MAXINTERPOLATIONS];
extern int bakipos[MAXINTERPOLATIONS];
// Variables that do not need to be saved.
extern int respawnactortime;

View file

@ -34,72 +34,10 @@ source as it is released.
#include "ns.h" // Must come before everything else!
#include "global.h"
#include "interpolate.h"
BEGIN_DUKE_NS
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
{
int i;
for(i=numinterpolations-1;i>=0;i--) oldipos[i] = *curipos[i];
}
void setinterpolation(int *posptr)
{
int i;
if (numinterpolations >= MAXINTERPOLATIONS) return;
for(i=numinterpolations-1;i>=0;i--)
if (curipos[i] == posptr) return;
curipos[numinterpolations] = posptr;
oldipos[numinterpolations] = *posptr;
numinterpolations++;
}
void stopinterpolation(int *posptr)
{
int i;
for(i=numinterpolations-1;i>=0;i--)
if (curipos[i] == posptr)
{
numinterpolations--;
oldipos[i] = oldipos[numinterpolations];
bakipos[i] = bakipos[numinterpolations];
curipos[i] = curipos[numinterpolations];
}
}
void dointerpolations(int smoothratio) //Stick at beginning of drawscreen
{
int i, j, odelta, ndelta;
ndelta = 0; j = 0;
for(i=numinterpolations-1;i>=0;i--)
{
bakipos[i] = *curipos[i];
odelta = ndelta; ndelta = (*curipos[i])-oldipos[i];
if (odelta != ndelta) j = mulscale16(ndelta,smoothratio);
*curipos[i] = oldipos[i]+j;
}
}
void restoreinterpolations() //Stick at end of drawscreen
{
int i;
for(i=numinterpolations-1;i>=0;i--) *curipos[i] = bakipos[i];
}
void setsectinterpolate(int sectnum)
{
int j, k, startwall,endwall;
@ -110,16 +48,16 @@ void setsectinterpolate(int sectnum)
for(j=startwall;j<endwall;j++)
{
setinterpolation(&wall[j].x);
setinterpolation(&wall[j].y);
StartInterpolation(j, Interp_Wall_X);
StartInterpolation(j, Interp_Wall_Y);
k = wall[j].nextwall;
if(k >= 0)
{
setinterpolation(&wall[k].x);
setinterpolation(&wall[k].y);
StartInterpolation(k, Interp_Wall_X);
StartInterpolation(k, Interp_Wall_Y);
k = wall[k].point2;
setinterpolation(&wall[k].x);
setinterpolation(&wall[k].y);
StartInterpolation(k, Interp_Wall_X);
StartInterpolation(k, Interp_Wall_Y);
}
}
}
@ -133,12 +71,12 @@ void clearsectinterpolate(int sectnum)
endwall = startwall + sect->wallnum;
for(j=startwall;j<endwall;j++)
{
stopinterpolation(&wall[j].x);
stopinterpolation(&wall[j].y);
StopInterpolation(j, Interp_Wall_X);
StopInterpolation(j, Interp_Wall_Y);
if(wall[j].nextwall >= 0)
{
stopinterpolation(&wall[wall[j].nextwall].x);
stopinterpolation(&wall[wall[j].nextwall].y);
StopInterpolation(wall[j].nextwall, Interp_Wall_X);
StopInterpolation(wall[j].nextwall, Interp_Wall_Y);
}
}
}

View file

@ -35,6 +35,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "sbar.h"
#include "automap.h"
#include "dukeactor.h"
#include "interpolate.h"
BEGIN_DUKE_NS
@ -426,9 +427,6 @@ void resetprestat(int snum,int g)
BellTime = 0;
BellSprite = nullptr;
numinterpolations = 0;
//startofdynamicinterpolations = 0;
if(p->curr_weapon == HANDREMOTE_WEAPON)
{
p->ammo_amount[HANDBOMB_WEAPON]++;
@ -965,11 +963,18 @@ void enterlevel(MapRecord *mi, int gamemode)
global_random = 0;
ud.last_level = currentLevel->levelNumber;
for (int i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i];
ps[myconnectindex].over_shoulder_on = 0;
clearfrags();
resettimevars(); // Here we go
setLevelStarted(mi);
if (isRRRA() && ps[screenpeek].sea_sick_stat == 1)
{
for (int i = 0; i < MAXWALLS; i++)
{
if (wall[i].picnum == 7873 || wall[i].picnum == 7870)
StartInterpolation(i, Interp_Wall_PanX);
}
}
}
//---------------------------------------------------------------------------

View file

@ -32,6 +32,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "prediction.h"
#include "automap.h"
#include "dukeactor.h"
#include "interpolate.h"
BEGIN_DUKE_NS
@ -502,7 +503,7 @@ void displayrooms(int snum, double smoothratio)
if (sect < 0 || sect >= MAXSECTORS) return;
GLInterface.SetMapFog(fogactive != 0);
dointerpolations(smoothratio);
DoInterpolations(smoothratio / 65536.);
setgamepalette(BASEPAL);
animatecamsprite(smoothratio);
@ -647,7 +648,7 @@ void displayrooms(int snum, double smoothratio)
}
}
//GLInterface.SetMapFog(false);
restoreinterpolations();
RestoreInterpolations();
if (!isRRRA() || !fogactive)
{

View file

@ -37,12 +37,15 @@ source as it is released.
#include "global.h"
#include "sounds.h"
#include "dukeactor.h"
#include "interpolate.h"
using std::min;
using std::max;
// PRIMITIVE
BEGIN_DUKE_NS
static int interptype[] = { Interp_Sect_Floorz, Interp_Sect_Ceilingz, Interp_Wall_X, Interp_Wall_Y };
//---------------------------------------------------------------------------
//
//
@ -318,7 +321,7 @@ void doanimations(void)
if (a == animategoal[i])
{
stopinterpolation(animateptr(i));
StopInterpolation(animatetarget[i], interptype[animatetype[i]]);
animatecnt--;
animatetype[i] = animatetype[animatecnt];
@ -419,8 +422,7 @@ int setanimation(short animsect, int animtype, int animtarget, int thegoal, int
if (j == animatecnt) animatecnt++;
setinterpolation(animptr);
StartInterpolation(animatetarget[i], interptype[animatetype[i]]);
return(j);
}

View file

@ -38,6 +38,7 @@ source as it is released.
#include "sounds.h"
#include "automap.h"
#include "dukeactor.h"
#include "interpolate.h"
BEGIN_DUKE_NS
@ -694,7 +695,7 @@ void spawneffector(DDukeActor* actor)
t[4] = sector[sect].ceilingz;
sector[sect].ceilingz = sp->z;
setinterpolation(&sector[sect].ceilingz);
StartInterpolation(sect, Interp_Sect_Ceilingz);
break;
case SE_35:
sector[sect].ceilingz = sp->z;
@ -781,13 +782,20 @@ void spawneffector(DDukeActor* actor)
if (numplayers < 2)
{
setinterpolation(&sector[sect].floorz);
setinterpolation(&sector[sect].ceilingz);
StartInterpolation(sect, Interp_Sect_Floorz);
StartInterpolation(sect, Interp_Sect_Ceilingz);
}
break;
}
case 156:
if (!isRRRA()) break;
case 34:
StartInterpolation(sect, Interp_Sect_FloorPanX);
break;
case SE_24_CONVEYOR:
StartInterpolation(sect, Interp_Sect_FloorPanX);
sp->yvel <<= 1;
case SE_36_PROJ_SHOOTER:
break;
@ -833,6 +841,8 @@ void spawneffector(DDukeActor* actor)
}
t[2] = clostest;
StartInterpolation(sect, Interp_Sect_FloorPanX);
StartInterpolation(sect, Interp_Sect_FloorPanY);
break;
}
@ -871,7 +881,7 @@ void spawneffector(DDukeActor* actor)
for (s = startwall; s < endwall; s++)
if (wall[s].hitag == 0) wall[s].hitag = 9999;
setinterpolation(&sector[sect].floorz);
StartInterpolation(sect, Interp_Sect_Floorz);
break;
case SE_32_CEILING_RISE_FALL:
@ -885,7 +895,7 @@ void spawneffector(DDukeActor* actor)
for (s = startwall; s < endwall; s++)
if (wall[s].hitag == 0) wall[s].hitag = 9999;
setinterpolation(&sector[sect].ceilingz);
StartInterpolation(sect, Interp_Sect_Ceilingz);
break;

View file

@ -287,7 +287,7 @@ void InitLevelGlobals(void)
gNet.TimeLimitClock = gNet.TimeLimit;
serpwasseen = false;
serpwasseen = false;
sumowasseen = false;
zillawasseen = false;
memset(BossSpriteNum,-1,sizeof(BossSpriteNum));