From bf9defc062eeab05ecd4e2838f4faa2c0303252a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 28 Dec 2021 20:19:38 +0100 Subject: [PATCH] - SW: moved some Polymost hack stuff to its proper place. --- source/games/exhumed/src/view.cpp | 10 ++--- source/games/sw/src/_polymost.cpp | 66 +++++++++++++++++++++++++++++++ source/games/sw/src/rooms.cpp | 64 +++--------------------------- 3 files changed, 76 insertions(+), 64 deletions(-) diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 90858c287..aa33d7f0f 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -333,12 +333,6 @@ void DrawView(double smoothRatio, bool sceneonly) if (nFreeze != 3) { TArray paldata(sector.Size() * 2 + wall.Size(), true); - int const viewingRange = viewingrange; - int const vr = xs_CRoundToInt(65536. * tan(r_fov * (pi::pi() / 360.))); - - - videoSetCorrectedAspect(); - renderSetAspect(MulScale(vr, viewingrange, 16), yxaspect); if (HavePLURemap()) { @@ -361,6 +355,10 @@ void DrawView(double smoothRatio, bool sceneonly) if (!testnewrenderer) { + // this little block of code is Exhumed's entire interface to Polymost. + int const vr = xs_CRoundToInt(65536. * tan(r_fov * (pi::pi() / 360.))); + videoSetCorrectedAspect(); + renderSetAspect(MulScale(vr, viewingrange, 16), yxaspect); renderSetRollAngle((float)rotscrnang.asbuildf()); renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), sectnum(pSector), false); analyzesprites(pm_tsprite, pm_spritesortcnt, nCamerax, nCameray, viewz, smoothRatio); diff --git a/source/games/sw/src/_polymost.cpp b/source/games/sw/src/_polymost.cpp index 6309c369d..194c27dd1 100644 --- a/source/games/sw/src/_polymost.cpp +++ b/source/games/sw/src/_polymost.cpp @@ -310,4 +310,70 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed } +void SW_FloorPortalHack(DSWActor* actor, int z, int match) +{ + // move ceiling multiple of 128 so that the wall tile will line up + int pix_diff = labs(z - actor->spr.sector()->ceilingz) >> 8; + int newz = actor->spr.sector()->ceilingz - ((pix_diff / 128) + 1) * Z(128); + + SWStatIterator it(STAT_FAF); + while (actor = it.Next()) + { + if (actor->spr.lotag == match) + { + // move upper levels floors down for the correct view + if (actor->spr.hitag == VIEW_LEVEL1) + { + // save it off + save.sect[save.zcount] = actor->spr.sector(); + save.zval[save.zcount] = actor->spr.sector()->ceilingz; + save.pic[save.zcount] = actor->spr.sector()->ceilingpicnum; + save.slope[save.zcount] = actor->spr.sector()->ceilingheinum; + + actor->spr.sector()->setceilingz(newz, true); + + // don't change FAF_MIRROR_PIC - ConnectArea + if (actor->spr.sector()->ceilingpicnum != FAF_MIRROR_PIC) + actor->spr.sector()->ceilingpicnum = FAF_MIRROR_PIC + 1; + actor->spr.sector()->setceilingslope(0); + + save.zcount++; + PRODUCTION_ASSERT(save.zcount < ZMAX); + } + } + } +} + +void SW_CeilingPortalHack(DSWActor* actor, int z, int match) +{ + int pix_diff = labs(z - actor->spr.sector()->floorz) >> 8; + int newz = actor->spr.sector()->floorz + ((pix_diff / 128) + 1) * Z(128); + + SWStatIterator it(STAT_FAF); + while (actor = it.Next()) + { + if (actor->spr.lotag == match) + { + // move lower levels ceilings up for the correct view + if (actor->spr.hitag == VIEW_LEVEL2) + { + // save it off + save.sect[save.zcount] = actor->spr.sector(); + save.zval[save.zcount] = actor->spr.sector()->floorz; + save.pic[save.zcount] = actor->spr.sector()->floorpicnum; + save.slope[save.zcount] = actor->spr.sector()->floorheinum; + + actor->spr.sector()->setfloorz(newz, true); + // don't change FAF_MIRROR_PIC - ConnectArea + if (actor->spr.sector()->floorpicnum != FAF_MIRROR_PIC) + actor->spr.sector()->floorpicnum = FAF_MIRROR_PIC + 1; + actor->spr.sector()->setfloorslope(0); + + save.zcount++; + PRODUCTION_ASSERT(save.zcount < ZMAX); + } + } + } + +} END_SW_NS diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 8b718d418..e96dacff0 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -39,6 +39,10 @@ BEGIN_SW_NS // //////////////////////////////////////////////////////////////////// +// Polymost only! +void SW_FloorPortalHack(DSWActor* actor, int z, int match); +void SW_CeilingPortalHack(DSWActor* actor, int z, int match); + #define ZMAX 400 typedef struct @@ -708,34 +712,7 @@ bool FindCeilingView(int match, int* x, int* y, int z, sectortype** sect) if (!testnewrenderer) { - pix_diff = labs(z - actor->spr.sector()->floorz) >> 8; - newz = actor->spr.sector()->floorz + ((pix_diff / 128) + 1) * Z(128); - - it.Reset(STAT_FAF); - while (actor = it.Next()) - { - if (actor->spr.lotag == match) - { - // move lower levels ceilings up for the correct view - if (actor->spr.hitag == VIEW_LEVEL2) - { - // save it off - save.sect[save.zcount] = actor->spr.sector(); - save.zval[save.zcount] = actor->spr.sector()->floorz; - save.pic[save.zcount] = actor->spr.sector()->floorpicnum; - save.slope[save.zcount] = actor->spr.sector()->floorheinum; - - actor->spr.sector()->setfloorz(newz, true); - // don't change FAF_MIRROR_PIC - ConnectArea - if (actor->spr.sector()->floorpicnum != FAF_MIRROR_PIC) - actor->spr.sector()->floorpicnum = FAF_MIRROR_PIC + 1; - actor->spr.sector()->setfloorslope(0); - - save.zcount++; - PRODUCTION_ASSERT(save.zcount < ZMAX); - } - } - } + SW_CeilingPortalHack(actor, z, match); } return true; } @@ -796,36 +773,7 @@ bool FindFloorView(int match, int* x, int* y, int z, sectortype** sect) if (!testnewrenderer) { - // move ceiling multiple of 128 so that the wall tile will line up - pix_diff = labs(z - actor->spr.sector()->ceilingz) >> 8; - newz = actor->spr.sector()->ceilingz - ((pix_diff / 128) + 1) * Z(128); - - it.Reset(STAT_FAF); - while (actor = it.Next()) - { - if (actor->spr.lotag == match) - { - // move upper levels floors down for the correct view - if (actor->spr.hitag == VIEW_LEVEL1) - { - // save it off - save.sect[save.zcount] = actor->spr.sector(); - save.zval[save.zcount] = actor->spr.sector()->ceilingz; - save.pic[save.zcount] = actor->spr.sector()->ceilingpicnum; - save.slope[save.zcount] = actor->spr.sector()->ceilingheinum; - - actor->spr.sector()->setceilingz(newz, true); - - // don't change FAF_MIRROR_PIC - ConnectArea - if (actor->spr.sector()->ceilingpicnum != FAF_MIRROR_PIC) - actor->spr.sector()->ceilingpicnum = FAF_MIRROR_PIC + 1; - actor->spr.sector()->setceilingslope(0); - - save.zcount++; - PRODUCTION_ASSERT(save.zcount < ZMAX); - } - } - } + SW_FloorPortalHack(actor, z, match); } return true; }