- fixed some automap issues:

* Blood's automap was not drawn at all.
* SW's automap always showed all sectors
* SW's player sprite was not rendered.
* Non-automap: Forward gotsector to the game code because there's still a few places in Blood that need it.
This commit is contained in:
Christoph Oelckers 2021-04-01 20:47:05 +02:00
parent 85020b374a
commit 80e5cd0dc5
11 changed files with 29 additions and 25 deletions

View file

@ -271,7 +271,7 @@ EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES];
EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES];
EXTERN uint8_t gotpic[(MAXTILES+7)>>3]; EXTERN uint8_t gotpic[(MAXTILES+7)>>3];
EXTERN char gotsector[(MAXSECTORS+7)>>3]; extern FixedBitArray<MAXSECTORS> gotsector;
extern uint32_t drawlinepat; extern uint32_t drawlinepat;

View file

@ -1818,7 +1818,7 @@ static void polymost_drawalls(int32_t const bunch)
domostpolymethod = DAMETH_NOMASK; domostpolymethod = DAMETH_NOMASK;
if (nextsectnum >= 0) if (nextsectnum >= 0)
if ((!(gotsector[nextsectnum>>3]& (1<<(nextsectnum&7)))) && testvisiblemost(x0,x1)) if (!gotsector[nextsectnum] && testvisiblemost(x0,x1))
polymost_scansector(nextsectnum); 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 bunchfrst = numbunches;
int const onumscans = numscans; int const onumscans = numscans;
@ -1942,7 +1942,7 @@ void polymost_scansector(int32_t sectnum)
int const nextsectnum = wal->nextsector; //Scan close sectors int const nextsectnum = wal->nextsector; //Scan close sectors
if (nextsectnum >= 0 && !(wal->cstat&32) && sectorbordercnt < countof(sectorborder)) 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; double const d = fp1.X* fp2.Y - fp2.X * fp1.Y;
DVector2 const p1 = fp2 - fp1; DVector2 const p1 = fp2 - fp1;
@ -1952,7 +1952,7 @@ void polymost_scansector(int32_t sectnum)
if (d*d < (p1.LengthSquared()) * 256.f) if (d*d < (p1.LengthSquared()) * 256.f)
{ {
sectorborder[sectorbordercnt++] = nextsectnum; 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; global100horiz = dahoriz;
memset(gotsector, 0, sizeof(gotsector)); gotsector.Zero();
qglobalhoriz = MulScale(dahoriz, DivScale(xdimenscale, viewingrange, 16), 16) + IntToFixed(ydimen >> 1); qglobalhoriz = MulScale(dahoriz, DivScale(xdimenscale, viewingrange, 16), 16) + IntToFixed(ydimen >> 1);
globalcursectnum = dacursectnum; globalcursectnum = dacursectnum;
Polymost::polymost_drawrooms(); Polymost::polymost_drawrooms();

View file

@ -565,7 +565,7 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang)
for (int i = numsectors - 1; i >= 0; i--) 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 //Collect floor sprites to draw
SectIterator it(i); 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; 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); auto mesh = sectorGeometry.get(i, 0);
vertices.Resize(mesh->vertices.Size()); vertices.Resize(mesh->vertices.Size());
for (unsigned j = 0; j < mesh->vertices.Size(); j++) 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); 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 }; 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); int translation = TRANSLATION(Translation_Remap + curbasepal, sector[i].floorpal);
setgotpic(picnum); setgotpic(picnum);
@ -616,6 +617,7 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang)
vertices.Resize(4); vertices.Resize(4);
for (auto sn : floorsprites) for (auto sn : floorsprites)
{ {
if (!gFullMap && !show2dsprite[sn]) continue;
auto spr = &sprite[sn]; auto spr = &sprite[sn];
vec2_t pp[4]; vec2_t pp[4];
GetFlatSpritePosition(spr, spr->pos.vec2, pp, true); GetFlatSpritePosition(spr, spr->pos.vec2, pp, true);

View file

@ -453,6 +453,8 @@ void BunchDrawer::ProcessSector(int sectnum)
} }
SetupSprite.Unclock(); SetupSprite.Unclock();
if (automapping)
show2dsector.Set(sectnum);
SetupFlat.Clock(); SetupFlat.Clock();
HWFlat flat; HWFlat flat;

View file

@ -37,7 +37,6 @@ private:
CL_Pass = 2, CL_Pass = 2,
}; };
void StartScene(); void StartScene();
void StartBunch(int sectnum, int linenum, binangle startan, binangle endan); void StartBunch(int sectnum, int linenum, binangle startan, binangle endan);
void AddLineToBunch(int line, binangle newan); void AddLineToBunch(int line, binangle newan);
@ -53,4 +52,5 @@ private:
public: public:
void Init(HWDrawInfo* _di, Clipper* c, vec2_t& view); void Init(HWDrawInfo* _di, Clipper* c, vec2_t& view);
void RenderScene(const int* viewsectors, unsigned sectcount); void RenderScene(const int* viewsectors, unsigned sectcount);
const FixedBitArray<MAXSECTORS>& GotSector() const { return gotsector; }
}; };

View file

@ -40,6 +40,7 @@
#include "v_draw.h" #include "v_draw.h"
#include "gamecvars.h" #include "gamecvars.h"
#include "gamestruct.h" #include "gamestruct.h"
#include "automap.h"
EXTERN_CVAR(Float, r_visibility) EXTERN_CVAR(Float, r_visibility)
CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE) 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_threshold, 0.5f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, gl_mask_sprite_threshold, 0.5f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
FixedBitArray<MAXSECTORS> gotsector;
//========================================================================== //==========================================================================
// //
// //
@ -281,6 +284,9 @@ void HWDrawInfo::DispatchSprites()
if (spritenum < 0 || (unsigned)tilenum >= MAXTILES) if (spritenum < 0 || (unsigned)tilenum >= MAXTILES)
continue; continue;
if (automapping == 1 && (unsigned)spritenum < MAXSPRITES)
show2dsprite.Set(spritenum);
setgotpic(tilenum); setgotpic(tilenum);
while (!(spriteext[spritenum].flags & SPREXT_NOTMD)) while (!(spriteext[spritenum].flags & SPREXT_NOTMD))
@ -648,4 +654,8 @@ void HWDrawInfo::ProcessScene(bool toscreen)
{ {
portalState.BeginScene(); portalState.BeginScene();
DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN); 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.
}
} }

View file

@ -725,7 +725,7 @@ void viewDrawScreen(bool sceneonly)
int nXSprite = pSprite->extra; int nXSprite = pSprite->extra;
assert(nXSprite > 0 && nXSprite < kMaxXSprites); assert(nXSprite > 0 && nXSprite < kMaxXSprites);
XSPRITE* pXSprite = &xsprite[nXSprite]; XSPRITE* pXSprite = &xsprite[nXSprite];
if (TestBitString(gotsector, pSprite->sectnum)) if (gotsector[pSprite->sectnum])
{ {
brightness += pXSprite->data3 * 32; brightness += pXSprite->data3 * 32;
} }
@ -739,7 +739,7 @@ void viewDrawScreen(bool sceneonly)
case kMissileTeslaAlt: case kMissileTeslaAlt:
case kMissileFlareAlt: case kMissileFlareAlt:
case kMissileTeslaRegular: case kMissileTeslaRegular:
if (TestBitString(gotsector, pSprite->sectnum)) brightness += 256; if (gotsector[pSprite->sectnum]) brightness += 256;
break; break;
} }
} }

View file

@ -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.
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -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) while ((i = it.NextIndex()) >= 0)
{ {
// manually set gotpic // manually set gotpic
if (TEST_GOTSECTOR(sprite[i].sectnum)) if (gotsector[sprite[i].sectnum])
{ {
SET_GOTPIC(FAF_MIRROR_PIC); SET_GOTPIC(FAF_MIRROR_PIC);
} }

View file

@ -1446,12 +1446,6 @@ void RestorePortalState()
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE); StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((i = it.NextIndex()) >= 0) while ((i = it.NextIndex()) >= 0)
{ {
// manually set gotpic
if (TEST_GOTSECTOR(sprite[i].sectnum))
{
SET_GOTPIC(FAF_MIRROR_PIC);
}
if (SPRITE_TAG3(i) == 0) if (SPRITE_TAG3(i) == 0)
{ {
// restore ceilingpicnum and ceilingstat // restore ceilingpicnum and ceilingstat
@ -1794,7 +1788,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
x1 = sprx - cposx; x1 = sprx - cposx;
y1 = spry - cposy; 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; daang = ((!SyncInput() ? spr->ang : spr->interpolatedang(smoothratio)) - cang) & 2047;

View file

@ -355,10 +355,6 @@ inline int SPRITEp_SIZE_BOS(const spritetype* sp)
// just determine if the player is moving // just determine if the player is moving
#define PLAYER_MOVING(pp) ((pp)->xvect|(pp)->yvect) #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 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 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))) #define SET_GOTPIC(tile_num) (SET(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7)))