- migrated SW's portal setup code to texture IDs.

This commit is contained in:
Christoph Oelckers 2022-12-06 11:11:50 +01:00
parent fe3a32d692
commit e5225e98e0
9 changed files with 60 additions and 34 deletions

View file

@ -525,7 +525,7 @@ int testpointinquad(const DVector2& pt, const DVector2* quad)
double intersectSprite(DCoreActor* actor, const DVector3& start, const DVector3& direction, DVector3& result, double maxfactor)
{
auto end = start + direction;
if (direction.isZero()) return false;
if (direction.XY().isZero()) return false;
// get point on trace that is closest to the sprite
double factor = NearestPointOnLineFast(actor->spr.pos.X, actor->spr.pos.Y, start.X, start.Y, end.X, end.Y);

View file

@ -440,8 +440,10 @@ struct sectortype
int getfloorslope() const { return floorstat & CSTAT_SECTOR_SLOPE ? floorheinum : 0; }
int getceilingslope() const { return ceilingstat & CSTAT_SECTOR_SLOPE ? ceilingheinum : 0; }
FTextureID ceilingtexture() const;
FTextureID floortexture() const;
const FTextureID ceilingtexture() const;
const FTextureID floortexture() const;
void setfloortexture(FTextureID tex);
void setceilingtexture(FTextureID tex);
Blood::XSECTOR& xs() const { return *_xs; }

View file

@ -704,13 +704,13 @@ FTextureID walltype::overtexture() const
return tex ? tex->GetID() : FNullTextureID();
}
FTextureID sectortype::ceilingtexture() const
const FTextureID sectortype::ceilingtexture() const
{
auto tex = tileGetTexture(ceilingpicnum);
return tex ? tex->GetID() : FNullTextureID();
}
FTextureID sectortype::floortexture() const
const FTextureID sectortype::floortexture() const
{
auto tex = tileGetTexture(floorpicnum);
return tex ? tex->GetID() : FNullTextureID();
@ -721,3 +721,15 @@ FTextureID spritetypebase::spritetexture() const
auto tex = tileGetTexture(picnum);
return tex ? tex->GetID() : FNullTextureID();
}
void sectortype::setfloortexture(FTextureID tex)
{
auto p = TileFiles.textotile.CheckKey(tex.GetIndex());
if (p) floorpicnum = *p;
}
void sectortype::setceilingtexture(FTextureID tex)
{
auto p = TileFiles.textotile.CheckKey(tex.GetIndex());
if (p) ceilingpicnum = *p;
}

View file

@ -247,7 +247,7 @@ void CopySectorMatch(int match)
dsectp->extra = ssectp->extra;
dsectp->visibility = ssectp->visibility;
if (ssectp->floorpicnum == FAF_MIRROR_PIC || ssectp->ceilingpicnum == FAF_MIRROR_PIC)
if (ssectp->floortexture() == FAFMirrorPic[0] || ssectp->ceilingtexture() == FAFMirrorPic[0])
{
CollectPortals(); // unavoidable. Since these portals are not static we have to reinitialize all of them.
}

View file

@ -227,13 +227,28 @@ void GameInterface::LoadGameTextures()
void GameInterface::SetupSpecialTextures()
{
enum
{
FAF_PLACE_MIRROR_PIC = 341,
FAF_MIRROR_PIC = 2356
};
tileDelete(MIRROR); // mirror
for (int i = 0; i < MAXMIRRORS; i++)
{
tileDelete(i + MIRRORLABEL);
TileFiles.MakeCanvas(CAMSPRITE + i, 128, 114);
}
// make these two unique, they are empty by default.
tileDelete(FAF_MIRROR_PIC);
tileDelete(FAF_MIRROR_PIC + 1);
TileFiles.lock();
// these are frequently checked markers.
FAFPlaceMirrorPic[0] = tileGetTextureID(FAF_PLACE_MIRROR_PIC);
FAFPlaceMirrorPic[1] = tileGetTextureID(FAF_PLACE_MIRROR_PIC + 1);
FAFMirrorPic[0] = tileGetTextureID(FAF_MIRROR_PIC);
FAFMirrorPic[1] = tileGetTextureID(FAF_MIRROR_PIC + 1);
}
//---------------------------------------------------------------------------
//

View file

@ -1455,20 +1455,17 @@ void CollectPortals();
int SpawnBlood(DSWActor* actor, DSWActor* weapActor, DAngle hit_angle = nullAngle, const DVector3* hitpos = nullptr);
enum
{
FAF_PLACE_MIRROR_PIC = 341,
FAF_MIRROR_PIC = 2356
};
inline FTextureID FAFPlaceMirrorPic[2];
inline FTextureID FAFMirrorPic[2];
inline bool FAF_ConnectCeiling(sectortype* sect)
{
return (sect && sect->ceilingpicnum == FAF_MIRROR_PIC);
return (sect && sect->ceilingtexture() == FAFMirrorPic[0]);
}
inline bool FAF_ConnectFloor(sectortype* sect)
{
return (sect && sect->floorpicnum == FAF_MIRROR_PIC);
return (sect && sect->floortexture() == FAFMirrorPic[0]);
}
inline bool FAF_ConnectArea(sectortype* sect)

View file

@ -628,23 +628,23 @@ void SetupMirrorTiles(void)
SWStatIterator it(STAT_FAF);
while (auto actor = it.Next())
{
if (actor->sector()->ceilingpicnum == FAF_PLACE_MIRROR_PIC)
if (actor->sector()->ceilingtexture() == FAFPlaceMirrorPic[0])
{
actor->sector()->ceilingpicnum = FAF_MIRROR_PIC;
actor->sector()->setceilingtexture(FAFMirrorPic[0]);
actor->sector()->ceilingstat |= (CSTAT_SECTOR_SKY);
}
if (actor->sector()->floorpicnum == FAF_PLACE_MIRROR_PIC)
if (actor->sector()->floortexture() == FAFPlaceMirrorPic[0])
{
actor->sector()->floorpicnum = FAF_MIRROR_PIC;
actor->sector()->setfloortexture(FAFMirrorPic[0]);
actor->sector()->floorstat |= (CSTAT_SECTOR_SKY);
}
if (actor->sector()->ceilingpicnum == FAF_PLACE_MIRROR_PIC+1)
actor->sector()->ceilingpicnum = FAF_MIRROR_PIC+1;
if (actor->sector()->ceilingtexture() == FAFPlaceMirrorPic[1])
actor->sector()->setceilingtexture(FAFMirrorPic[1]);
if (actor->sector()->floorpicnum == FAF_PLACE_MIRROR_PIC+1)
actor->sector()->floorpicnum = FAF_MIRROR_PIC+1;
if (actor->sector()->floortexture() == FAFPlaceMirrorPic[1])
actor->sector()->setfloortexture(FAFMirrorPic[1]);
}
}
@ -908,7 +908,7 @@ void CollectPortals()
for (unsigned i = 0; i < sector.Size(); i++)
{
if (sector[i].floorpicnum == FAF_MIRROR_PIC && !floordone[i])
if (sector[i].floortexture() == FAFMirrorPic[0] && !floordone[i])
{
auto& fp = floorportals[floorportals.Reserve(1)];
fp.sectors.Push(i);
@ -920,13 +920,13 @@ void CollectPortals()
if (!wal.twoSided()) continue;
auto nsec = wal.nextSector();
auto ns = sectindex(nsec);
if (floordone[ns] || nsec->floorpicnum != FAF_MIRROR_PIC) continue;
if (floordone[ns] || nsec->floortexture() != FAFMirrorPic[0]) continue;
fp.sectors.Push(ns);
floordone.Set(ns);
}
}
}
if (sector[i].ceilingpicnum == FAF_MIRROR_PIC && !ceilingdone[i])
if (sector[i].ceilingtexture() == FAFMirrorPic[0] && !ceilingdone[i])
{
auto& fp = ceilingportals[ceilingportals.Reserve(1)];
fp.sectors.Push(i);
@ -938,7 +938,7 @@ void CollectPortals()
if (!wal.twoSided()) continue;
auto nsec = wal.nextSector();
auto ns = sectindex(nsec);
if (ceilingdone[ns] || nsec->ceilingpicnum != FAF_MIRROR_PIC) continue;
if (ceilingdone[ns] || nsec->ceilingtexture() != FAFMirrorPic[0]) continue;
fp.sectors.Push(ns);
ceilingdone.Set(ns);
}
@ -961,7 +961,7 @@ void CollectPortals()
if (match != -1)
{
FindCeilingView(match, &tpos.X, &tpos.Y, tpos.Z, &tsect);
if (tsect != nullptr &&tsect->floorpicnum == FAF_MIRROR_PIC)
if (tsect != nullptr &&tsect->floortexture() == FAFMirrorPic[0])
{
// got something!
fp.othersector = sectindex(tsect);
@ -988,7 +988,7 @@ void CollectPortals()
if (match != -1)
{
FindFloorView(match, &tpos.X, &tpos.Y, tpos.Z, &tsect);
if (tsect != nullptr && tsect->ceilingpicnum == FAF_MIRROR_PIC)
if (tsect != nullptr && tsect->ceilingtexture() == FAFMirrorPic[0])
{
// got something!
fp.othersector = sectindex(tsect);

View file

@ -191,11 +191,11 @@ void WallSetup(void)
for (auto& wal : wall)
{
if (wal.wallpicnum == FAF_PLACE_MIRROR_PIC)
wal.wallpicnum = FAF_MIRROR_PIC;
if (wal.walltexture() == FAFPlaceMirrorPic[0])
wal.setwalltexture(FAFMirrorPic[0]);
if (wal.wallpicnum == FAF_PLACE_MIRROR_PIC+1)
wal.wallpicnum = FAF_MIRROR_PIC+1;
if (wal.walltexture() == FAFPlaceMirrorPic[1])
wal.setwalltexture(FAFMirrorPic[1]);
// this overwrites the lotag so it needs to be called LAST - its down there
// SetupWallForBreak(wp);
@ -453,7 +453,7 @@ void SectorSetup(void)
if ((sectp->floorstat & CSTAT_SECTOR_SKY))
{
// don't do a z adjust for FAF area
if (sectp->floorpicnum != FAF_PLACE_MIRROR_PIC)
if (sectp->floortexture() != FAFPlaceMirrorPic[0])
{
sectp->extra |= (SECTFX_Z_ADJUST);
}
@ -462,7 +462,7 @@ void SectorSetup(void)
if ((sectp->ceilingstat & CSTAT_SECTOR_SKY))
{
// don't do a z adjust for FAF area
if (sectp->ceilingpicnum != FAF_PLACE_MIRROR_PIC)
if (sectp->ceilingtexture() != FAFPlaceMirrorPic[0])
{
sectp->extra |= (SECTFX_Z_ADJUST);
}

View file

@ -4346,7 +4346,7 @@ bool WeaponMoveHit(DSWActor* actor)
}
}
if ((sectp->ceilingstat & CSTAT_SECTOR_SKY) && sectp->ceilingpicnum != FAF_MIRROR_PIC)
if ((sectp->ceilingstat & CSTAT_SECTOR_SKY) && sectp->ceilingtexture() != FAFMirrorPic[0])
{
if (abs(actor->spr.pos.Z - sectp->ceilingz) < ActorSizeZ(actor))
{