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

Let's see if this is breaking anything.
This commit is contained in:
NY00123 2020-04-14 18:17:08 +03:00 committed by Christoph Oelckers
parent 25be14ccc0
commit 7749b0f7b9
7 changed files with 62 additions and 7 deletions

View file

@ -2013,7 +2013,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 (PedanticMode ||
if (PedanticMode || pp->sop_control ||
pp == Player+myconnectindex && TEST(pp->Flags, PF_DEAD))
{
tq16ang = camerapp->oq16ang + mulscale16(((camerapp->q16ang + fix16_from_int(1024) - camerapp->oq16ang) & 0x7FFFFFF) - fix16_from_int(1024), smoothratio);
@ -2056,7 +2056,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

@ -187,6 +187,7 @@ SWBOOL NoDemoStartup = FALSE;
SWBOOL FirstTimeIntoGame;
SWBOOL PedanticMode;
SWBOOL InterpolateSectObj;
SWBOOL BorderAdjust = FALSE;
SWBOOL LocationInfo = 0;
@ -958,6 +959,7 @@ void InitLevelGlobals(void)
memset(BossSpriteNum,-1,sizeof(BossSpriteNum));
PedanticMode = (DemoPlaying || DemoRecording || DemoEdit || DemoMode);
InterpolateSectObj = !CommEnabled && !PedanticMode;
}
void InitLevelGlobals2(void)

View file

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

View file

@ -111,4 +111,13 @@ 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,6 +49,11 @@ 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_from_int(NORM_ANGLE(pp->RevolveAng + pp->RevolveDeltaAng));
pp->q16ang = fix16_from_int(NORM_ANGLE(pp->RevolveAng + pp->RevolveDeltaAng));
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;