From 7a03967ceb3f00e59e4c179cd9b762affabdfec8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 7 Apr 2021 16:52:17 +0200 Subject: [PATCH] - 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. --- .../core/rendering/scene/hw_bunchdrawer.cpp | 46 +++++++++++-------- source/core/rendering/scene/hw_bunchdrawer.h | 1 + source/core/rendering/scene/hw_walls.cpp | 1 - 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/source/core/rendering/scene/hw_bunchdrawer.cpp b/source/core/rendering/scene/hw_bunchdrawer.cpp index 955aa7f3d..23168b8da 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.cpp +++ b/source/core/rendering/scene/hw_bunchdrawer.cpp @@ -85,6 +85,7 @@ void BunchDrawer::StartScene() Bunches.Clear(); CompareData.Clear(); gotsector.Zero(); + gotsector2.Zero(); gotwall.Zero(); } @@ -435,8 +436,8 @@ int BunchDrawer::FindClosestBunch() void BunchDrawer::ProcessSector(int sectnum, bool portal) { - if (gotsector[sectnum]) return; - gotsector.Set(sectnum); + if (gotsector2[sectnum]) return; + gotsector2.Set(sectnum); auto sect = §or[sectnum]; bool inbunch; @@ -445,28 +446,32 @@ void BunchDrawer::ProcessSector(int sectnum, bool portal) SetupSprite.Clock(); int z; - SectIterator it(sectnum); - while ((z = it.NextIndex()) >= 0) + if (!gotsector[sectnum]) { - auto const spr = (uspriteptr_t)&sprite[z]; - - if ((spr->cstat & CSTAT_SPRITE_INVISIBLE) || spr->xrepeat == 0 || spr->yrepeat == 0) // skip invisible sprites - 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)) + gotsector.Set(sectnum); + SectIterator it(sectnum); + while ((z = it.NextIndex()) >= 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; + auto const spr = (uspriteptr_t)&sprite[z]; + + if ((spr->cstat & CSTAT_SPRITE_INVISIBLE) || spr->xrepeat == 0 || spr->yrepeat == 0) // skip invisible sprites + 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) || + (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) show2dsector.Set(sectnum); @@ -547,6 +552,7 @@ void BunchDrawer::RenderScene(const int* viewsectors, unsigned sectcount, bool p ang2 = bamang(rotang + ANGLE_90); process(); clipper->Clear(); + gotsector2.Zero(); ang1 = bamang(rotang + ANGLE_90); ang2 = bamang(rotang - ANGLE_90); process(); diff --git a/source/core/rendering/scene/hw_bunchdrawer.h b/source/core/rendering/scene/hw_bunchdrawer.h index 9182ef76a..d8906c6c8 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.h +++ b/source/core/rendering/scene/hw_bunchdrawer.h @@ -28,6 +28,7 @@ class BunchDrawer vec2_t iview; float gcosang, gsinang; FixedBitArray gotsector; + FixedBitArray gotsector2; FixedBitArray gotwall; binangle ang1, ang2; diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 8d74b0437..7117bbac1 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -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)