- handle the RR geometry hack

This commit is contained in:
Christoph Oelckers 2021-11-21 09:08:05 +01:00
parent 9c7eecb55f
commit 4928187b02
6 changed files with 28 additions and 23 deletions

View file

@ -50,9 +50,9 @@ extern cycle_t drawtime, actortime, thinktime, gameupdatetime;
struct GeoEffect
{
int* geosectorwarp;
int* geosectorwarp2;
int* geosector;
sectortype** geosectorwarp;
sectortype** geosectorwarp2;
sectortype** geosector;
int* geox;
int* geoy;
int* geox2;

View file

@ -399,17 +399,18 @@ void HWDrawInfo::CreateScene(bool portal)
GeoEffect eff;
int effsect = vp.SectNums ? vp.SectNums[0] : vp.SectCount;
int drawsect = effsect;
auto drawsectp = &sector[effsect];
auto orgdrawsectp = drawsectp;
// RR geometry hack. Ugh...
// This just adds to the existing render list, so we must offset the effect areas to the same xy-space as the main one as we cannot change the view matrix.
if (gi->GetGeoEffect(&eff, &sector[effsect]))
if (gi->GetGeoEffect(&eff, drawsectp))
{
ingeo = true;
geoofs = { (float)eff.geox[0], (float)eff.geoy[0] };
// process the first layer.
for (int i = 0; i < eff.geocnt; i++)
{
auto sect = &sector[eff.geosectorwarp[i]];
auto sect = eff.geosectorwarp[i];
for (auto w = 0; w < sect->wallnum; w++)
{
auto wal = &wall[sect->wallptr + w];
@ -417,17 +418,18 @@ void HWDrawInfo::CreateScene(bool portal)
wal->y += eff.geoy[i];
}
sect->dirty = 255;
if (eff.geosector[i] == effsect) drawsect = eff.geosectorwarp[i];
if (eff.geosector[i] == drawsectp) drawsectp = eff.geosectorwarp[i];
}
if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, view, bamang(vp.RotAngle - a1), bamang(vp.RotAngle + a1));
else mDrawer.Init(this, mClipper, view, bamang(0), bamang(0));
int drawsect = sectnum(drawsectp);
mDrawer.RenderScene(&drawsect, 1, false);
for (int i = 0; i < eff.geocnt; i++)
{
auto sect = &sector[eff.geosectorwarp[i]];
auto sect = eff.geosectorwarp[i];
for (auto w = 0; w < sect->wallnum; w++)
{
auto wal = &wall[sect->wallptr + w];
@ -440,7 +442,7 @@ void HWDrawInfo::CreateScene(bool portal)
geoofs = { (float)eff.geox2[0], (float)eff.geoy2[0] };
for (int i = 0; i < eff.geocnt; i++)
{
auto sect = &sector[eff.geosectorwarp2[i]];
auto sect = eff.geosectorwarp2[i];
for (auto w = 0; w < sect->wallnum; w++)
{
auto wal = &wall[sect->wallptr + w];
@ -448,16 +450,17 @@ void HWDrawInfo::CreateScene(bool portal)
wal->y += eff.geoy2[i];
}
sect->dirty = 255;
if (eff.geosector[i] == effsect) drawsect = eff.geosectorwarp2[i];
if (eff.geosector[i] == orgdrawsectp) drawsectp = eff.geosectorwarp2[i];
}
if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, view, bamang(vp.RotAngle - a1), bamang(vp.RotAngle + a1));
else mDrawer.Init(this, mClipper, view, bamang(0), bamang(0));
drawsect = sectnum(drawsectp);
mDrawer.RenderScene(&drawsect, 1, false);
for (int i = 0; i < eff.geocnt; i++)
{
auto sect = &sector[eff.geosectorwarp2[i]];
auto sect = eff.geosectorwarp2[i];
for (auto w = 0; w < sect->wallnum; w++)
{
auto wal = &wall[sect->wallptr + w];

View file

@ -203,7 +203,9 @@ void renderMirror(int cposx, int cposy, int cposz, binangle cang, fixedhoriz cho
static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixedhoriz choriz, int sect, int smoothratio)
{
int gs, tgsect, geosect, geoid = 0;
auto sectp = &sector[sect];
int gs, geoid = 0;
sectortype* tgsect, *geosect;
renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), sect, false);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio);
renderDrawMasks();
@ -217,7 +219,7 @@ static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixed
changeactorsect(act, geosectorwarp[gs]);
setsprite(act, act->s->x -= geox[gs], act->s->y -= geoy[gs], act->s->z);
}
if (geosector[gs] == sect)
if (geosector[gs] == sectp)
{
geosect = geosectorwarp[gs];
geoid = gs;
@ -249,7 +251,7 @@ static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixed
changeactorsect(act, geosectorwarp2[gs]);
setsprite(act, act->s->x -= geox2[gs], act->s->y -= geoy2[gs], act->s->z);
}
if (geosector[gs] == sect)
if (geosector[gs] == sectp)
{
geosect = geosectorwarp2[gs];
geoid = gs;

View file

@ -123,9 +123,9 @@ uint32_t everyothertime; // Global animation ticker helper.
// Redneck Rampage
int thunder_brightness;
int wupass; // used to play the level entry sound only once.
int geosectorwarp[MAXGEOSECTORS]; // geometry render hack (overlay a secondary scene)
int geosectorwarp2[MAXGEOSECTORS];
int geosector[MAXGEOSECTORS];
sectortype* geosectorwarp[MAXGEOSECTORS]; // geometry render hack (overlay a secondary scene)
sectortype* geosectorwarp2[MAXGEOSECTORS];
sectortype* geosector[MAXGEOSECTORS];
int geox[MAXGEOSECTORS];
int geoy[MAXGEOSECTORS];
int geox2[MAXGEOSECTORS];

View file

@ -104,9 +104,9 @@ extern int ufocnt;
extern int hulkspawn;
extern int lastlevel;
extern int geosectorwarp[MAXGEOSECTORS];
extern int geosectorwarp2[MAXGEOSECTORS];
extern int geosector[MAXGEOSECTORS];
extern sectortype* geosectorwarp[MAXGEOSECTORS];
extern sectortype* geosectorwarp2[MAXGEOSECTORS];
extern sectortype* geosector[MAXGEOSECTORS];
extern int geox[MAXGEOSECTORS];
extern int geoy[MAXGEOSECTORS];
extern int geox2[MAXGEOSECTORS];

View file

@ -610,7 +610,7 @@ void prelevel_r(int g)
I_Error("Too many geometry effects");
if (spr->hitag == 0)
{
geosector[geocnt] = spr->sectnum;
geosector[geocnt] = spr->sector();
for (j = 0; j < MAXSPRITES; j++)
{
auto spj = &sprite[j];
@ -618,14 +618,14 @@ void prelevel_r(int g)
{
if (spj->hitag == 1)
{
geosectorwarp[geocnt] = spj->sectnum;
geosectorwarp[geocnt] = spj->sector();
geox[geocnt] = spr->x - spj->x;
geoy[geocnt] = spr->y - spj->y;
//geoz[geocnt] = spr->z - spj->z;
}
if (spj->hitag == 2)
{
geosectorwarp2[geocnt] = spj->sectnum;
geosectorwarp2[geocnt] = spj->sector();
geox2[geocnt] = spr->x - spj->x;
geoy2[geocnt] = spr->y - spj->y;
//geoz2[geocnt] = spr->z - spj->z;