diff --git a/source/build/include/build.h b/source/build/include/build.h index d54d887ca..f56b18e45 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -271,7 +271,7 @@ EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; EXTERN uint8_t gotpic[(MAXTILES+7)>>3]; -EXTERN char gotsector[(MAXSECTORS+7)>>3]; +extern FixedBitArray gotsector; extern uint32_t drawlinepat; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index b04d84267..09ad5ad9b 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -1818,7 +1818,7 @@ static void polymost_drawalls(int32_t const bunch) domostpolymethod = DAMETH_NOMASK; if (nextsectnum >= 0) - if ((!(gotsector[nextsectnum>>3]& (1<<(nextsectnum&7)))) && testvisiblemost(x0,x1)) + if (!gotsector[nextsectnum] && testvisiblemost(x0,x1)) polymost_scansector(nextsectnum); } } @@ -1919,7 +1919,7 @@ void polymost_scansector(int32_t sectnum) } } - gotsector[sectnum>>3] |= 1<<(sectnum&7); + gotsector.Set(sectnum); int const bunchfrst = numbunches; int const onumscans = numscans; @@ -1942,7 +1942,7 @@ void polymost_scansector(int32_t sectnum) int const nextsectnum = wal->nextsector; //Scan close sectors if (nextsectnum >= 0 && !(wal->cstat&32) && sectorbordercnt < countof(sectorborder)) - if ((gotsector[nextsectnum>>3]&(1<<(nextsectnum&7))) == 0) + if (gotsector[nextsectnum] == 0) { double const d = fp1.X* fp2.Y - fp2.X * fp1.Y; DVector2 const p1 = fp2 - fp1; @@ -1952,7 +1952,7 @@ void polymost_scansector(int32_t sectnum) if (d*d < (p1.LengthSquared()) * 256.f) { sectorborder[sectorbordercnt++] = nextsectnum; - gotsector[nextsectnum>>3] |= 1<<(nextsectnum&7); + gotsector.Set(nextsectnum); } } @@ -3355,7 +3355,7 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, global100horiz = dahoriz; - memset(gotsector, 0, sizeof(gotsector)); + gotsector.Zero(); qglobalhoriz = MulScale(dahoriz, DivScale(xdimenscale, viewingrange, 16), 16) + IntToFixed(ydimen >> 1); globalcursectnum = dacursectnum; Polymost::polymost_drawrooms(); diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 9d79e9067..1589708a1 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -565,7 +565,7 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang) for (int i = numsectors - 1; i >= 0; i--) { - if (!gFullMap && !show2dsector[i] && !(g_gameType & GAMEFLAG_SW)) continue; + if (!gFullMap && !show2dsector[i]) continue; //Collect floor sprites to draw SectIterator it(i); @@ -585,6 +585,9 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang) if (sector[i].floorstat & CSTAT_SECTOR_SKY) continue; + int picnum = sector[i].floorpicnum; + if ((unsigned)picnum >= (unsigned)MAXTILES) continue; + auto mesh = sectorGeometry.get(i, 0); vertices.Resize(mesh->vertices.Size()); for (unsigned j = 0; j < mesh->vertices.Size(); j++) @@ -595,8 +598,6 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang) int y1 = DMulScale(oy, xvect, ox, yvect, 16) + (height << 11); vertices[j] = { x1 / 4096.f, y1 / 4096.f, mesh->texcoords[j].X, mesh->texcoords[j].Y }; } - int picnum = sector[i].floorpicnum; - if ((unsigned)picnum >= (unsigned)MAXTILES) continue; int translation = TRANSLATION(Translation_Remap + curbasepal, sector[i].floorpal); setgotpic(picnum); @@ -616,6 +617,7 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang) vertices.Resize(4); for (auto sn : floorsprites) { + if (!gFullMap && !show2dsprite[sn]) continue; auto spr = &sprite[sn]; vec2_t pp[4]; GetFlatSpritePosition(spr, spr->pos.vec2, pp, true); diff --git a/source/core/rendering/scene/hw_bunchdrawer.cpp b/source/core/rendering/scene/hw_bunchdrawer.cpp index 4a1450e1d..66db00c5a 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.cpp +++ b/source/core/rendering/scene/hw_bunchdrawer.cpp @@ -453,6 +453,8 @@ void BunchDrawer::ProcessSector(int sectnum) } SetupSprite.Unclock(); + if (automapping) + show2dsector.Set(sectnum); SetupFlat.Clock(); HWFlat flat; diff --git a/source/core/rendering/scene/hw_bunchdrawer.h b/source/core/rendering/scene/hw_bunchdrawer.h index 371eae9cc..dbf5329eb 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.h +++ b/source/core/rendering/scene/hw_bunchdrawer.h @@ -37,7 +37,6 @@ private: CL_Pass = 2, }; - void StartScene(); void StartBunch(int sectnum, int linenum, binangle startan, binangle endan); void AddLineToBunch(int line, binangle newan); @@ -53,4 +52,5 @@ private: public: void Init(HWDrawInfo* _di, Clipper* c, vec2_t& view); void RenderScene(const int* viewsectors, unsigned sectcount); + const FixedBitArray& GotSector() const { return gotsector; } }; diff --git a/source/core/rendering/scene/hw_drawinfo.cpp b/source/core/rendering/scene/hw_drawinfo.cpp index 01c91a642..9ff8acd34 100644 --- a/source/core/rendering/scene/hw_drawinfo.cpp +++ b/source/core/rendering/scene/hw_drawinfo.cpp @@ -40,6 +40,7 @@ #include "v_draw.h" #include "gamecvars.h" #include "gamestruct.h" +#include "automap.h" EXTERN_CVAR(Float, r_visibility) CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE) @@ -51,6 +52,8 @@ CVAR(Bool, gl_texture, true, 0) CVAR(Float, gl_mask_threshold, 0.5f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +FixedBitArray gotsector; + //========================================================================== // // @@ -281,6 +284,9 @@ void HWDrawInfo::DispatchSprites() if (spritenum < 0 || (unsigned)tilenum >= MAXTILES) continue; + if (automapping == 1 && (unsigned)spritenum < MAXSPRITES) + show2dsprite.Set(spritenum); + setgotpic(tilenum); while (!(spriteext[spritenum].flags & SPREXT_NOTMD)) @@ -648,4 +654,8 @@ void HWDrawInfo::ProcessScene(bool toscreen) { portalState.BeginScene(); DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN); + if (toscreen && isBlood()) + { + gotsector = mDrawer.GotSector(); // Blood needs this to implement some lighting effect hacks. Needs to be refactored to use better info. + } } diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index d07e2c9da..df342bc1e 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -725,7 +725,7 @@ void viewDrawScreen(bool sceneonly) int nXSprite = pSprite->extra; assert(nXSprite > 0 && nXSprite < kMaxXSprites); XSPRITE* pXSprite = &xsprite[nXSprite]; - if (TestBitString(gotsector, pSprite->sectnum)) + if (gotsector[pSprite->sectnum]) { brightness += pXSprite->data3 * 32; } @@ -739,7 +739,7 @@ void viewDrawScreen(bool sceneonly) case kMissileTeslaAlt: case kMissileFlareAlt: case kMissileTeslaRegular: - if (TestBitString(gotsector, pSprite->sectnum)) brightness += 256; + if (gotsector[pSprite->sectnum]) brightness += 256; break; } } diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 14848af2d..f1a3cc1fd 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -209,7 +209,7 @@ void V_AddBlend (float r, float g, float b, float a, float v_blend[4]) //--------------------------------------------------------------------------- // -// 'rest' in this case means everything not part of the 3D scene and its weapon sprite. +// draws everything not part of the 3D scene and its weapon sprite. // //--------------------------------------------------------------------------- diff --git a/source/games/sw/src/_polymost.cpp b/source/games/sw/src/_polymost.cpp index 499ff7ffa..2288f28bf 100644 --- a/source/games/sw/src/_polymost.cpp +++ b/source/games/sw/src/_polymost.cpp @@ -134,7 +134,7 @@ void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, short while ((i = it.NextIndex()) >= 0) { // manually set gotpic - if (TEST_GOTSECTOR(sprite[i].sectnum)) + if (gotsector[sprite[i].sectnum]) { SET_GOTPIC(FAF_MIRROR_PIC); } diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index b388afcdd..1dbc5d783 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1446,12 +1446,6 @@ void RestorePortalState() StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE); while ((i = it.NextIndex()) >= 0) { - // manually set gotpic - if (TEST_GOTSECTOR(sprite[i].sectnum)) - { - SET_GOTPIC(FAF_MIRROR_PIC); - } - if (SPRITE_TAG3(i) == 0) { // restore ceilingpicnum and ceilingstat @@ -1794,7 +1788,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, x1 = sprx - cposx; y1 = spry - cposy; - if (((gotsector[i >> 3] & (1 << (i & 7))) > 0) && (czoom > 192)) + if (czoom > 192) { daang = ((!SyncInput() ? spr->ang : spr->interpolatedang(smoothratio)) - cang) & 2047; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index ac0468e35..98e333c04 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -355,10 +355,6 @@ inline int SPRITEp_SIZE_BOS(const spritetype* sp) // just determine if the player is moving #define PLAYER_MOVING(pp) ((pp)->xvect|(pp)->yvect) -#define TEST_GOTSECTOR(sect_num) (TEST(gotsector[(sect_num) >> 3], 1 << ((sect_num) & 7))) -#define RESET_GOTSECTOR(sect_num) (RESET(gotsector[(sect_num) >> 3], 1 << ((sect_num) & 7))) -#define SET_GOTSECTOR(sect_num) (SET(gotsector[(sect_num) >> 3], 1 << ((sect_num) & 7))) - #define TEST_GOTPIC(tile_num) (TEST(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7))) #define RESET_GOTPIC(tile_num) (RESET(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7))) #define SET_GOTPIC(tile_num) (SET(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7)))