- SW: moved some Polymost hack stuff to its proper place.

This commit is contained in:
Christoph Oelckers 2021-12-28 20:19:38 +01:00
parent bf7437c827
commit bf9defc062
3 changed files with 76 additions and 64 deletions

View file

@ -333,12 +333,6 @@ void DrawView(double smoothRatio, bool sceneonly)
if (nFreeze != 3) if (nFreeze != 3)
{ {
TArray<uint8_t> paldata(sector.Size() * 2 + wall.Size(), true); TArray<uint8_t> 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()) if (HavePLURemap())
{ {
@ -361,6 +355,10 @@ void DrawView(double smoothRatio, bool sceneonly)
if (!testnewrenderer) 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()); renderSetRollAngle((float)rotscrnang.asbuildf());
renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), sectnum(pSector), false); renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), sectnum(pSector), false);
analyzesprites(pm_tsprite, pm_spritesortcnt, nCamerax, nCameray, viewz, smoothRatio); analyzesprites(pm_tsprite, pm_spritesortcnt, nCamerax, nCameray, viewz, smoothRatio);

View file

@ -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 END_SW_NS

View file

@ -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 #define ZMAX 400
typedef struct typedef struct
@ -708,34 +712,7 @@ bool FindCeilingView(int match, int* x, int* y, int z, sectortype** sect)
if (!testnewrenderer) if (!testnewrenderer)
{ {
pix_diff = labs(z - actor->spr.sector()->floorz) >> 8; SW_CeilingPortalHack(actor, z, match);
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);
}
}
}
} }
return true; return true;
} }
@ -796,36 +773,7 @@ bool FindFloorView(int match, int* x, int* y, int z, sectortype** sect)
if (!testnewrenderer) if (!testnewrenderer)
{ {
// move ceiling multiple of 128 so that the wall tile will line up SW_FloorPortalHack(actor, z, match);
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);
}
}
}
} }
return true; return true;
} }