From 221172311c08bd8211723e4291b9d153dc256c08 Mon Sep 17 00:00:00 2001 From: NY00123 Date: Fri, 1 May 2020 14:29:12 +0300 Subject: [PATCH] SW: Let's make use of interpso.*. Still need to do a few more things. --- source/sw/src/draw.cpp | 9 ++++-- source/sw/src/game.cpp | 3 +- source/sw/src/game.h | 1 - source/sw/src/player.cpp | 2 ++ source/sw/src/sprite.cpp | 2 ++ source/sw/src/track.cpp | 61 ++++++++++++++-------------------------- source/sw/src/weapon.cpp | 7 ++--- 7 files changed, 36 insertions(+), 49 deletions(-) diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 89da7edfc..39a6ac6fd 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -53,6 +53,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "text.h" #include "menus.h" #include "interp.h" +#include "interpso.h" #include "sector.h" #include "config.h" #include "menu/menu.h" @@ -2033,6 +2034,8 @@ drawscreen(PLAYERp pp) { dointerpolations(smoothratio); // Stick at beginning of drawscreen short_dointerpolations(smoothratio); // Stick at beginning of drawscreen + if (gs.InterpolateSO) + so_dointerpolations(smoothratio); // Stick at beginning of drawscreen } // TENSW: when rendering with prediction, the only thing that counts should @@ -2050,7 +2053,7 @@ drawscreen(PLAYERp pp) tq16ang = camerapp->oq16ang + mulscale16(NORM_Q16ANGLE(camerapp->q16ang + fix16_from_int(1024) - camerapp->oq16ang) - fix16_from_int(1024), smoothratio); tq16horiz = camerapp->oq16horiz + mulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio); } - else if (InterpolateSectObj) + else if (gs.InterpolateSO) { tq16ang = camerapp->oq16ang + mulscale16(((pp->camq16ang + fix16_from_int(1024) - camerapp->oq16ang) & 0x7FFFFFF) - fix16_from_int(1024), smoothratio); tq16horiz = camerapp->oq16horiz + mulscale16(pp->camq16horiz - camerapp->oq16horiz, smoothratio); @@ -2092,7 +2095,7 @@ drawscreen(PLAYERp pp) if (pp->sop_riding || pp->sop_control) { - if (pp->sop_control && !InterpolateSectObj) + if (pp->sop_control && !gs.InterpolateSO) { tx = pp->posx; ty = pp->posy; @@ -2318,6 +2321,8 @@ drawscreen(PLAYERp pp) restoreinterpolations(); // Stick at end of drawscreen short_restoreinterpolations(); // Stick at end of drawscreen + if (gs.InterpolateSO) + so_restoreinterpolations(); // Stick at end of drawscreen PostDraw(); DrawScreen = FALSE; diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index a6b10702d..aab1a1786 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -53,6 +53,7 @@ Things required to make savegames work: #include "panel.h" #include "game.h" #include "interp.h" +#include "interpso.h" #include "tags.h" #include "sector.h" #include "sprite.h" @@ -185,7 +186,6 @@ SWBOOL NoDemoStartup = FALSE; SWBOOL FirstTimeIntoGame; SWBOOL PedanticMode; -SWBOOL InterpolateSectObj; SWBOOL BorderAdjust = FALSE; SWBOOL LocationInfo = 0; @@ -957,7 +957,6 @@ void InitLevelGlobals(void) memset(BossSpriteNum,-1,sizeof(BossSpriteNum)); PedanticMode = (DemoPlaying || DemoRecording || DemoEdit || DemoMode); - InterpolateSectObj = !CommEnabled && !PedanticMode; } void InitLevelGlobals2(void) diff --git a/source/sw/src/game.h b/source/sw/src/game.h index ad9bb6aae..eeb53f4d9 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -189,7 +189,6 @@ int krand1(void); #include "pragmas.h" extern SWBOOL PedanticMode; -extern SWBOOL InterpolateSectObj; // // Map directions/degrees diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 9e3eebbff..5b2e0a356 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -62,6 +62,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "vis.h" #include "track.h" #include "interp.h" +#include "interpso.h" #include "menu/menu.h" #include "gstrings.h" #include "z_music.h" @@ -7952,6 +7953,7 @@ domovethings(void) updateinterpolations(); // Stick at beginning of domovethings short_updateinterpolations(); // Stick at beginning of domovethings + so_updateinterpolations(); // Stick at beginning of domovethings MoveSkipSavePos(); #if 0 diff --git a/source/sw/src/sprite.cpp b/source/sw/src/sprite.cpp index babfffed4..a6ba463c5 100644 --- a/source/sw/src/sprite.cpp +++ b/source/sw/src/sprite.cpp @@ -41,6 +41,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "sounds.h" #include "interp.h" +#include "interpso.h" #include "sprite.h" #include "weapon.h" #include "jsector.h" @@ -692,6 +693,7 @@ KillSprite(int16_t SpriteNum) sn--; ASSERT(sop->sp_num[sn] >= 0); + so_stopspriteinterpolation(sop, sp); // replace the one to be deleted with the last ndx sop->sp_num[FoundSpriteNdx] = sop->sp_num[sn]; // the last ndx is not -1 diff --git a/source/sw/src/track.cpp b/source/sw/src/track.cpp index 3e0b651f8..ce78edbc2 100644 --- a/source/sw/src/track.cpp +++ b/source/sw/src/track.cpp @@ -34,7 +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 "interpso.h" #include "network.h" #include "sprite.h" #include "track.h" @@ -849,7 +849,6 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) // // Make sure every sector object has an outer loop tagged - important - // Further setup interpolation // FoundOutsideLoop = FALSE; @@ -862,21 +861,6 @@ 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; @@ -886,16 +870,10 @@ 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) @@ -903,13 +881,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) I_Error("Forgot to tag outer loop for Sector Object #%d", (int)(sop - SectorObject)); } - // interpolate midpoint, for aiming at a remote controlled SO - if (InterpolateSectObj) - { - setinterpolation(&sop->xmid); - setinterpolation(&sop->ymid); - setinterpolation(&sop->zmid); - } + so_addinterpolation(sop); for (i = 0; i < (int)SIZ(StatList); i++) { @@ -1003,8 +975,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) ASSERT(sn < SIZ(sop->sp_num) - 1); sop->sp_num[sn] = sp_num; - if (InterpolateSectObj) - setspriteinterpolation(sp); + so_setspriteinterpolation(sop, sp); if (!TEST(sop->flags, SOBJ_SPRITE_OBJ)) @@ -1665,7 +1636,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny) if (TEST(sop->flags, SOBJ_DONT_ROTATE)) { - if (!InterpolateSectObj) + if (!gs.InterpolateSO) { pp->oposx = pp->posx; pp->oposy = pp->posy; @@ -1715,7 +1686,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny) pp->camq16ang = NORM_Q16ANGLE(pp->camq16ang); pp->q16ang = NORM_Q16ANGLE(pp->RevolveQ16Ang + fix16_from_int(pp->RevolveDeltaAng)); - if (!InterpolateSectObj) + if (!gs.InterpolateSO) { pp->oq16ang = pp->q16ang; pp->oposx = pp->posx; @@ -1975,7 +1946,7 @@ PlayerPart: pp->SpriteP->z = pp->loz; } } - if (!InterpolateSectObj) + if (!gs.InterpolateSO) pp->oposz = pp->posz; } else @@ -2091,8 +2062,7 @@ void KillSectorObjectSprites(SECTOR_OBJECTp sop) if (sp->picnum == ST1 && sp->hitag == SPAWN_SPOT) continue; - if (InterpolateSectObj) - stopspriteinterpolation(sp); + so_stopspriteinterpolation(sop, sp); KillSprite(sop->sp_num[i]); } @@ -2397,6 +2367,8 @@ MoveSectorObjects(SECTOR_OBJECTp sop, short locktics) short speed; short delta_ang; + so_setinterpolationtics(sop, locktics); + if (sop->track >= SO_OPERATE_TRACK_START) { if (TEST(sop->flags, SOBJ_UPDATE_ONCE)) @@ -2817,7 +2789,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny) void -OperateSectorObject(SECTOR_OBJECTp sop, short newang, int newx, int newy) +OperateSectorObjectForTics(SECTOR_OBJECTp sop, short newang, int newx, int newy, short locktics) { int i; SECTORp *sectp; @@ -2828,6 +2800,8 @@ OperateSectorObject(SECTOR_OBJECTp sop, short newang, int newx, int newy) if (sop->track < SO_OPERATE_TRACK_START) return; + so_setinterpolationtics(sop, locktics); + if (sop->bob_amt) { sop->bob_sine_ndx = (totalsynctics << sop->bob_speed) & 2047; @@ -2854,9 +2828,16 @@ OperateSectorObject(SECTOR_OBJECTp sop, short newang, int newx, int newy) RefreshPoints(sop, newx - sop->xmid, newy - sop->ymid, FALSE); } +void +OperateSectorObject(SECTOR_OBJECTp sop, short newang, int newx, int newy) +{ + OperateSectorObjectForTics(sop, newang, newx, newy, synctics); +} + void PlaceSectorObject(SECTOR_OBJECTp sop, int newx, int newy) { + so_setinterpolationtics(sop, synctics); RefreshPoints(sop, newx - sop->xmid, newy - sop->ymid, FALSE); } @@ -3079,7 +3060,7 @@ DoAutoTurretObject(SECTOR_OBJECTp sop) } } - OperateSectorObject(sop, sop->ang, sop->xmid, sop->ymid); + OperateSectorObjectForTics(sop, sop->ang, sop->xmid, sop->ymid, 2*synctics); } } diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index 0756a69db..95f9e8f9c 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -32,6 +32,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "panel.h" #include "game.h" #include "interp.h" +#include "interpso.h" #include "tags.h" #include "common_game.h" #include "break.h" @@ -11393,8 +11394,7 @@ AddSpriteToSectorObject(short SpriteNum, SECTOR_OBJECTp sop) ASSERT(sn < SIZ(sop->sp_num) - 1); sop->sp_num[sn] = SpriteNum; - if (InterpolateSectObj) - setspriteinterpolation(sp); + so_setspriteinterpolation(sop, sp); SET(u->Flags, SPR_ON_SO_SECTOR|SPR_SO_ATTACHED); @@ -11461,8 +11461,7 @@ 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); + so_setspriteinterpolation(sop, exp); // Place sprite exactly where shoot point is //exp->x = eu->ox = sop->xmid - u->sx;