diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 9d693d2cd..51bf06773 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -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; diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index f7c6f8e83..c8c421b98 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -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) diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 09ac2b2c4..c551b9aad 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -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 /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/sw/src/interp.cpp b/source/sw/src/interp.cpp index 917d6f270..df437a003 100644 --- a/source/sw/src/interp.cpp +++ b/source/sw/src/interp.cpp @@ -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 diff --git a/source/sw/src/interp.h b/source/sw/src/interp.h index def0248d8..3347d1283 100644 --- a/source/sw/src/interp.h +++ b/source/sw/src/interp.h @@ -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 diff --git a/source/sw/src/track.cpp b/source/sw/src/track.cpp index 90a67be18..b09bb3b53 100644 --- a/source/sw/src/track.cpp +++ b/source/sw/src/track.cpp @@ -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]); } diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index 3bcb556ea..0756a69db 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -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;