From f9b11647471ab5eb9fc4bf040c3b654978a6f7cb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 2 Dec 2021 00:54:11 +0100 Subject: [PATCH] - use point2Wall wherever possible. --- source/build/src/clip.cpp | 4 ++-- source/build/src/engine.cpp | 2 +- source/build/src/polymost.cpp | 14 +++++++------- source/core/gamefuncs.h | 8 ++++---- source/core/rendering/scene/hw_portal.cpp | 18 +++++++++--------- source/core/rendering/scene/hw_portal.h | 2 +- source/core/sectorgeometry.cpp | 10 +++++----- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 9bafd976b..d92d59c79 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -111,7 +111,7 @@ int clipinsidebox(vec2_t *vect, int wallnum, int walldist) int const r = walldist << 1; auto const wal1 = (uwallptr_t)&wall[wallnum]; - auto const wal2 = (uwallptr_t)&wall[wal1->point2]; + auto const wal2 = (uwallptr_t)wal1->point2Wall(); vec2_t const v1 = { wal1->x + walldist - vect->x, wal1->y + walldist - vect->y }; vec2_t v2 = { wal2->x + walldist - vect->x, wal2->y + walldist - vect->y }; @@ -986,7 +986,7 @@ void getzrange_(const vec3_t *pos, int16_t sectnum, if (k >= 0) { vec2_t const v1 = wall[j].pos; - vec2_t const v2 = wall[wall[j].point2].pos; + vec2_t const v2 = wall[j].point2Wall()->pos; if ((v1.x < xmin && (v2.x < xmin)) || (v1.x > xmax && v2.x > xmax) || (v1.y < ymin && (v2.y < ymin)) || (v1.y > ymax && v2.y > ymax)) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index b54c38864..469ee0893 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -104,7 +104,7 @@ ADD_STAT(printcoords) static void getclosestpointonwall_internal(vec2_t const p, int32_t const dawall, vec2_t *const closest) { vec2_t const w = wall[dawall].pos; - vec2_t const w2 = wall[wall[dawall].point2].pos; + vec2_t const w2 = wall[dawall].point2Wall()->pos; vec2_t const d = { w2.x - w.x, w2.y - w.y }; int64_t i = d.x * ((int64_t)p.x - w.x) + d.y * ((int64_t)p.y - w.y); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 4a4c7c479..015ee97cf 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -1000,8 +1000,8 @@ static void polymost_internal_nonparallaxed(FVector2 n0, FVector2 n1, float ryp0 if (globalorientation & 64) { //relative alignment - vec2_t const xy = { wall[sec->firstWall()->point2].x - sec->firstWall()->x, - wall[sec->firstWall()->point2].y - sec->firstWall()->y }; + vec2_t const xy = sec->firstWall()->delta(); + float r; int length = ksqrt(uhypsq(xy.x, xy.y)); @@ -1844,9 +1844,9 @@ static void polymost_drawalls(int32_t const bunch) int32_t wallfront(int32_t l1, int32_t l2) { vec2_t const l1vect = wall[thewall[l1]].pos; - vec2_t const l1p2vect = wall[wall[thewall[l1]].point2].pos; + vec2_t const l1p2vect = wall[thewall[l1]].point2Wall()->pos; vec2_t const l2vect = wall[thewall[l2]].pos; - vec2_t const l2p2vect = wall[wall[thewall[l2]].point2].pos; + vec2_t const l2p2vect = wall[thewall[l2]].point2Wall()->pos; vec2_t d = { l1p2vect.x - l1vect.x, l1p2vect.y - l1vect.y }; int32_t t1 = DMulScale(l2vect.x - l1vect.x, d.y, -d.x, l2vect.y - l1vect.y, 2); //p1(l2) vs. l1 int32_t t2 = DMulScale(l2p2vect.x - l1vect.x, d.y, -d.x, l2p2vect.y - l1vect.y, 2); //p2(l2) vs. l1 @@ -3269,8 +3269,8 @@ static_assert((int)RS_YFLIP == (int)HUDFLAG_FLIPPED); void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t dawall, int32_t* tposx, int32_t* tposy, fixed_t* tang) { - const int32_t x = wall[dawall].x, dx = wall[wall[dawall].point2].x - x; - const int32_t y = wall[dawall].y, dy = wall[wall[dawall].point2].y - y; + const int32_t x = wall[dawall].x, dx = wall[dawall].point2Wall()->x - x; + const int32_t y = wall[dawall].y, dy = wall[dawall].point2Wall()->y - y; const int32_t j = dx * dx + dy * dy; if (j == 0) @@ -3649,7 +3649,7 @@ void renderDrawMasks(void) maskwallcnt--; FVector2 dot = { (float)wall[w].x, (float)wall[w].y }; - FVector2 dot2 = { (float)wall[wall[w].point2].x, (float)wall[wall[w].point2].y }; + FVector2 dot2 = { (float)wall[w].point2Wall()->x, (float)wall[w].point2Wall()->y }; FVector2 middle = { (dot.X + dot2.X) * .5f, (dot.Y + dot2.Y) * .5f }; _equation maskeq = equation(dot.X, dot.Y, dot2.X, dot2.Y); diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 66cd01008..1cdf03755 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -143,12 +143,12 @@ inline double WallStartY(int wallnum) inline double WallEndX(int wallnum) { - return wall[wall[wallnum].point2].x * (1 / 16.); + return wall[wallnum].point2Wall()->x * (1 / 16.); } inline double WallEndY(int wallnum) { - return wall[wall[wallnum].point2].y * (1 / -16.); + return wall[wallnum].point2Wall()->y * (1 / -16.); } inline double WallStartX(const walltype* wallnum) @@ -168,12 +168,12 @@ inline DVector2 WallStart(const walltype* wallnum) inline double WallEndX(const walltype* wallnum) { - return wall[wallnum->point2].x * (1 / 16.); + return wallnum->point2Wall()->x * (1 / 16.); } inline double WallEndY(const walltype* wallnum) { - return wall[wallnum->point2].y * (1 / -16.); + return wallnum->point2Wall()->y * (1 / -16.); } inline DVector2 WallEnd(const walltype* wallnum) diff --git a/source/core/rendering/scene/hw_portal.cpp b/source/core/rendering/scene/hw_portal.cpp index 4151780b4..4d218a3cf 100644 --- a/source/core/rendering/scene/hw_portal.cpp +++ b/source/core/rendering/scene/hw_portal.cpp @@ -526,8 +526,8 @@ bool HWMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe int x = line->x; int y = line->y; - int dx = wall[line->point2].x - x; - int dy = wall[line->point2].y - y; + int dx = line->point2Wall()->x - x; + int dy = line->point2Wall()->y - y; // this can overflow so use 64 bit math. const int64_t j = int64_t(dx) * dx + int64_t(dy) * dy; @@ -565,7 +565,7 @@ bool HWMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe ClearClipper(di, clipper); auto startan = bvectangbam(line->x - newx, line->y - newy); - auto endan = bvectangbam(wall[line->point2].x - newx, wall[line->point2].y - newy); + auto endan = bvectangbam(line->point2Wall()->x - newx, line->point2Wall()->y - newy); clipper->RestrictVisibleRange(endan, startan); // we check the line from the backside so angles are reversed. return true; } @@ -608,10 +608,10 @@ bool HWLineToLinePortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *cl DVector2 npos = vp.Pos - srccenter + destcenter; #if 0 // Blood does not rotate these. Needs map checking to make sure it can be added. - int dx = wall[origin->point2].x - origin->x; - int dy = wall[origin->point2].y - origin->y; - int dx2 = wall[line->point2].x - line->x; - int dy2 = wall[line->point2].y - line->y; + int dx = origin->point2Wall()->x - origin->x; + int dy = origin->point2Wall()->y - origin->y; + int dx2 = line->point2Wall()->x - line->x; + int dy2 = line->point2Wall()->y - line->y; auto srcang = bvectangbam(dx, dy); auto destang = bvectangbam(-dx, -dy); @@ -635,7 +635,7 @@ bool HWLineToLinePortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *cl ClearClipper(di, clipper); auto startan = bvectangbam(origin->x - origx, origin->y - origy); - auto endan = bvectangbam(wall[origin->point2].x - origx, wall[origin->point2].y - origy); + auto endan = bvectangbam(origin->point2Wall()->x - origx, origin->point2Wall()->y - origy); clipper->RestrictVisibleRange(startan, endan); return true; } @@ -687,7 +687,7 @@ bool HWLineToSpritePortal::Setup(HWDrawInfo* di, FRenderState& rstate, Clipper* ClearClipper(di, clipper); auto startan = bvectangbam(origin->x - origx, origin->y - origy); - auto endan = bvectangbam(wall[origin->point2].x - origx, wall[origin->point2].y - origy); + auto endan = bvectangbam(origin->point2Wall()->x - origx, origin->point2Wall()->y - origy); clipper->RestrictVisibleRange(startan, endan); return true; } diff --git a/source/core/rendering/scene/hw_portal.h b/source/core/rendering/scene/hw_portal.h index 8bbc65c92..abac7575e 100644 --- a/source/core/rendering/scene/hw_portal.h +++ b/source/core/rendering/scene/hw_portal.h @@ -244,7 +244,7 @@ protected: { this->line = line; //v1 = &line->pos; - //v2 = &wall[line->point2].pos; + //v2 = &line->point2Wall()->pos; //CalcDelta(); } diff --git a/source/core/sectorgeometry.cpp b/source/core/sectorgeometry.cpp index 1969482cf..47e973c1e 100644 --- a/source/core/sectorgeometry.cpp +++ b/source/core/sectorgeometry.cpp @@ -118,8 +118,8 @@ public: auto firstwall = sec->firstWall(); ix1 = firstwall->x; iy1 = firstwall->y; - ix2 = wall[firstwall->point2].x; - iy2 = wall[firstwall->point2].y; + ix2 = firstwall->point2Wall()->x; + iy2 = firstwall->point2Wall()->y; if (plane == 0) { @@ -555,7 +555,7 @@ void SectorGeometry::ValidateSector(unsigned int secnum, int plane, const FVecto sec->floorxpan_ == compare->floorxpan_ && sec->floorypan_ == compare->floorypan_ && sec->firstWall()->pos == data[secnum].poscompare[0] && - wall[sec->firstWall()->point2].pos == data[secnum].poscompare2[0] && + sec->firstWall()->point2Wall()->pos == data[secnum].poscompare2[0] && !(sec->dirty & 1) && data[secnum].planes[plane].vertices.Size() ) return; sec->dirty &= ~1; @@ -568,14 +568,14 @@ void SectorGeometry::ValidateSector(unsigned int secnum, int plane, const FVecto sec->ceilingxpan_ == compare->ceilingxpan_ && sec->ceilingypan_ == compare->ceilingypan_ && sec->firstWall()->pos == data[secnum].poscompare[1] && - wall[sec->firstWall()->point2].pos == data[secnum].poscompare2[1] && + sec->firstWall()->point2Wall()->pos == data[secnum].poscompare2[1] && !(sec->dirty & 2) && data[secnum].planes[1].vertices.Size()) return; sec->dirty &= ~2; } *compare = *sec; data[secnum].poscompare[plane] = sec->firstWall()->pos; - data[secnum].poscompare2[plane] = wall[sec->firstWall()->point2].pos; + data[secnum].poscompare2[plane] = sec->firstWall()->point2Wall()->pos; if (data[secnum].degenerate || !MakeVertices(secnum, plane, offset)) { data[secnum].degenerate = true;