- fixed clipping info not properly reset when rendering the scene in two passes.

We need to reset the gotsector array for that, but since we also need the accumulate result of both passes there's now two such arrays.
This commit is contained in:
Christoph Oelckers 2021-04-07 16:52:17 +02:00
parent caa8efd3d5
commit 7a03967ceb
3 changed files with 27 additions and 21 deletions

View file

@ -85,6 +85,7 @@ void BunchDrawer::StartScene()
Bunches.Clear(); Bunches.Clear();
CompareData.Clear(); CompareData.Clear();
gotsector.Zero(); gotsector.Zero();
gotsector2.Zero();
gotwall.Zero(); gotwall.Zero();
} }
@ -435,8 +436,8 @@ int BunchDrawer::FindClosestBunch()
void BunchDrawer::ProcessSector(int sectnum, bool portal) void BunchDrawer::ProcessSector(int sectnum, bool portal)
{ {
if (gotsector[sectnum]) return; if (gotsector2[sectnum]) return;
gotsector.Set(sectnum); gotsector2.Set(sectnum);
auto sect = &sector[sectnum]; auto sect = &sector[sectnum];
bool inbunch; bool inbunch;
@ -445,28 +446,32 @@ void BunchDrawer::ProcessSector(int sectnum, bool portal)
SetupSprite.Clock(); SetupSprite.Clock();
int z; int z;
SectIterator it(sectnum); if (!gotsector[sectnum])
while ((z = it.NextIndex()) >= 0)
{ {
auto const spr = (uspriteptr_t)&sprite[z]; gotsector.Set(sectnum);
SectIterator it(sectnum);
if ((spr->cstat & CSTAT_SPRITE_INVISIBLE) || spr->xrepeat == 0 || spr->yrepeat == 0) // skip invisible sprites while ((z = it.NextIndex()) >= 0)
continue;
int sx = spr->x - iview.x, sy = spr->y - int(iview.y);
// this checks if the sprite is it behind the camera, which will not work if the pitch is high enough to necessitate a FOV of more than 180°.
//if ((spr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) || (hw_models && tile2model[spr->picnum].modelid >= 0) || ((sx * gcosang) + (sy * gsinang) > 0))
{ {
if ((spr->cstat & (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_MASK)) != (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_WALL) || auto const spr = (uspriteptr_t)&sprite[z];
(r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) ||
(r_voxels && gi->Voxelize(spr->picnum)) || if ((spr->cstat & CSTAT_SPRITE_INVISIBLE) || spr->xrepeat == 0 || spr->yrepeat == 0) // skip invisible sprites
DMulScale(bcos(spr->ang), -sx, bsin(spr->ang), -sy, 6) > 0) continue;
if (renderAddTsprite(di->tsprite, di->spritesortcnt, z, sectnum))
break; int sx = spr->x - iview.x, sy = spr->y - int(iview.y);
// this checks if the sprite is it behind the camera, which will not work if the pitch is high enough to necessitate a FOV of more than 180°.
//if ((spr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) || (hw_models && tile2model[spr->picnum].modelid >= 0) || ((sx * gcosang) + (sy * gsinang) > 0))
{
if ((spr->cstat & (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_MASK)) != (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_WALL) ||
(r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) ||
(r_voxels && gi->Voxelize(spr->picnum)) ||
DMulScale(bcos(spr->ang), -sx, bsin(spr->ang), -sy, 6) > 0)
if (renderAddTsprite(di->tsprite, di->spritesortcnt, z, sectnum))
break;
}
} }
SetupSprite.Unclock();
} }
SetupSprite.Unclock();
if (automapping) if (automapping)
show2dsector.Set(sectnum); show2dsector.Set(sectnum);
@ -547,6 +552,7 @@ void BunchDrawer::RenderScene(const int* viewsectors, unsigned sectcount, bool p
ang2 = bamang(rotang + ANGLE_90); ang2 = bamang(rotang + ANGLE_90);
process(); process();
clipper->Clear(); clipper->Clear();
gotsector2.Zero();
ang1 = bamang(rotang + ANGLE_90); ang1 = bamang(rotang + ANGLE_90);
ang2 = bamang(rotang - ANGLE_90); ang2 = bamang(rotang - ANGLE_90);
process(); process();

View file

@ -28,6 +28,7 @@ class BunchDrawer
vec2_t iview; vec2_t iview;
float gcosang, gsinang; float gcosang, gsinang;
FixedBitArray<MAXSECTORS> gotsector; FixedBitArray<MAXSECTORS> gotsector;
FixedBitArray<MAXSECTORS> gotsector2;
FixedBitArray<MAXWALLS> gotwall; FixedBitArray<MAXWALLS> gotwall;
binangle ang1, ang2; binangle ang1, ang2;

View file

@ -1046,7 +1046,6 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
} }
} }
} }
globalr = globalg = globalb = 255;
} }
void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sector) void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sector)