- fixed yet another problem with the local 'sprite' variables in HWWall causing problems.

This variable and its companions in HWFlat and HWSprite have now been renamed to avoid these issues.
This commit is contained in:
Christoph Oelckers 2021-05-07 00:09:30 +02:00
parent 34a5fb5a6a
commit 29b0106a96
6 changed files with 43 additions and 42 deletions

View file

@ -251,8 +251,8 @@ void HWDrawList::SortPlaneIntoPlane(SortNode * head,SortNode * sort)
if (fh->z == fs->z)
{
// Make sure we have consistent ordering with two floor sprites of the same distance if they overlap
int time1 = fh->sprite ? fh->sprite->time : -1;
int time2 = fs->sprite ? fs->sprite->time : -1;
int time1 = fh->Sprite ? fh->Sprite->time : -1;
int time2 = fs->Sprite ? fs->Sprite->time : -1;
if (time1 == time2) head->AddToEqual(sort);
else if (time2 < time1)head->AddToLeft(sort);
else head->AddToRight(sort);
@ -404,8 +404,8 @@ void HWDrawList::SortWallIntoWall(HWDrawInfo *di, SortNode * head,SortNode * sor
if (fabs(v1)<MIN_EQ && fabs(v2)<MIN_EQ)
{
int time1 = wh->sprite ? wh->sprite->time : -1;
int time2 = ws->sprite ? ws->sprite->time : -1;
int time1 = wh->Sprite ? wh->Sprite->time : -1;
int time2 = ws->Sprite ? ws->Sprite->time : -1;
if ((ws->type==RENDERWALL_FOGBOUNDARY && wh->type!=RENDERWALL_FOGBOUNDARY) || time2 < time1)
{
@ -591,7 +591,7 @@ inline int HWDrawList::CompareSprites(SortNode * a,SortNode * b)
if (s1->depth < s2->depth) return 1;
if (s1->depth > s2->depth) return -1;
return s1->sprite->time - s2->sprite->time;
return s1->Sprite->time - s2->Sprite->time;
}
//==========================================================================
@ -737,8 +737,8 @@ void HWDrawList::SortWallsVert(HWDrawInfo* di)
HWWall* w1 = walls[a.index];
HWWall* w2 = walls[b.index];
if (w1->glseg.y1 != w2->glseg.y1) return w1->glseg.y1 < w2->glseg.y1;
int time1 = w1->sprite ? w1->sprite->time : -1;
int time2 = w2->sprite ? w2->sprite->time : -1;
int time1 = w1->Sprite ? w1->Sprite->time : -1;
int time2 = w2->Sprite ? w2->Sprite->time : -1;
return time1 < time2;
});
@ -747,8 +747,8 @@ void HWDrawList::SortWallsVert(HWDrawInfo* di)
HWWall* w1 = walls[a.index];
HWWall* w2 = walls[b.index];
if (w1->glseg.y1 != w2->glseg.y1) return w1->glseg.y1 > w2->glseg.y1;
int time1 = w1->sprite ? w1->sprite->time : -1;
int time2 = w2->sprite ? w2->sprite->time : -1;
int time1 = w1->Sprite ? w1->Sprite->time : -1;
int time2 = w2->Sprite ? w2->Sprite->time : -1;
return time1 < time2;
});
@ -784,8 +784,8 @@ void HWDrawList::SortWallsHorz(HWDrawInfo* di)
HWWall* w1 = walls[a.index];
HWWall* w2 = walls[b.index];
if (w1->glseg.x1 != w2->glseg.x1) return w1->glseg.x1 < w2->glseg.x1;
int time1 = w1->sprite ? w1->sprite->time : -1;
int time2 = w2->sprite ? w2->sprite->time : -1;
int time1 = w1->Sprite ? w1->Sprite->time : -1;
int time2 = w2->Sprite ? w2->Sprite->time : -1;
return time1 < time2;
});
@ -794,8 +794,8 @@ void HWDrawList::SortWallsHorz(HWDrawInfo* di)
HWWall* w1 = walls[a.index];
HWWall* w2 = walls[b.index];
if (w1->glseg.x1 != w2->glseg.x1) return w1->glseg.x1 > w2->glseg.x1;
int time1 = w1->sprite ? w1->sprite->time : -1;
int time2 = w2->sprite ? w2->sprite->time : -1;
int time1 = w1->Sprite ? w1->Sprite->time : -1;
int time2 = w2->Sprite ? w2->Sprite->time : -1;
return time1 < time2;
});
@ -831,8 +831,8 @@ void HWDrawList::SortFlats(HWDrawInfo* di)
HWFlat* w1 = flats[a.index];
HWFlat* w2 = flats[b.index];
if (w1->z != w2->z) return w1->z < w2->z;
int time1 = w1->sprite ? w1->sprite->time : -1;
int time2 = w2->sprite ? w2->sprite->time : -1;
int time1 = w1->Sprite ? w1->Sprite->time : -1;
int time2 = w2->Sprite ? w2->Sprite->time : -1;
return time1 < time2;
});
@ -841,8 +841,8 @@ void HWDrawList::SortFlats(HWDrawInfo* di)
HWFlat* w1 = flats[a.index];
HWFlat* w2 = flats[b.index];
if (w1->z != w2->z) return w2->z < w1->z;
int time1 = w1->sprite ? w1->sprite->time : -1;
int time2 = w2->sprite ? w2->sprite->time : -1;
int time1 = w1->Sprite ? w1->Sprite->time : -1;
int time2 = w2->Sprite ? w2->Sprite->time : -1;
return time1 < time2;
});

View file

@ -50,7 +50,7 @@ void HWDrawInfo::AddWall(HWWall *wall)
int list;
if (wall->type != RENDERWALL_M2S) list = GLDL_PLAINWALLS;
else if (wall->sprite == nullptr) list = GLDL_MASKEDWALLS;
else if (wall->Sprite == nullptr) list = GLDL_MASKEDWALLS;
else if (wall->glseg.x1 == wall->glseg.x2) list = GLDL_MASKEDWALLSV;
else if (wall->glseg.y1 == wall->glseg.y2) list = GLDL_MASKEDWALLSH;
else list = GLDL_MASKEDWALLSS;
@ -98,11 +98,11 @@ void HWDrawInfo::AddFlat(HWFlat *flat)
if (flat->RenderStyle != LegacyRenderStyles[STYLE_Translucent] || flat->alpha < 1.f - FLT_EPSILON || checkTranslucentReplacement(flat->texture->GetID(), flat->palette))
{
// translucent portals go into the translucent border list.
list = flat->sprite? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER;
list = flat->Sprite? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER;
}
else
{
list = flat->sprite ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS;
list = flat->Sprite ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS;
}
auto newflat = drawlists[list].NewFlat();
*newflat = *flat;

View file

@ -185,7 +185,7 @@ public:
public:
walltype* seg;
spritetype* sprite;
spritetype* Sprite;
sectortype* frontsector, * backsector;
//private:
@ -251,7 +251,7 @@ class HWFlat
public:
int section;
sectortype * sec;
spritetype* sprite; // for flat sprites.
spritetype* Sprite; // for flat sprites.
FGameTexture *texture;
float z; // the z position of the flat (only valid for non-sloped planes)
@ -294,7 +294,7 @@ class HWSprite
{
public:
spritetype* sprite;
spritetype* Sprite;
PalEntry fade;
int shade, palette;
float visibility;

View file

@ -96,7 +96,7 @@ void HWFlat::MakeVertices()
{
if (vertcount > 0) return;
bool canvas = texture->isHardwareCanvas();
if (sprite == nullptr)
if (Sprite == nullptr)
{
auto mesh = sectorGeometry.get(section, plane, geoofs);
if (!mesh) return;
@ -117,12 +117,12 @@ void HWFlat::MakeVertices()
else
{
vec2_t pos[4];
GetFlatSpritePosition(sprite, sprite->pos.vec2, pos, true);
GetFlatSpritePosition(Sprite, Sprite->pos.vec2, pos, true);
auto ret = screen->mVertexData->AllocVertices(6);
auto vp = ret.first;
float x = !(sprite->cstat & CSTAT_SPRITE_XFLIP) ? 0.f : 1.f;
float y = !(sprite->cstat & CSTAT_SPRITE_YFLIP) ? 0.f : 1.f;
float x = !(Sprite->cstat & CSTAT_SPRITE_XFLIP) ? 0.f : 1.f;
float y = !(Sprite->cstat & CSTAT_SPRITE_YFLIP) ? 0.f : 1.f;
for (unsigned i = 0; i < 6; i++)
{
const static unsigned indices[] = { 0, 1, 2, 0, 2, 3 };
@ -144,7 +144,7 @@ void HWFlat::MakeVertices()
//==========================================================================
void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
{
if (screen->BuffersArePersistent() && !sprite)
if (screen->BuffersArePersistent() && !Sprite)
{
MakeVertices();
}
@ -156,7 +156,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
}
#endif
if (!sprite)
if (!Sprite)
{
auto mesh = sectorGeometry.get(section, plane, geoofs);
state.SetNormal(mesh->normal);
@ -182,7 +182,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
if (texture && !checkTranslucentReplacement(texture->GetID(), palette)) state.AlphaFunc(Alpha_GEqual, texture->alphaThreshold);
else state.AlphaFunc(Alpha_GEqual, 0.f);
}
state.SetMaterial(texture, UF_Texture, 0, sprite == nullptr? CLAMP_NONE : CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette), -1);
state.SetMaterial(texture, UF_Texture, 0, Sprite == nullptr? CLAMP_NONE : CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette), -1);
state.SetLightIndex(dynlightindex);
state.Draw(DT_Triangles, vertindex, vertcount);
@ -208,7 +208,7 @@ void HWFlat::PutFlat(HWDrawInfo *di, int whichplane)
{
vertcount = 0;
plane = whichplane;
if (!screen->BuffersArePersistent() || sprite || di->ingeo) // should be made static buffer content later (when the logic is working)
if (!screen->BuffersArePersistent() || Sprite || di->ingeo) // should be made static buffer content later (when the logic is working)
{
#if 0
if (di->Level->HasDynamicLights && texture != nullptr && !di->isFullbrightScene() && !(hacktype & (SSRF_PLANEHACK | SSRF_FLOODHACK)))
@ -250,7 +250,7 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section
visibility = sectorVisibility(frontsector);
sec = frontsector;
section = section_;
sprite = nullptr;
Sprite = nullptr;
geoofs = di->geoofs;
//
@ -352,7 +352,7 @@ void HWFlat::ProcessFlatSprite(HWDrawInfo* di, spritetype* sprite, sectortype* s
if (texture && texture->isValid())
{
this->sprite = sprite;
this->Sprite = sprite;
sec = sector;
shade = sprite->shade;
palette = sprite->pal;

View file

@ -315,7 +315,7 @@ void HWSprite::Process(HWDrawInfo* di, spritetype* spr, sectortype* sector, int
if (!tex || !tex->isValid()) return;
texture = tex;
sprite = spr;
Sprite = spr;
modelframe = 0;
dynlightindex = -1;
@ -442,7 +442,7 @@ void HWSprite::Process(HWDrawInfo* di, spritetype* spr, sectortype* sector, int
bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, spritetype* spr, sectortype* sector, bool rotate)
{
sprite = spr;
Sprite = spr;
auto sprext = &spriteext[spr->owner];
texture = nullptr;
@ -528,7 +528,7 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, spritetype* spr, se
auto vp = di->Viewpoint;
depth = (float)((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
PutSprite(di, spriteHasTranslucency(sprite));
PutSprite(di, spriteHasTranslucency(Sprite));
rendered_sprites++;
return true;
}

View file

@ -158,7 +158,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
SetLightAndFog(state, fade, palette, shade, visibility, alpha);
state.SetMaterial(texture, UF_Texture, 0, (flags & (HWF_CLAMPX | HWF_CLAMPY)), TRANSLATION(Translation_Remap + curbasepal, palette), -1);
if (sprite == nullptr)
if (Sprite == nullptr)
{
int h = (int)texture->GetDisplayHeight();
int h2 = 1 << sizeToBits(h);
@ -479,7 +479,8 @@ void HWWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
case PORTALTYPE_LINETOSPRITE:
// These are also unique.
portal = new HWLineToSpritePortal(&portalState, seg, &sprite[seg->portalnum]);
assert(seg->portalnum >= 0 && seg->portalnum < MAXSPRITES);
portal = new HWLineToSpritePortal(&portalState, seg, &::sprite[seg->portalnum]);
di->Portals.Push(portal);
portal->AddLine(this);
break;
@ -866,7 +867,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
this->seg = wal;
this->frontsector = frontsector;
this->backsector = backsector;
sprite = nullptr;
Sprite = nullptr;
vertindex = 0;
vertcount = 0;
@ -1021,7 +1022,7 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect
if (!tex || !tex->isValid()) return;
seg = nullptr;
sprite = spr;
Sprite = spr;
vec2_t pos[2];
int sprz = spr->pos.z;
@ -1053,7 +1054,7 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect
fade = lookups.getFade(sector->floorpal); // fog is per sector.
visibility = sectorVisibility(sector);
SetSpriteTranslucency(sprite, alpha, RenderStyle);
SetSpriteTranslucency(Sprite, alpha, RenderStyle);
int height, topofs;
if (hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize)
@ -1122,5 +1123,5 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect
std::swap(tcs[UPLFT], tcs[UPRGT]);
}
PutWall(di, spriteHasTranslucency(sprite));
PutWall(di, spriteHasTranslucency(Sprite));
}