SW: Interpolate sector objects in non-demo, single player games.

Let's see if this is breaking anything.

# Conflicts:
#	source/sw/src/draw.cpp
#	source/sw/src/game.cpp
#	source/sw/src/game.h
#	source/sw/src/interp.cpp
#	source/sw/src/track.cpp
This commit is contained in:
NY00123 2020-04-14 18:17:08 +03:00 committed by Christoph Oelckers
parent e80888523e
commit 996ab77cf4
7 changed files with 59 additions and 4 deletions

View file

@ -2009,7 +2009,7 @@ drawscreen(PLAYERp pp)
tx = camerapp->oposx + mulscale16(camerapp->posx - camerapp->oposx, smoothratio);
ty = camerapp->oposy + mulscale16(camerapp->posy - camerapp->oposy, smoothratio);
tz = camerapp->oposz + mulscale16(camerapp->posz - camerapp->oposz, smoothratio);
if (PEDANTIC_MODE ||
if (PEDANTIC_MODE || pp->sop_control ||
pp == Player+myconnectindex && TEST(pp->Flags, PF_DEAD))
{
tq16ang = camerapp->q16ang;
@ -2053,7 +2053,7 @@ drawscreen(PLAYERp pp)
if (pp->sop_riding || pp->sop_control)
{
if (pp->sop_control)
if (pp->sop_control && !InterpolateSectObj)
{
tx = pp->posx;
ty = pp->posy;

View file

@ -186,6 +186,7 @@ SWBOOL NoDemoStartup = FALSE;
SWBOOL FirstTimeIntoGame;
SWBOOL BorderAdjust = FALSE;
SWBOOL InterpolateSectObj;
SWBOOL LocationInfo = 0;
void drawoverheadmap(int cposx, int cposy, int czoom, short cang);
int DispFrameRate = FALSE;
@ -952,6 +953,7 @@ void InitLevelGlobals(void)
sumowasseen = FALSE;
zillawasseen = FALSE;
memset(BossSpriteNum,-1,sizeof(BossSpriteNum));
InterpolateSectObj = !CommEnabled && !PedanticMode;
}
void InitLevelGlobals2(void)

View file

@ -874,6 +874,8 @@ extern int PlayerYellVocs[MAX_YELLSOUNDS];
void BossHealthMeter(void);
extern SWBOOL InterpolateSectObj;
// Global variables used for modifying variouse things from the Console
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -110,4 +110,12 @@ void restoreinterpolations(void) // Stick at end of drawscreen
for (i = numinterpolations - 1; i >= 0; i--)
*curipos[i] = bakipos[i];
}
void togglespriteinterpolation(spritetype *sp, int set)
{
auto func = set ? setinterpolation : stopinterpolation;
func(&sp->x);
func(&sp->y);
func(&sp->z);
}
END_SW_NS

View file

@ -49,5 +49,10 @@ void updateinterpolations(void);
void dointerpolations(int smoothratio);
void restoreinterpolations(void);
void togglespriteinterpolation(spritetype *sp, int set);
static void FORCE_INLINE setspriteinterpolation(spritetype *sp) { togglespriteinterpolation(sp, 1); }
static void FORCE_INLINE stopspriteinterpolation(spritetype *sp) { togglespriteinterpolation(sp, 0); }
#endif
END_SW_NS

View file

@ -34,6 +34,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "ai.h"
#include "player.h"
#include "game.h"
#include "interp.h"
#include "network.h"
#include "sprite.h"
#include "track.h"
@ -848,6 +849,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
//
// Make sure every sector object has an outer loop tagged - important
// Further setup interpolation
//
FoundOutsideLoop = FALSE;
@ -860,6 +862,21 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
// move all walls in sectors
for (k = startwall; k <= endwall; k++)
{
uint16_t const nextwall = wall[k].nextwall;
// setup interpolation
if (InterpolateSectObj)
{
setinterpolation(&wall[k].x);
setinterpolation(&wall[k].y);
if (nextwall < MAXWALLS)
{
setinterpolation(&wall[wall[nextwall].point2].x);
setinterpolation(&wall[wall[nextwall].point2].y);
}
}
// for morph point - tornado style
if (wall[k].lotag == TAG_WALL_ALIGN_SLOPE_TO_POINT)
sop->morph_wall_point = k;
@ -869,10 +886,16 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
// each wall has this set - for collision detection
SET(wall[k].extra, WALLFX_SECTOR_OBJECT|WALLFX_DONT_STICK);
uint16_t const nextwall = wall[k].nextwall;
if (nextwall < MAXWALLS)
SET(wall[nextwall].extra, WALLFX_SECTOR_OBJECT|WALLFX_DONT_STICK);
}
// interpolate floor and ceiling
if (InterpolateSectObj && (k != startwall))
{
setinterpolation(&(*sectp)->ceilingz);
setinterpolation(&(*sectp)->floorz);
}
}
if (!FoundOutsideLoop)
@ -972,6 +995,8 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
ASSERT(sn < SIZ(sop->sp_num) - 1);
sop->sp_num[sn] = sp_num;
if (InterpolateSectObj)
setspriteinterpolation(sp);
if (!TEST(sop->flags, SOBJ_SPRITE_OBJ))
@ -1630,8 +1655,11 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
pp->posx += BOUND_4PIX(nx);
pp->posy += BOUND_4PIX(ny);
if (!InterpolateSectObj)
{
pp->oposx = pp->posx;
pp->oposy = pp->posy;
}
if (TEST(sop->flags, SOBJ_DONT_ROTATE))
{
@ -1676,7 +1704,9 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
// New angle is formed by taking last known angle and
// adjusting by the delta angle
pp->oq16ang = pp->q16ang = fix16_sadd(pp->RevolveAng, pp->RevolveDeltaAng) & 0x7FFFFFF;
pp->q16ang = fix16_sadd(pp->RevolveAng, pp->RevolveDeltaAng) & 0x7FFFFFF;
if (!InterpolateSectObj)
pp->oq16ang = pp->q16ang;
UpdatePlayerSprite(pp);
}
@ -1929,6 +1959,7 @@ PlayerPart:
pp->SpriteP->z = pp->loz;
}
}
if (!InterpolateSectObj)
pp->oposz = pp->posz;
}
else
@ -2044,6 +2075,8 @@ void KillSectorObjectSprites(SECTOR_OBJECTp sop)
if (sp->picnum == ST1 && sp->hitag == SPAWN_SPOT)
continue;
if (InterpolateSectObj)
stopspriteinterpolation(sp);
KillSprite(sop->sp_num[i]);
}

View file

@ -31,6 +31,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "names2.h"
#include "panel.h"
#include "game.h"
#include "interp.h"
#include "tags.h"
#include "common_game.h"
#include "break.h"
@ -11392,6 +11393,8 @@ AddSpriteToSectorObject(short SpriteNum, SECTOR_OBJECTp sop)
ASSERT(sn < SIZ(sop->sp_num) - 1);
sop->sp_num[sn] = SpriteNum;
if (InterpolateSectObj)
setspriteinterpolation(sp);
SET(u->Flags, SPR_ON_SO_SECTOR|SPR_SO_ATTACHED);
@ -11458,6 +11461,8 @@ SpawnBigGunFlames(int16_t Weapon, int16_t Operator, SECTOR_OBJECTp sop)
ASSERT(sn < SIZ(sop->sp_num) - 1);
sop->sp_num[sn] = explosion;
if (InterpolateSectObj)
setspriteinterpolation(exp);
// Place sprite exactly where shoot point is
//exp->x = eu->ox = sop->xmid - u->sx;