- use point2Wall wherever possible.

This commit is contained in:
Christoph Oelckers 2021-12-02 00:54:11 +01:00
parent 83cf2f3baf
commit f9b1164747
7 changed files with 29 additions and 29 deletions

View file

@ -111,7 +111,7 @@ int clipinsidebox(vec2_t *vect, int wallnum, int walldist)
int const r = walldist << 1; int const r = walldist << 1;
auto const wal1 = (uwallptr_t)&wall[wallnum]; 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 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 }; 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) if (k >= 0)
{ {
vec2_t const v1 = wall[j].pos; 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) || 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)) (v1.y < ymin && (v2.y < ymin)) || (v1.y > ymax && v2.y > ymax))

View file

@ -104,7 +104,7 @@ ADD_STAT(printcoords)
static void getclosestpointonwall_internal(vec2_t const p, int32_t const dawall, vec2_t *const closest) 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 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 }; 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); int64_t i = d.x * ((int64_t)p.x - w.x) + d.y * ((int64_t)p.y - w.y);

View file

@ -1000,8 +1000,8 @@ static void polymost_internal_nonparallaxed(FVector2 n0, FVector2 n1, float ryp0
if (globalorientation & 64) if (globalorientation & 64)
{ {
//relative alignment //relative alignment
vec2_t const xy = { wall[sec->firstWall()->point2].x - sec->firstWall()->x, vec2_t const xy = sec->firstWall()->delta();
wall[sec->firstWall()->point2].y - sec->firstWall()->y };
float r; float r;
int length = ksqrt(uhypsq(xy.x, xy.y)); 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) int32_t wallfront(int32_t l1, int32_t l2)
{ {
vec2_t const l1vect = wall[thewall[l1]].pos; 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 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 }; 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 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 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, 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) 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 x = wall[dawall].x, dx = wall[dawall].point2Wall()->x - x;
const int32_t y = wall[dawall].y, dy = wall[wall[dawall].point2].y - y; const int32_t y = wall[dawall].y, dy = wall[dawall].point2Wall()->y - y;
const int32_t j = dx * dx + dy * dy; const int32_t j = dx * dx + dy * dy;
if (j == 0) if (j == 0)
@ -3649,7 +3649,7 @@ void renderDrawMasks(void)
maskwallcnt--; maskwallcnt--;
FVector2 dot = { (float)wall[w].x, (float)wall[w].y }; 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 }; FVector2 middle = { (dot.X + dot2.X) * .5f, (dot.Y + dot2.Y) * .5f };
_equation maskeq = equation(dot.X, dot.Y, dot2.X, dot2.Y); _equation maskeq = equation(dot.X, dot.Y, dot2.X, dot2.Y);

View file

@ -143,12 +143,12 @@ inline double WallStartY(int wallnum)
inline double WallEndX(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) 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) inline double WallStartX(const walltype* wallnum)
@ -168,12 +168,12 @@ inline DVector2 WallStart(const walltype* wallnum)
inline double WallEndX(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) 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) inline DVector2 WallEnd(const walltype* wallnum)

View file

@ -526,8 +526,8 @@ bool HWMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe
int x = line->x; int x = line->x;
int y = line->y; int y = line->y;
int dx = wall[line->point2].x - x; int dx = line->point2Wall()->x - x;
int dy = wall[line->point2].y - y; int dy = line->point2Wall()->y - y;
// this can overflow so use 64 bit math. // this can overflow so use 64 bit math.
const int64_t j = int64_t(dx) * dx + int64_t(dy) * dy; 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); ClearClipper(di, clipper);
auto startan = bvectangbam(line->x - newx, line->y - newy); 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. clipper->RestrictVisibleRange(endan, startan); // we check the line from the backside so angles are reversed.
return true; return true;
} }
@ -608,10 +608,10 @@ bool HWLineToLinePortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *cl
DVector2 npos = vp.Pos - srccenter + destcenter; DVector2 npos = vp.Pos - srccenter + destcenter;
#if 0 // Blood does not rotate these. Needs map checking to make sure it can be added. #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 dx = origin->point2Wall()->x - origin->x;
int dy = wall[origin->point2].y - origin->y; int dy = origin->point2Wall()->y - origin->y;
int dx2 = wall[line->point2].x - line->x; int dx2 = line->point2Wall()->x - line->x;
int dy2 = wall[line->point2].y - line->y; int dy2 = line->point2Wall()->y - line->y;
auto srcang = bvectangbam(dx, dy); auto srcang = bvectangbam(dx, dy);
auto destang = bvectangbam(-dx, -dy); auto destang = bvectangbam(-dx, -dy);
@ -635,7 +635,7 @@ bool HWLineToLinePortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *cl
ClearClipper(di, clipper); ClearClipper(di, clipper);
auto startan = bvectangbam(origin->x - origx, origin->y - origy); 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); clipper->RestrictVisibleRange(startan, endan);
return true; return true;
} }
@ -687,7 +687,7 @@ bool HWLineToSpritePortal::Setup(HWDrawInfo* di, FRenderState& rstate, Clipper*
ClearClipper(di, clipper); ClearClipper(di, clipper);
auto startan = bvectangbam(origin->x - origx, origin->y - origy); 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); clipper->RestrictVisibleRange(startan, endan);
return true; return true;
} }

View file

@ -244,7 +244,7 @@ protected:
{ {
this->line = line; this->line = line;
//v1 = &line->pos; //v1 = &line->pos;
//v2 = &wall[line->point2].pos; //v2 = &line->point2Wall()->pos;
//CalcDelta(); //CalcDelta();
} }

View file

@ -118,8 +118,8 @@ public:
auto firstwall = sec->firstWall(); auto firstwall = sec->firstWall();
ix1 = firstwall->x; ix1 = firstwall->x;
iy1 = firstwall->y; iy1 = firstwall->y;
ix2 = wall[firstwall->point2].x; ix2 = firstwall->point2Wall()->x;
iy2 = wall[firstwall->point2].y; iy2 = firstwall->point2Wall()->y;
if (plane == 0) if (plane == 0)
{ {
@ -555,7 +555,7 @@ void SectorGeometry::ValidateSector(unsigned int secnum, int plane, const FVecto
sec->floorxpan_ == compare->floorxpan_ && sec->floorxpan_ == compare->floorxpan_ &&
sec->floorypan_ == compare->floorypan_ && sec->floorypan_ == compare->floorypan_ &&
sec->firstWall()->pos == data[secnum].poscompare[0] && 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) && data[secnum].planes[plane].vertices.Size() ) return;
sec->dirty &= ~1; sec->dirty &= ~1;
@ -568,14 +568,14 @@ void SectorGeometry::ValidateSector(unsigned int secnum, int plane, const FVecto
sec->ceilingxpan_ == compare->ceilingxpan_ && sec->ceilingxpan_ == compare->ceilingxpan_ &&
sec->ceilingypan_ == compare->ceilingypan_ && sec->ceilingypan_ == compare->ceilingypan_ &&
sec->firstWall()->pos == data[secnum].poscompare[1] && 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) && data[secnum].planes[1].vertices.Size()) return;
sec->dirty &= ~2; sec->dirty &= ~2;
} }
*compare = *sec; *compare = *sec;
data[secnum].poscompare[plane] = sec->firstWall()->pos; 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)) if (data[secnum].degenerate || !MakeVertices(secnum, plane, offset))
{ {
data[secnum].degenerate = true; data[secnum].degenerate = true;