mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- use wallsofsector in 4 more places.
# Conflicts: # source/build/src/polymost.cpp
This commit is contained in:
parent
588f88c9cc
commit
a2e280e188
5 changed files with 38 additions and 50 deletions
|
@ -2606,28 +2606,29 @@ void polymost_completeMirror()
|
|||
|
||||
static inline int32_t polymost_findwall(tspritetype const * const tspr, vec2_t const * const tsiz, int32_t * rd)
|
||||
{
|
||||
int32_t dist = 4, closest = -1;
|
||||
int32_t dist = 4;
|
||||
auto const sect = tspr->sector();
|
||||
vec2_t n;
|
||||
walltype* closest = nullptr;
|
||||
|
||||
for (intptr_t i=sect->wallptr; i<sect->wallptr + sect->wallnum; i++)
|
||||
for(auto& wal : wallsofsector(sect))
|
||||
{
|
||||
if ((wall[i].nextsector == -1 || ((sector[wall[i].nextsector].ceilingz > (tspr->z - ((tsiz->y * tspr->yrepeat) << 2))) ||
|
||||
sector[wall[i].nextsector].floorz < tspr->z)) && !polymost_getclosestpointonwall((const vec2_t *) tspr, i, &n))
|
||||
if ((!wal.twoSided() || ((wal.nextSector()->ceilingz > (tspr->z - ((tsiz->y * tspr->yrepeat) << 2))) ||
|
||||
wal.nextSector()->floorz < tspr->z)) && !polymost_getclosestpointonwall((const vec2_t *) tspr, wallnum(&wal), &n))
|
||||
{
|
||||
int const dst = abs(tspr->x - n.x) + abs(tspr->y - n.y);
|
||||
|
||||
if (dst <= dist)
|
||||
{
|
||||
dist = dst;
|
||||
closest = i;
|
||||
closest = &wal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*rd = dist;
|
||||
|
||||
return closest;
|
||||
return closest? wallnum(closest) : -1;
|
||||
}
|
||||
|
||||
static int32_t polymost_lintersect(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
|
|
|
@ -419,33 +419,26 @@ void drawredlines(int cposx, int cposy, int czoom, int cang)
|
|||
{
|
||||
if (!gFullMap && !show2dsector[i]) continue;
|
||||
|
||||
int startwall = sector[i].wallptr;
|
||||
int endwall = sector[i].wallptr + sector[i].wallnum;
|
||||
|
||||
int z1 = sector[i].ceilingz;
|
||||
int z2 = sector[i].floorz;
|
||||
walltype* wal;
|
||||
int j;
|
||||
|
||||
for (j = startwall, wal = &wall[startwall]; j < endwall; j++, wal++)
|
||||
for (auto& wal : wallsofsector(i))
|
||||
{
|
||||
int k = wal->nextwall;
|
||||
if (k < 0 || k >= numwalls) continue;
|
||||
if (!wal.twoSided()) continue;
|
||||
|
||||
int s = wal->nextsector;
|
||||
if (s < 0 || s >= numsectors) continue;
|
||||
auto osec = wal.nextSector();
|
||||
|
||||
if (sector[s].ceilingz == z1 && sector[s].floorz == z2)
|
||||
if (((wal->cstat | wal->nextWall()->cstat) & (16 + 32)) == 0) continue;
|
||||
if (osec->ceilingz == z1 && osec->floorz == z2)
|
||||
if (((wal.cstat | wal.nextWall()->cstat) & (16 + 32)) == 0) continue;
|
||||
|
||||
if (ShowRedLine(j, i))
|
||||
if (ShowRedLine(wallnum(&wal), i))
|
||||
{
|
||||
int ox = wal->x - cposx;
|
||||
int oy = wal->y - cposy;
|
||||
int ox = wal.x - cposx;
|
||||
int oy = wal.y - cposy;
|
||||
int x1 = DMulScale(ox, xvect, -oy, yvect, 16) + (width << 11);
|
||||
int y1 = DMulScale(oy, xvect, ox, yvect, 16) + (height << 11);
|
||||
|
||||
auto wal2 = wal->point2Wall();
|
||||
auto wal2 = wal.point2Wall();
|
||||
ox = wal2->x - cposx;
|
||||
oy = wal2->y - cposy;
|
||||
int x2 = DMulScale(ox, xvect, -oy, yvect, 16) + (width << 11);
|
||||
|
@ -474,26 +467,20 @@ static void drawwhitelines(int cposx, int cposy, int czoom, int cang)
|
|||
{
|
||||
if (!gFullMap && !show2dsector[i] && !isSWALL()) continue;
|
||||
|
||||
int startwall = sector[i].wallptr;
|
||||
int endwall = sector[i].wallptr + sector[i].wallnum;
|
||||
|
||||
walltype* wal;
|
||||
int j;
|
||||
|
||||
for (j = startwall, wal = &wall[startwall]; j < endwall; j++, wal++)
|
||||
for (auto& wal : wallsofsector(i))
|
||||
{
|
||||
if (wal->nextwall >= 0) continue;
|
||||
if (!gFullMap && !tileGetTexture(wal->picnum)->isValid()) continue;
|
||||
if (wal.nextwall >= 0) continue;
|
||||
if (!gFullMap && !tileGetTexture(wal.picnum)->isValid()) continue;
|
||||
|
||||
if (isSWALL() && !gFullMap && !show2dwall[j])
|
||||
if (isSWALL() && !gFullMap && !show2dwall[wallnum(&wal)])
|
||||
continue;
|
||||
|
||||
int ox = wal->x - cposx;
|
||||
int oy = wal->y - cposy;
|
||||
int ox = wal.x - cposx;
|
||||
int oy = wal.y - cposy;
|
||||
int x1 = DMulScale(ox, xvect, -oy, yvect, 16) + (width << 11);
|
||||
int y1 = DMulScale(oy, xvect, ox, yvect, 16) + (height << 11);
|
||||
|
||||
int k = wal->point2;
|
||||
int k = wal.point2;
|
||||
auto wal2 = &wall[k];
|
||||
ox = wal2->x - cposx;
|
||||
oy = wal2->y - cposy;
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
struct SectionLine
|
||||
{
|
||||
int16_t section;
|
||||
int16_t partnersection;
|
||||
int16_t startpoint;
|
||||
int16_t endpoint;
|
||||
int16_t wall;
|
||||
int16_t partner;
|
||||
int16_t point2index;
|
||||
int section;
|
||||
int partnersection;
|
||||
int startpoint;
|
||||
int endpoint;
|
||||
int wall;
|
||||
int partner;
|
||||
int point2index;
|
||||
};
|
||||
|
||||
struct Section
|
||||
|
|
|
@ -481,7 +481,7 @@ int HWLinePortal::ClipSector(sectortype *sub)
|
|||
// this seg is completely behind the mirror
|
||||
for (int i = 0; i<sub->wallnum; i++)
|
||||
{
|
||||
if (PointOnLineSide(WallStart(&wall[sub->wallptr]), line) == 0) return PClip_Inside;
|
||||
if (PointOnLineSide(WallStart(sub->firstWall()), line) == 0) return PClip_Inside;
|
||||
}
|
||||
return PClip_InFront;
|
||||
}
|
||||
|
|
|
@ -109,27 +109,27 @@ static int GetClosestPointOnWall(tspritetype* spr, walltype* wal, vec2_t* const
|
|||
|
||||
static int IsOnWall(tspritetype* tspr, int height)
|
||||
{
|
||||
int dist = 3, closest = -1;
|
||||
int dist = 3;
|
||||
auto sect = tspr->sector();
|
||||
vec2_t n;
|
||||
walltype* closest = nullptr;
|
||||
|
||||
int topz = (tspr->z - ((height * tspr->yrepeat) << 2));
|
||||
for (int i = sect->wallptr; i < sect->wallptr + sect->wallnum; i++)
|
||||
for(auto& wal : wallsofsector(sect))
|
||||
{
|
||||
auto wal = &wall[i];
|
||||
if ((wal->nextsector == -1 || ((wal->nextSector()->ceilingz > topz) ||
|
||||
wal->nextSector()->floorz < tspr->z)) && !GetClosestPointOnWall(tspr, wal, &n))
|
||||
if ((wal.nextsector == -1 || ((wal.nextSector()->ceilingz > topz) ||
|
||||
wal.nextSector()->floorz < tspr->z)) && !GetClosestPointOnWall(tspr, &wal, &n))
|
||||
{
|
||||
int const dst = abs(tspr->x - n.x) + abs(tspr->y - n.y);
|
||||
|
||||
if (dst <= dist)
|
||||
{
|
||||
dist = dst;
|
||||
closest = i;
|
||||
closest = &wal;
|
||||
}
|
||||
}
|
||||
}
|
||||
return closest == -1? -1 : dist;
|
||||
return closest == nullptr? -1 : dist;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
Loading…
Reference in a new issue