From c7ae4688a3f502b894f579eee4f2b528cefbb2b7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Mar 2016 10:07:06 +0200 Subject: [PATCH] - replaced all direct access to vertex coordinates with wrapper functions. So that code replacement can be done piece by piece and not all at once. --- src/m_bbox.cpp | 8 +-- src/nodebuild_extract.cpp | 22 ++++--- src/nodebuild_utility.cpp | 49 ++++++++-------- src/p_buildmap.cpp | 5 +- src/p_enemy.cpp | 28 ++++----- src/p_glnodes.cpp | 11 ++-- src/p_map.cpp | 2 +- src/p_maputl.cpp | 18 +++--- src/p_maputl.h | 14 +++-- src/p_mobj.cpp | 4 +- src/p_sectors.cpp | 28 ++++----- src/p_setup.cpp | 107 ++++++++++++++++++----------------- src/p_sight.cpp | 4 +- src/p_slopes.cpp | 42 +++++++------- src/p_switch.cpp | 2 +- src/p_udmf.cpp | 10 ++-- src/p_writemap.cpp | 6 +- src/po_man.cpp | 79 +++++++++++++------------- src/po_man.h | 4 +- src/portal.cpp | 30 +++++----- src/r_bsp.cpp | 30 +++++----- src/r_data/r_interpolate.cpp | 19 +++---- src/r_defs.h | 43 ++++++++++++-- src/r_main.cpp | 16 +++--- src/r_segs.cpp | 42 +++++++------- src/r_things.cpp | 4 +- 26 files changed, 328 insertions(+), 299 deletions(-) diff --git a/src/m_bbox.cpp b/src/m_bbox.cpp index a2d839b6b..6baba2a56 100644 --- a/src/m_bbox.cpp +++ b/src/m_bbox.cpp @@ -78,8 +78,8 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const if (ld->dx == 0) { // ST_VERTICAL - p1 = m_Box[BOXRIGHT] < ld->v1->x; - p2 = m_Box[BOXLEFT] < ld->v1->x; + p1 = m_Box[BOXRIGHT] < ld->v1->fixX(); + p2 = m_Box[BOXLEFT] < ld->v1->fixX(); if (ld->dy < 0) { p1 ^= 1; @@ -88,8 +88,8 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const } else if (ld->dy == 0) { // ST_HORIZONTAL: - p1 = m_Box[BOXTOP] > ld->v1->y; - p2 = m_Box[BOXBOTTOM] > ld->v1->y; + p1 = m_Box[BOXTOP] > ld->v1->fixY(); + p2 = m_Box[BOXBOTTOM] > ld->v1->fixY(); if (ld->dx < 0) { p1 ^= 1; diff --git a/src/nodebuild_extract.cpp b/src/nodebuild_extract.cpp index 0d5e0b91c..425c656e3 100644 --- a/src/nodebuild_extract.cpp +++ b/src/nodebuild_extract.cpp @@ -64,8 +64,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, for (i = 0; i < vertCount; ++i) { - outVerts[i].x = Vertices[i].x; - outVerts[i].y = Vertices[i].y; + outVerts[i].set(Vertices[i].x, Vertices[i].y); } subCount = Subsectors.Size(); @@ -169,8 +168,7 @@ void FNodeBuilder::ExtractMini (FMiniBSP *bsp) bsp->Verts.Resize(Vertices.Size()); for (i = 0; i < Vertices.Size(); ++i) { - bsp->Verts[i].x = Vertices[i].x; - bsp->Verts[i].y = Vertices[i].y; + bsp->Verts[i].set(Vertices[i].x, Vertices[i].y); } bsp->Subsectors.Resize(Subsectors.Size()); @@ -400,14 +398,14 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector, vertex_t { Printf(PRINT_LOG, " Seg %5d%c(%5d,%5d)-(%5d,%5d) [%08x,%08x]-[%08x,%08x]\n", i, segs[i].linedef == NULL ? '+' : ' ', - segs[i].v1->x>>16, - segs[i].v1->y>>16, - segs[i].v2->x>>16, - segs[i].v2->y>>16, - segs[i].v1->x, - segs[i].v1->y, - segs[i].v2->x, - segs[i].v2->y); + segs[i].v1->fixX()>>16, + segs[i].v1->fixY()>>16, + segs[i].v2->fixX()>>16, + segs[i].v2->fixY()>>16, + segs[i].v1->fixX(), + segs[i].v1->fixY(), + segs[i].v2->fixX(), + segs[i].v2->fixY()); } #endif diff --git a/src/nodebuild_utility.cpp b/src/nodebuild_utility.cpp index d3d560f4c..96da22b8a 100644 --- a/src/nodebuild_utility.cpp +++ b/src/nodebuild_utility.cpp @@ -96,14 +96,14 @@ void FNodeBuilder::FindUsedVertices (vertex_t *oldverts, int max) if (map[v1] == -1) { - newvert.x = oldverts[v1].x; - newvert.y = oldverts[v1].y; + newvert.x = oldverts[v1].fixX(); + newvert.y = oldverts[v1].fixY(); map[v1] = VertexMap->SelectVertexExact (newvert); } if (map[v2] == -1) { - newvert.x = oldverts[v2].x; - newvert.y = oldverts[v2].y; + newvert.x = oldverts[v2].fixX(); + newvert.y = oldverts[v2].fixY(); map[v2] = VertexMap->SelectVertexExact (newvert); } @@ -222,11 +222,11 @@ void FNodeBuilder::AddSegs(seg_t *segs, int numsegs) seg.frontsector = segs[i].frontsector; seg.backsector = segs[i].backsector; - vert.x = segs[i].v1->x; - vert.y = segs[i].v1->y; + vert.x = segs[i].v1->fixX(); + vert.y = segs[i].v1->fixY(); seg.v1 = VertexMap->SelectVertexExact(vert); - vert.x = segs[i].v2->x; - vert.y = segs[i].v2->y; + vert.x = segs[i].v2->fixX(); + vert.y = segs[i].v2->fixY(); seg.v2 = VertexMap->SelectVertexExact(vert); seg.linedef = int(segs[i].linedef - Level.Lines); seg.sidedef = segs[i].sidedef != NULL ? int(segs[i].sidedef - Level.Sides) : int(NO_SIDE); @@ -430,18 +430,18 @@ void FNodeBuilder::FindPolyContainers (TArray &spots, TArrayx + spot->x; - center.y = mid.y - anchor->y + spot->y; + center.set(mid.fixX() - anchor->x + spot->x, + mid.fixY() - anchor->y + spot->y); // Scan right for the seg closest to the polyobject's center after it // gets moved to its start spot. fixed_t closestdist = FIXED_MAX; unsigned int closestseg = UINT_MAX; - P(Printf ("start %d,%d -- center %d, %d\n", spot->x>>16, spot->y>>16, center.x>>16, center.y>>16)); + P(Printf ("start %d,%d -- center %d, %d\n", spot->x>>16, spot->y>>16, center.fixX()>>16, center.fixY()>>16)); for (unsigned int j = 0; j < Segs.Size(); ++j) { @@ -454,16 +454,16 @@ void FNodeBuilder::FindPolyContainers (TArray &spots, TArrayy < center.y && v2->y < center.y) || (v1->y > center.y && v2->y > center.y)) + if ((v1->y < center.fixY() && v2->y < center.fixY()) || (v1->y > center.fixY() && v2->y > center.fixY())) { // Not crossed continue; } fixed_t dx = v2->x - v1->x; - if (PointOnSide (center.x, center.y, v1->x, v1->y, dx, dy) <= 0) + if (PointOnSide (center.fixX(), center.fixY(), v1->x, v1->y, dx, dy) <= 0) { - fixed_t t = DivScale30 (center.y - v1->y, dy); + fixed_t t = DivScale30 (center.fixY() - v1->y, dy); fixed_t sx = v1->x + MulScale30 (dx, t); fixed_t dist = sx - spot->x; @@ -565,8 +565,7 @@ bool FNodeBuilder::GetPolyExtents (int polynum, fixed_t bbox[4]) vert = Segs[i].v1; - start.x = Vertices[vert].x; - start.y = Vertices[vert].y; + start.set(Vertices[vert].x, Vertices[vert].y); do { @@ -574,7 +573,7 @@ bool FNodeBuilder::GetPolyExtents (int polynum, fixed_t bbox[4]) vert = Segs[i].v2; i = Vertices[vert].segs; count++; // to prevent endless loops. Stop when this reaches the number of segs. - } while (i != DWORD_MAX && (Vertices[vert].x != start.x || Vertices[vert].y != start.y) && count < Segs.Size()); + } while (i != DWORD_MAX && (Vertices[vert].x != start.fixX() || Vertices[vert].y != start.fixY()) && count < Segs.Size()); return true; } @@ -614,15 +613,15 @@ void FNodeBuilder::FLevel::FindMapBounds () { fixed_t minx, maxx, miny, maxy; - minx = maxx = Vertices[0].x; - miny = maxy = Vertices[0].y; + minx = maxx = Vertices[0].fixX(); + miny = maxy = Vertices[0].fixY(); for (int i = 1; i < NumVertices; ++i) { - if (Vertices[i].x < minx) minx = Vertices[i].x; - else if (Vertices[i].x > maxx) maxx = Vertices[i].x; - if (Vertices[i].y < miny) miny = Vertices[i].y; - else if (Vertices[i].y > maxy) maxy = Vertices[i].y; + if (Vertices[i].fixX() < minx) minx = Vertices[i].fixX(); + else if (Vertices[i].fixX() > maxx) maxx = Vertices[i].fixX(); + if (Vertices[i].fixY() < miny) miny = Vertices[i].fixY(); + else if (Vertices[i].fixY() > maxy) maxy = Vertices[i].fixY(); } MinX = minx; diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 2fa2a70f2..4fd0380c8 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -764,13 +764,12 @@ vertex_t *FindVertex (SDWORD x, SDWORD y) for (i = 0; i < numvertexes; ++i) { - if (vertexes[i].x == x && vertexes[i].y == y) + if (vertexes[i].fixX() == x && vertexes[i].fixY() == y) { return &vertexes[i]; } } - vertexes[i].x = x; - vertexes[i].y = y; + vertexes[i].set(x, y); numvertexes++; return &vertexes[i]; } diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 8707ffc76..4e62b09c1 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -162,12 +162,12 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun // I wish there was a better method to do this than randomly looking through the portal at a few places... if (checkabove) { - sector_t *upper = P_PointInSector(check->v1->fPos() + check->Delta() / 2 + sec->SkyBoxes[sector_t::ceiling]->Scale); + sector_t *upper = P_PointInSector(check->V1() + check->Delta() / 2 + sec->SkyBoxes[sector_t::ceiling]->Scale); P_RecursiveSound(upper, soundtarget, splash, soundblocks, emitter, maxdist); } if (checkbelow) { - sector_t *lower = P_PointInSector(check->v1->fPos() + check->Delta() / 2 + sec->SkyBoxes[sector_t::floor]->Scale); + sector_t *lower = P_PointInSector(check->V1() + check->Delta() / 2 + sec->SkyBoxes[sector_t::floor]->Scale); P_RecursiveSound(lower, soundtarget, splash, soundblocks, emitter, maxdist); } FLinePortal *port = check->getPortal(); @@ -195,18 +195,18 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun other = check->sidedef[0]->sector; // check for closed door - if ((sec->floorplane.ZatPoint (check->v1->fPos()) >= - other->ceilingplane.ZatPoint (check->v1->fPos()) && - sec->floorplane.ZatPoint (check->v2->fPos()) >= - other->ceilingplane.ZatPoint (check->v2->fPos())) - || (other->floorplane.ZatPoint (check->v1->fPos()) >= - sec->ceilingplane.ZatPoint (check->v1->fPos()) && - other->floorplane.ZatPoint (check->v2->fPos()) >= - sec->ceilingplane.ZatPoint (check->v2->fPos())) - || (other->floorplane.ZatPoint (check->v1->fPos()) >= - other->ceilingplane.ZatPoint (check->v1->fPos()) && - other->floorplane.ZatPoint (check->v2->fPos()) >= - other->ceilingplane.ZatPoint (check->v2->fPos()))) + if ((sec->floorplane.ZatPoint (check->V1()) >= + other->ceilingplane.ZatPoint (check->V1()) && + sec->floorplane.ZatPoint (check->V2()) >= + other->ceilingplane.ZatPoint (check->V2())) + || (other->floorplane.ZatPoint (check->V1()) >= + sec->ceilingplane.ZatPoint (check->V1()) && + other->floorplane.ZatPoint (check->V2()) >= + sec->ceilingplane.ZatPoint (check->V2())) + || (other->floorplane.ZatPoint (check->V1()) >= + other->ceilingplane.ZatPoint (check->V1()) && + other->floorplane.ZatPoint (check->V2()) >= + other->ceilingplane.ZatPoint (check->V2()))) { continue; } diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 84951a3a3..cc80296da 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -140,7 +140,7 @@ static int CheckForMissingSegs() if (seg->sidedef!=NULL) { // check all the segs and calculate the length they occupy on their sidedef - DVector2 vec1(seg->v2->x - seg->v1->x, seg->v2->y - seg->v1->y); + DVector2 vec1(seg->v2->fixX() - seg->v1->fixX(), seg->v2->fixY() - seg->v1->fixY()); added_seglen[seg->sidedef - sides] += float(vec1.Length()); } } @@ -268,8 +268,7 @@ static bool LoadGLVertexes(FileReader * lump) for (i = firstglvertex; i < numvertexes; i++) { - vertexes[i].x = LittleLong(mgl->x); - vertexes[i].y = LittleLong(mgl->y); + vertexes[i].set(LittleLong(mgl->x), LittleLong(mgl->y)); mgl++; } delete[] gldata; @@ -1102,8 +1101,8 @@ static void CreateCachedNodes(MapData *map) WriteLong(ZNodes, numvertexes); for(int i=0;iflags |= SSECF_DEGENERATE; for(j=2; jnumlines; j++) { - if (!PointOnLine(seg[j].v1->x, seg[j].v1->y, seg->v1->x, seg->v1->y, seg->v2->x-seg->v1->x, seg->v2->y-seg->v1->y)) + if (!PointOnLine(seg[j].v1->fixX(), seg[j].v1->fixY(), seg->v1->fixX(), seg->v1->fixY(), seg->v2->fixX() -seg->v1->fixX(), seg->v2->fixY() -seg->v1->fixY())) { // Not on the same line ss->flags &= ~SSECF_DEGENERATE; diff --git a/src/p_map.cpp b/src/p_map.cpp index 3e2fca2e2..765b0d57e 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -109,7 +109,7 @@ static DVector2 FindRefPoint(line_t *ld, const DVector2 &pos) !ld->frontsector->PortalBlocksMovement(sector_t::floor)) { - DVector2 v1 = ld->v1->fPos(); + DVector2 v1 = ld->V1(); DVector2 d = ld->Delta(); double r = clamp(((pos.X - v1.X) * d.X + (pos.Y - v1.Y) * d.Y) / (d.X*d.X + d.Y*d.Y), 0., 1.); return v1 + d*r; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index d58ecd975..0c444dd6c 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -104,7 +104,7 @@ fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1) SQWORD den = ( ((SQWORD)v1->dy*v2->dx - (SQWORD)v1->dx*v2->dy) >> FRACBITS ); if (den == 0) return 0; // parallel - SQWORD num = ((SQWORD)(v1->x - v2->x)*v1->dy + (SQWORD)(v2->y - v1->y)*v1->dx); + SQWORD num = ((SQWORD)(v1->fixX() - v2->fixX())*v1->dy + (SQWORD)(v2->fixY() - v1->fixY())*v1->dx); return (fixed_t)(num / den); #elif 0 // This is the original Doom version @@ -120,8 +120,8 @@ fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1) // I_Error ("P_InterceptVector: parallel"); num = - FixedMul ( (v1->x - v2->x)>>8 ,v1->dy ) - +FixedMul ( (v2->y - v1->y)>>8, v1->dx ); + FixedMul ( (v1->fixX() - v2->fixX())>>8 ,v1->dy ) + +FixedMul ( (v2->fixY() - v1->fixY())>>8, v1->dx ); frac = FixedDiv (num , den); @@ -1230,8 +1230,8 @@ void FPathTraverse::AddLineIntercepts(int bx, int by) || trace.dx < -FRACUNIT*16 || trace.dy < -FRACUNIT*16) { - s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace); - s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace); + s1 = P_PointOnDivlineSide (ld->v1->fixX(), ld->v1->fixY(), &trace); + s2 = P_PointOnDivlineSide (ld->v2->fixX(), ld->v2->fixY(), &trace); } else { @@ -1939,21 +1939,21 @@ int P_VanillaPointOnLineSide(fixed_t x, fixed_t y, const line_t* line) if (!line->dx) { - if (x <= line->v1->x) + if (x <= line->v1->fixX()) return line->dy > 0; return line->dy < 0; } if (!line->dy) { - if (y <= line->v1->y) + if (y <= line->v1->fixY()) return line->dx < 0; return line->dx > 0; } - dx = (x - line->v1->x); - dy = (y - line->v1->y); + dx = (x - line->v1->fixX()); + dy = (y - line->v1->fixY()); left = FixedMul ( line->dy>>FRACBITS , dx ); right = FixedMul ( dy , line->dx>>FRACBITS ); diff --git a/src/p_maputl.h b/src/p_maputl.h index 63875ef89..56e5a7615 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -45,18 +45,20 @@ struct intercept_t // //========================================================================== +const double POL_Epsilon = -1. / 65536.; + inline int P_PointOnLineSide (fixed_t x, fixed_t y, const line_t *line) { extern int P_VanillaPointOnLineSide(fixed_t x, fixed_t y, const line_t* line); return i_compatflags2 & COMPATF2_POINTONLINE ? P_VanillaPointOnLineSide(x, y, line) - : DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy) > 0; + : DMulScale32 (y-line->v1->fixY(), line->dx, line->v1->fixX()-x, line->dy) > 0; } inline int P_PointOnLineSidePrecise (fixed_t x, fixed_t y, const line_t *line) { - return DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy) > 0; + return DMulScale32 (y-line->v1->fixY(), line->dx, line->v1->fixX()-x, line->dy) > 0; } inline int P_PointOnLineSide(double x, double y, const line_t *line) @@ -71,12 +73,12 @@ inline int P_PointOnLineSide(const DVector2 & p, const line_t *line) inline int P_PointOnLineSidePrecise(double x, double y, const line_t *line) { - return DMulScale32(FLOAT2FIXED(y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(x), line->dy) > 0; + return (y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - x) * line->Delta().Y > POL_Epsilon ; } inline int P_PointOnLineSidePrecise(const DVector2 &pt, const line_t *line) { - return DMulScale32(FLOAT2FIXED(pt.Y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(pt.X), line->dy) > 0; + return (pt.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pt.X) * line->Delta().Y > POL_Epsilon; } @@ -121,8 +123,8 @@ inline int P_PointOnDivlineSidePrecise(const DVector2 &pos, const divline_t *lin inline void P_MakeDivline (const line_t *li, fdivline_t *dl) { - dl->x = li->v1->x; - dl->y = li->v1->y; + dl->x = li->v1->fixX(); + dl->y = li->v1->fixY(); dl->dx = li->dx; dl->dy = li->dy; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 467d01d0e..1fabbc432 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1401,9 +1401,9 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) den = line->Delta().LengthSquared(); if (den != 0) { - frac = clamp((mo->Pos() - line->v1->fPos()) | line->Delta(), 0, den) / den; + frac = clamp((mo->Pos() - line->V1()) | line->Delta(), 0, den) / den; - linepos = DVector3(line->v1->fPos() + line->Delta() * frac, pos.Z); + linepos = DVector3(line->V1() + line->Delta() * frac, pos.Z); F3DFloor * ffloor=NULL; if (line->sidedef[side^1] != NULL) diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index e96a4328e..41bb46d11 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -725,34 +725,34 @@ void sector_t::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy) co { vertex_t *v1 = lines[i]->v1; vertex_t *v2 = lines[i]->v2; - double a = v2->x - v1->x; - double b = v2->y - v1->y; + double a = v2->fixX() - v1->fixX(); + double b = v2->fixY() - v1->fixY(); double den = a*a + b*b; double ix, iy, dist; if (den == 0) { // Line is actually a point! - ix = v1->x; - iy = v1->y; + ix = v1->fixX(); + iy = v1->fixY(); } else { - double num = (x - v1->x) * a + (y - v1->y) * b; + double num = (x - v1->fixX()) * a + (y - v1->fixY()) * b; double u = num / den; if (u <= 0) { - ix = v1->x; - iy = v1->y; + ix = v1->fixX(); + iy = v1->fixY(); } else if (u >= 1) { - ix = v2->x; - iy = v2->y; + ix = v2->fixX(); + iy = v2->fixY(); } else { - ix = v1->x + u * a; - iy = v1->y + u * b; + ix = v1->fixX() + u * a; + iy = v1->fixY() + u * b; } } a = (ix - x); @@ -1136,10 +1136,10 @@ bool P_AlignFlat (int linenum, int side, int fc) if (!sec) return false; - fixed_t x = line->v1->x; - fixed_t y = line->v1->y; + fixed_t x = line->v1->fixX(); + fixed_t y = line->v1->fixY(); - angle_t angle = R_PointToAngle2 (x, y, line->v2->x, line->v2->y); + angle_t angle = R_PointToAngle2 (x, y, line->v2->fixX(), line->v2->fixY()); angle_t norm = (angle-ANGLE_90) >> ANGLETOFINESHIFT; fixed_t dist = -DMulScale16 (finecosine[norm], x, finesine[norm], y); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 3c096a5f0..fb0df8e1d 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -864,8 +864,7 @@ void P_LoadVertexes (MapData * map) SWORD x, y; (*map->file) >> x >> y; - vertexes[i].x = x << FRACBITS; - vertexes[i].y = y << FRACBITS; + vertexes[i].set(x << FRACBITS, y << FRACBITS); } } @@ -1003,7 +1002,9 @@ void LoadZNodes(FileReaderBase &data, int glnodes) } for (i = 0; i < newVerts; ++i) { - data >> newvertarray[i + orgVerts].x >> newvertarray[i + orgVerts].y; + fixed_t x, y; + data >> x >> y; + newvertarray[i + orgVerts].set(x, y); } if (vertexes != newvertarray) { @@ -1316,28 +1317,30 @@ void P_LoadSegs (MapData * map) // off, then move one vertex. This may seem insignificant, but one degree // errors _can_ cause firelines. - ptp_angle = R_PointToAngle2 (li->v1->x, li->v1->y, li->v2->x, li->v2->y); + ptp_angle = R_PointToAngle2 (li->v1->fixX(), li->v1->fixY(), li->v2->fixX(), li->v2->fixY()); dis = 0; delta_angle = (absangle(ptp_angle-(segangle<<16))>>ANGLETOFINESHIFT)*360/FINEANGLES; if (delta_angle != 0) { segangle >>= (ANGLETOFINESHIFT-16); - dx = (li->v1->x - li->v2->x)>>FRACBITS; - dy = (li->v1->y - li->v2->y)>>FRACBITS; + dx = (li->v1->fixX() - li->v2->fixX())>>FRACBITS; + dy = (li->v1->fixY() - li->v2->fixY())>>FRACBITS; dis = ((int) g_sqrt((double)(dx*dx + dy*dy)))< vnum1) && (vertchanged[vnum2] == 0)) { - li->v2->x = li->v1->x + FixedMul(dis,dx); - li->v2->y = li->v1->y + FixedMul(dis,dy); + li->v2->set( + li->v1->fixX() + FixedMul(dis,dx), + li->v1->fixY() + FixedMul(dis,dy)); vertchanged[vnum2] = 1; // this was changed } else if (vertchanged[vnum1] == 0) { - li->v1->x = li->v2->x - FixedMul(dis,dx); - li->v1->y = li->v2->y - FixedMul(dis,dy); + li->v1->set( + li->v2->fixX() - FixedMul(dis,dx), + li->v2->fixY() - FixedMul(dis,dy)); vertchanged[vnum1] = 1; // this was changed } } @@ -1904,29 +1907,29 @@ void P_AdjustLine (line_t *ld) v1 = ld->v1; v2 = ld->v2; - ld->dx = v2->x - v1->x; - ld->dy = v2->y - v1->y; + ld->dx = v2->fixX() - v1->fixX(); + ld->dy = v2->fixY() - v1->fixY(); - if (v1->x < v2->x) + if (v1->fixX() < v2->fixX()) { - ld->bbox[BOXLEFT] = v1->x; - ld->bbox[BOXRIGHT] = v2->x; + ld->bbox[BOXLEFT] = v1->fixX(); + ld->bbox[BOXRIGHT] = v2->fixX(); } else { - ld->bbox[BOXLEFT] = v2->x; - ld->bbox[BOXRIGHT] = v1->x; + ld->bbox[BOXLEFT] = v2->fixX(); + ld->bbox[BOXRIGHT] = v1->fixX(); } - if (v1->y < v2->y) + if (v1->fixY() < v2->fixY()) { - ld->bbox[BOXBOTTOM] = v1->y; - ld->bbox[BOXTOP] = v2->y; + ld->bbox[BOXBOTTOM] = v1->fixY(); + ld->bbox[BOXTOP] = v2->fixY(); } else { - ld->bbox[BOXBOTTOM] = v2->y; - ld->bbox[BOXTOP] = v1->y; + ld->bbox[BOXBOTTOM] = v2->fixY(); + ld->bbox[BOXTOP] = v1->fixY(); } } @@ -2015,8 +2018,8 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha) ld->frontsector = ld->sidedef[0] != NULL ? ld->sidedef[0]->sector : NULL; ld->backsector = ld->sidedef[1] != NULL ? ld->sidedef[1]->sector : NULL; - double dx = FIXED2DBL(ld->v2->x - ld->v1->x); - double dy = FIXED2DBL(ld->v2->y - ld->v1->y); + double dx = FIXED2DBL(ld->v2->fixX() - ld->v1->fixX()); + double dy = FIXED2DBL(ld->v2->fixY() - ld->v1->fixY()); int linenum = int(ld-lines); if (ld->frontsector == NULL) @@ -2141,8 +2144,8 @@ void P_LoadLineDefs (MapData * map) I_Error ("Line %d has invalid vertices: %d and/or %d.\nThe map only contains %d vertices.", i+skipped, v1, v2, numvertexes); } else if (v1 == v2 || - (vertexes[LittleShort(mld->v1)].x == vertexes[LittleShort(mld->v2)].x && - vertexes[LittleShort(mld->v1)].y == vertexes[LittleShort(mld->v2)].y)) + (vertexes[LittleShort(mld->v1)].fixX() == vertexes[LittleShort(mld->v2)].fixX() && + vertexes[LittleShort(mld->v1)].fixY() == vertexes[LittleShort(mld->v2)].fixY())) { Printf ("Removing 0-length line %d\n", i+skipped); memmove (mld, mld+1, sizeof(*mld)*(numlines-i-1)); @@ -2230,8 +2233,8 @@ void P_LoadLineDefs2 (MapData * map) mld = ((maplinedef2_t*)mldf) + i; if (mld->v1 == mld->v2 || - (vertexes[LittleShort(mld->v1)].x == vertexes[LittleShort(mld->v2)].x && - vertexes[LittleShort(mld->v1)].y == vertexes[LittleShort(mld->v2)].y)) + (vertexes[LittleShort(mld->v1)].fixX() == vertexes[LittleShort(mld->v2)].fixX() && + vertexes[LittleShort(mld->v1)].fixY() == vertexes[LittleShort(mld->v2)].fixY())) { Printf ("Removing 0-length line %d\n", i+skipped); memmove (mld, mld+1, sizeof(*mld)*(numlines-i-1)); @@ -2794,15 +2797,15 @@ static void P_CreateBlockMap () return; // Find map extents for the blockmap - minx = maxx = vertexes[0].x; - miny = maxy = vertexes[0].y; + minx = maxx = vertexes[0].fixX(); + miny = maxy = vertexes[0].fixY(); for (i = 1; i < numvertexes; ++i) { - if (vertexes[i].x < minx) minx = vertexes[i].x; - else if (vertexes[i].x > maxx) maxx = vertexes[i].x; - if (vertexes[i].y < miny) miny = vertexes[i].y; - else if (vertexes[i].y > maxy) maxy = vertexes[i].y; + if (vertexes[i].fixX() < minx) minx = vertexes[i].fixX(); + else if (vertexes[i].fixX() > maxx) maxx = vertexes[i].fixX(); + if (vertexes[i].fixY() < miny) miny = vertexes[i].fixY(); + else if (vertexes[i].fixY() > maxy) maxy = vertexes[i].fixY(); } maxx >>= FRACBITS; @@ -2824,10 +2827,10 @@ static void P_CreateBlockMap () for (line = 0; line < numlines; ++line) { - int x1 = lines[line].v1->x >> FRACBITS; - int y1 = lines[line].v1->y >> FRACBITS; - int x2 = lines[line].v2->x >> FRACBITS; - int y2 = lines[line].v2->y >> FRACBITS; + int x1 = lines[line].v1->fixX() >> FRACBITS; + int y1 = lines[line].v1->fixY() >> FRACBITS; + int x2 = lines[line].v2->fixX() >> FRACBITS; + int y2 = lines[line].v2->fixY() >> FRACBITS; int dx = x2 - x1; int dy = y2 - y1; int bx = (x1 - minx) >> BLOCKBITS; @@ -3217,8 +3220,8 @@ static void P_GroupLines (bool buildmap) for (j = 0; j < sector->linecount; ++j) { li = sector->lines[j]; - bbox.AddToBox (li->v1->x, li->v1->y); - bbox.AddToBox (li->v2->x, li->v2->y); + bbox.AddToBox (li->v1->fixX(), li->v1->fixY()); + bbox.AddToBox (li->v2->fixX(), li->v2->fixY()); } } @@ -3234,8 +3237,8 @@ static void P_GroupLines (bool buildmap) Triangle[1] = sector->lines[0]->v2; if (sector->linecount > 1) { - fixed_t dx = Triangle[1]->x - Triangle[0]->x; - fixed_t dy = Triangle[1]->y - Triangle[0]->y; + fixed_t dx = Triangle[1]->fixX() - Triangle[0]->fixX(); + fixed_t dy = Triangle[1]->fixY() - Triangle[0]->fixY(); // Find another point in the sector that does not lie // on the same line as the first two points. for (j = 0; j < 2; ++j) @@ -3243,11 +3246,11 @@ static void P_GroupLines (bool buildmap) vertex_t *v; v = (j == 1) ? sector->lines[1]->v1 : sector->lines[1]->v2; - if (DMulScale32 (v->y - Triangle[0]->y, dx, - Triangle[0]->x - v->x, dy) != 0) + if (DMulScale32 (v->fixY() - Triangle[0]->fixY(), dx, + Triangle[0]->fixX() - v->fixX(), dy) != 0) { - sector->centerspot.X = FIXED2DBL(Triangle[0]->x / 3 + Triangle[1]->x / 3 + v->x / 3); - sector->centerspot.Y = FIXED2DBL(Triangle[0]->y / 3 + Triangle[1]->y / 3 + v->y / 3); + sector->centerspot.X = FIXED2DBL(Triangle[0]->fixX() / 3 + Triangle[1]->fixX() / 3 + v->fixX() / 3); + sector->centerspot.Y = FIXED2DBL(Triangle[0]->fixY() / 3 + Triangle[1]->fixY() / 3 + v->fixY() / 3); break; } } @@ -3926,8 +3929,8 @@ void P_SetupLevel (const char *lumpname, int position) seg_t * seg=&segs[i]; if (seg->backsector == seg->frontsector && seg->linedef) { - fixed_t d1=P_AproxDistance(seg->v1->x-seg->linedef->v1->x,seg->v1->y-seg->linedef->v1->y); - fixed_t d2=P_AproxDistance(seg->v2->x-seg->linedef->v1->x,seg->v2->y-seg->linedef->v1->y); + fixed_t d1=P_AproxDistance(seg->v1->fixX()-seg->linedef->v1->fixX(),seg->v1->fixY()-seg->linedef->v1->fixY()); + fixed_t d2=P_AproxDistance(seg->v2->fixX()-seg->linedef->v1->fixX(),seg->v2->fixY()-seg->linedef->v1->fixY()); if (d2 (%d,%d)\n", lines[linenum].v1->x >> FRACBITS, - lines[linenum].v1->y >> FRACBITS, - lines[linenum].v2->x >> FRACBITS, - lines[linenum].v2->y >> FRACBITS); + Printf ("(%d,%d) -> (%d,%d)\n", lines[linenum].v1->fixX() >> FRACBITS, + lines[linenum].v1->fixY() >> FRACBITS, + lines[linenum].v2->fixX() >> FRACBITS, + lines[linenum].v2->fixY() >> FRACBITS); } #endif diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 4b8a32951..b812e0f63 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -375,8 +375,8 @@ bool SightCheck::P_SightCheckLine (line_t *ld) return true; } ld->validcount = validcount; - if (P_PointOnDivlineSidePrecise (ld->v1->fPos(), &Trace) == - P_PointOnDivlineSidePrecise (ld->v2->fPos(), &Trace)) + if (P_PointOnDivlineSidePrecise (ld->V1(), &Trace) == + P_PointOnDivlineSidePrecise (ld->V2(), &Trace)) { return true; // line isn't crossed } diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp index 0265a1514..805347b9a 100644 --- a/src/p_slopes.cpp +++ b/src/p_slopes.cpp @@ -79,14 +79,14 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo DVector3 p, v1, v2, cross; - p[0] = FIXED2DBL (line->v1->x); - p[1] = FIXED2DBL (line->v1->y); - p[2] = FIXED2DBL (plane->ZatPoint (line->v1->x, line->v1->y)); + p[0] = FIXED2DBL (line->v1->fixX()); + p[1] = FIXED2DBL (line->v1->fixY()); + p[2] = FIXED2DBL (plane->ZatPoint (line->v1->fixX(), line->v1->fixY())); v1[0] = FIXED2DBL (line->dx); v1[1] = FIXED2DBL (line->dy); - v1[2] = FIXED2DBL (plane->ZatPoint (line->v2->x, line->v2->y)) - p[2]; - v2[0] = FIXED2DBL (x - line->v1->x); - v2[1] = FIXED2DBL (y - line->v1->y); + v1[2] = FIXED2DBL (plane->ZatPoint (line->v2->fixX(), line->v2->fixY())) - p[2]; + v2[0] = FIXED2DBL (x - line->v1->fixX()); + v2[1] = FIXED2DBL (y - line->v1->fixY()); v2[2] = FIXED2DBL (z) - p[2]; cross = v1 ^ v2; @@ -232,12 +232,12 @@ void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int secplane_t *srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane; fixed_t srcheight = (which == 0) ? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling); - v1[0] = FIXED2DBL (x - l->v2->x); - v1[1] = FIXED2DBL (y - l->v2->y); + v1[0] = FIXED2DBL (x - l->v2->fixX()); + v1[1] = FIXED2DBL (y - l->v2->fixY()); v1[2] = FIXED2DBL (z - srcheight); - v2[0] = FIXED2DBL (x - l->v1->x); - v2[1] = FIXED2DBL (y - l->v1->y); + v2[0] = FIXED2DBL (x - l->v1->fixX()); + v2[1] = FIXED2DBL (y - l->v1->fixY()); v2[2] = FIXED2DBL (z - srcheight); cross = v1 ^ v2; @@ -360,7 +360,7 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, vt2.Z = h2? *h2 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling); vt3.Z = h3? *h3 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling); - if (P_PointOnLineSidePrecise(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0) + if (P_PointOnLineSidePrecise(vertexes[vi3].fixX(), vertexes[vi3].fixY(), sec->lines[0]) == 0) { vec1 = vt2 - vt3; vec2 = vt1 - vt3; @@ -394,8 +394,8 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, srcplane->b = FLOAT2FIXED (cross[1]); srcplane->c = FLOAT2FIXED (cross[2]); srcplane->ic = DivScale32 (1, srcplane->c); - srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].x, - srcplane->b, vertexes[vi3].y, + srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].fixX(), + srcplane->b, vertexes[vi3].fixY(), srcplane->c, FLOAT2FIXED(vt3.Z)); } } @@ -507,8 +507,8 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which) vert = (*probe++)->v2; else vert = (*probe)->v1; - dist = fabs((double(line->v1->y) - vert->y) * line->dx - - (double(line->v1->x) - vert->x) * line->dy); + dist = fabs((double(line->v1->fixY()) - vert->fixY()) * line->dx - + (double(line->v1->fixX()) - vert->fixX()) * line->dy); if (dist > bestdist) { @@ -528,14 +528,14 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which) srcheight = (which == 0) ? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling); destheight = (which == 0) ? refsec->GetPlaneTexZ(sector_t::floor) : refsec->GetPlaneTexZ(sector_t::ceiling); - p[0] = FIXED2DBL (line->v1->x); - p[1] = FIXED2DBL(line->v1->y); + p[0] = FIXED2DBL (line->v1->fixX()); + p[1] = FIXED2DBL(line->v1->fixY()); p[2] = FIXED2DBL(destheight); v1[0] = FIXED2DBL(line->dx); v1[1] = FIXED2DBL(line->dy); v1[2] = 0; - v2[0] = FIXED2DBL(refvert->x - line->v1->x); - v2[1] = FIXED2DBL(refvert->y - line->v1->y); + v2[0] = FIXED2DBL(refvert->fixX() - line->v1->fixX()); + v2[1] = FIXED2DBL(refvert->fixY() - line->v1->fixY()); v2[2] = FIXED2DBL(srcheight - destheight); cross = (v1 ^ v2).Unit(); @@ -551,8 +551,8 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which) srcplane->c = FLOAT2FIXED (cross[2]); //srcplane->ic = FLOAT2FIXED (1.f/cross[2]); srcplane->ic = DivScale32 (1, srcplane->c); - srcplane->d = -TMulScale16 (srcplane->a, line->v1->x, - srcplane->b, line->v1->y, + srcplane->d = -TMulScale16 (srcplane->a, line->v1->fixX(), + srcplane->b, line->v1->fixY(), srcplane->c, destheight); } diff --git a/src/p_switch.cpp b/src/p_switch.cpp index fdea7747b..9add91850 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -291,7 +291,7 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *ques // which wasn't necessarily anywhere near the switch if it was // facing a big sector (and which wasn't necessarily for the // button just activated, either). - DVector2 pt(side->linedef->v1->fPos() + side->linedef->Delta() / 2); + DVector2 pt(side->linedef->V1() + side->linedef->Delta() / 2); bool playsound; side->SetTexture(texture, Switch->frames[0].Texture); diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 946e0000c..27de16613 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1676,21 +1676,22 @@ public: void ParseVertex(vertex_t *vt, vertexdata_t *vd) { - vt->x = vt->y = 0; + vt->set(0, 0); vd->zCeiling = vd->zFloor = vd->flags = 0; sc.MustGetToken('{'); + fixed_t x, y; while (!sc.CheckToken('}')) { FName key = ParseKey(); switch (key) { case NAME_X: - vt->x = CheckFixed(key); + x = CheckFixed(key); break; case NAME_Y: - vt->y = CheckFixed(key); + y = CheckFixed(key); break; case NAME_ZCeiling: @@ -1707,6 +1708,7 @@ public: break; } } + vt->set(x, y); } //=========================================================================== @@ -1729,7 +1731,7 @@ public: I_Error ("Line %d has invalid vertices: %zd and/or %zd.\nThe map only contains %d vertices.", i+skipped, v1i, v2i, numvertexes); } else if (v1i == v2i || - (vertexes[v1i].x == vertexes[v2i].x && vertexes[v1i].y == vertexes[v2i].y)) + (vertexes[v1i].fixX() == vertexes[v2i].fixX() && vertexes[v1i].fixY() == vertexes[v2i].fixY())) { Printf ("Removing 0-length line %d\n", i+skipped); ParsedLines.Delete(i); diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index cd8082cfe..3b0ba4f13 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -167,8 +167,8 @@ static int WriteVERTEXES (FILE *file) for (int i = 0; i < numvertexes; ++i) { - mv.x = LittleShort(short(vertexes[i].x >> FRACBITS)); - mv.y = LittleShort(short(vertexes[i].y >> FRACBITS)); + mv.x = LittleShort(short(vertexes[i].fixX() >> FRACBITS)); + mv.y = LittleShort(short(vertexes[i].fixY() >> FRACBITS)); fwrite (&mv, sizeof(mv), 1, file); } return numvertexes * sizeof(mv); @@ -189,7 +189,7 @@ static int WriteSEGS (FILE *file) ms.v2 = LittleShort(short(segs[i].v2 - vertexes)); ms.linedef = LittleShort(short(segs[i].linedef - lines)); ms.side = segs[i].sidedef == segs[i].linedef->sidedef[0] ? 0 : LittleShort((short)1); - ms.angle = LittleShort(short(R_PointToAngle2 (segs[i].v1->x, segs[i].v1->y, segs[i].v2->x, segs[i].v2->y)>>16)); + ms.angle = LittleShort(short(R_PointToAngle2 (segs[i].v1->fixX(), segs[i].v1->fixY(), segs[i].v2->fixX(), segs[i].v2->fixY())>>16)); fwrite (&ms, sizeof(ms), 1, file); } } diff --git a/src/po_man.cpp b/src/po_man.cpp index c43d094ae..7fbef05f2 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -867,7 +867,7 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side) } vertex_t *v1 = side->V1(); vertex_t *v2 = side->V2(); - thrustAngle = VecToAngle(v2->x - v1->x, v2->y - v1->y) - 90.; + thrustAngle = VecToAngle(v2->fixX() - v1->fixX(), v2->fixY() - v1->fixY()) - 90.; pe = static_cast(specialdata); if (pe) @@ -921,30 +921,30 @@ void FPolyObj::UpdateBBox () { line_t *line = Linedefs[i]; - if (line->v1->x < line->v2->x) + if (line->v1->fixX() < line->v2->fixX()) { - line->bbox[BOXLEFT] = line->v1->x; - line->bbox[BOXRIGHT] = line->v2->x; + line->bbox[BOXLEFT] = line->v1->fixX(); + line->bbox[BOXRIGHT] = line->v2->fixX(); } else { - line->bbox[BOXLEFT] = line->v2->x; - line->bbox[BOXRIGHT] = line->v1->x; + line->bbox[BOXLEFT] = line->v2->fixX(); + line->bbox[BOXRIGHT] = line->v1->fixX(); } - if (line->v1->y < line->v2->y) + if (line->v1->fixY() < line->v2->fixY()) { - line->bbox[BOXBOTTOM] = line->v1->y; - line->bbox[BOXTOP] = line->v2->y; + line->bbox[BOXBOTTOM] = line->v1->fixY(); + line->bbox[BOXTOP] = line->v2->fixY(); } else { - line->bbox[BOXBOTTOM] = line->v2->y; - line->bbox[BOXTOP] = line->v1->y; + line->bbox[BOXBOTTOM] = line->v2->fixY(); + line->bbox[BOXTOP] = line->v1->fixY(); } // Update the line's slopetype - line->dx = line->v2->x - line->v1->x; - line->dy = line->v2->y - line->v1->y; + line->dx = line->v2->fixX() - line->v1->fixX(); + line->dy = line->v2->fixY() - line->v1->fixY(); } CalcCenter(); } @@ -954,8 +954,8 @@ void FPolyObj::CalcCenter() SQWORD cx = 0, cy = 0; for(unsigned i=0;ix; - cy += Vertices[i]->y; + cx += Vertices[i]->fixX(); + cy += Vertices[i]->fixY(); } CenterSpot.x = (fixed_t)(cx / Vertices.Size()); CenterSpot.y = (fixed_t)(cy / Vertices.Size()); @@ -1011,8 +1011,7 @@ void FPolyObj::DoMovePolyobj (int x, int y) { for(unsigned i=0;i < Vertices.Size(); i++) { - Vertices[i]->x += x; - Vertices[i]->y += y; + Vertices[i]->set(Vertices[i]->fixX() + x, Vertices[i]->fixY() + y); PrevPts[i].x += x; PrevPts[i].y += y; } @@ -1061,11 +1060,11 @@ bool FPolyObj::RotatePolyobj (angle_t angle, bool fromsave) for(unsigned i=0;i < Vertices.Size(); i++) { - PrevPts[i].x = Vertices[i]->x; - PrevPts[i].y = Vertices[i]->y; - Vertices[i]->x = OriginalPts[i].x; - Vertices[i]->y = OriginalPts[i].y; - RotatePt(an, &Vertices[i]->x, &Vertices[i]->y, StartSpot.x, StartSpot.y); + PrevPts[i].x = Vertices[i]->fixX(); + PrevPts[i].y = Vertices[i]->fixY(); + FPolyVertex torot = OriginalPts[i]; + RotatePt(an, &torot.x, &torot.y, StartSpot.x, StartSpot.y); + Vertices[i]->set(torot.x, torot.y); } blocked = false; validcount++; @@ -1085,8 +1084,7 @@ bool FPolyObj::RotatePolyobj (angle_t angle, bool fromsave) { for(unsigned i=0;i < Vertices.Size(); i++) { - Vertices[i]->x = PrevPts[i].x; - Vertices[i]->y = PrevPts[i].y; + Vertices[i]->set(PrevPts[i].x, PrevPts[i].y); } UpdateBBox(); LinkPolyobj(); @@ -1281,9 +1279,9 @@ void FPolyObj::LinkPolyobj () vertex_t *vt; vt = Sidedefs[i]->linedef->v1; - Bounds.AddToBox(vt->x, vt->y); + Bounds.AddToBox(vt->fixX(), vt->fixY()); vt = Sidedefs[i]->linedef->v2; - Bounds.AddToBox(vt->x, vt->y); + Bounds.AddToBox(vt->fixX(), vt->fixY()); } bbox[BOXRIGHT] = GetSafeBlockX(Bounds.Right() - bmaporgx); bbox[BOXLEFT] = GetSafeBlockX(Bounds.Left() - bmaporgx); @@ -1373,34 +1371,34 @@ void FPolyObj::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, si { vertex_t *v1 = Sidedefs[i]->V1(); vertex_t *v2 = Sidedefs[i]->V2(); - double a = v2->x - v1->x; - double b = v2->y - v1->y; + double a = v2->fixX() - v1->fixX(); + double b = v2->fixY() - v1->fixY(); double den = a*a + b*b; double ix, iy, dist; if (den == 0) { // Line is actually a point! - ix = v1->x; - iy = v1->y; + ix = v1->fixX(); + iy = v1->fixY(); } else { - double num = (x - v1->x) * a + (y - v1->y) * b; + double num = (x - v1->fixX()) * a + (y - v1->fixY()) * b; double u = num / den; if (u <= 0) { - ix = v1->x; - iy = v1->y; + ix = v1->fixX(); + iy = v1->fixY(); } else if (u >= 1) { - ix = v2->x; - iy = v2->y; + ix = v2->fixX(); + iy = v2->fixY(); } else { - ix = v1->x + u * a; - iy = v1->y + u * b; + ix = v1->fixX() + u * a; + iy = v1->fixY() + u * b; } } a = (ix - x); @@ -1692,10 +1690,9 @@ static void TranslateToStartSpot (int tag, int originX, int originY) } for (unsigned i = 0; i < po->Vertices.Size(); i++) { - po->Vertices[i]->x -= deltaX; - po->Vertices[i]->y -= deltaY; - po->OriginalPts[i].x = po->Vertices[i]->x - po->StartSpot.x; - po->OriginalPts[i].y = po->Vertices[i]->y - po->StartSpot.y; + po->Vertices[i]->set(po->Vertices[i]->fixX() - deltaX, po->Vertices[i]->fixY() - deltaY); + po->OriginalPts[i].x = po->Vertices[i]->fixX() - po->StartSpot.x; + po->OriginalPts[i].y = po->Vertices[i]->fixY() - po->StartSpot.y; } po->CalcCenter(); // For compatibility purposes diff --git a/src/po_man.h b/src/po_man.h index fbfd15acb..e989ad4f5 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -13,8 +13,8 @@ struct FPolyVertex FPolyVertex &operator=(vertex_t *v) { - x = v->x; - y = v->y; + x = v->fixX(); + y = v->fixX(); return *this; } }; diff --git a/src/portal.cpp b/src/portal.cpp index 79470d410..3e50e2d71 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -168,8 +168,8 @@ void FLinePortalTraverse::AddLineIntercepts(int bx, int by) if (ld->validcount == validcount) continue; // already processed - if (P_PointOnDivlineSidePrecise (ld->v1->x, ld->v1->y, &trace) == - P_PointOnDivlineSidePrecise (ld->v2->x, ld->v2->y, &trace)) + if (P_PointOnDivlineSidePrecise (ld->v1->fixX(), ld->v1->fixY(), &trace) == + P_PointOnDivlineSidePrecise (ld->v2->fixX(), ld->v2->fixY(), &trace)) { continue; // line isn't crossed } @@ -513,13 +513,13 @@ inline int P_PointOnLineSideExplicit (fixed_t x, fixed_t y, fixed_t x1, fixed_t inline int P_GetLineSide(fixed_t x, fixed_t y, const line_t *line) { - return DMulScale32(y - line->v1->y, line->dx, line->v1->x - x, line->dy); + return DMulScale32(y - line->v1->fixY(), line->dx, line->v1->fixX() - x, line->dy); } bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t viewy, bool partial, bool samebehind) { - int behind1 = P_GetLineSide(line->v1->x, line->v1->y, portal); - int behind2 = P_GetLineSide(line->v2->x, line->v2->y, portal); + int behind1 = P_GetLineSide(line->v1->fixX(), line->v1->fixY(), portal); + int behind2 = P_GetLineSide(line->v2->fixX(), line->v2->fixY(), portal); if (behind1 == 0 && behind2 == 0) { @@ -544,8 +544,8 @@ bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t vie { // The line intersects with the portal straight, so we need to do another check to see how both ends of the portal lie in relation to the viewer. int viewside = P_PointOnLineSidePrecise(viewx, viewy, line); - int p1side = P_GetLineSide(portal->v1->x, portal->v1->y, line); - int p2side = P_GetLineSide(portal->v2->x, portal->v2->y, line); + int p1side = P_GetLineSide(portal->v1->fixX(), portal->v1->fixY(), line); + int p2side = P_GetLineSide(portal->v2->fixX(), portal->v2->fixY(), line); // Do the same handling of points on the portal straight than above. if (p1side == 0) p1side = p2side; else if (p2side == 0) p2side = p1side; @@ -569,15 +569,15 @@ void P_TranslatePortalXY(line_t* src, fixed_t& x, fixed_t& y) if (!port) return; // offsets from line - fixed_t nposx = x - src->v1->x; - fixed_t nposy = y - src->v1->y; + fixed_t nposx = x - src->v1->fixX(); + fixed_t nposy = y - src->v1->fixY(); // Rotate position along normal to match exit linedef fixed_t tx = FixedMul(nposx, port->mCosRot) - FixedMul(nposy, port->mSinRot); fixed_t ty = FixedMul(nposy, port->mCosRot) + FixedMul(nposx, port->mSinRot); - tx += port->mDestination->v2->x; - ty += port->mDestination->v2->y; + tx += port->mDestination->v2->fixX(); + ty += port->mDestination->v2->fixY(); x = tx; y = ty; @@ -632,11 +632,11 @@ void P_TranslatePortalZ(line_t* src, fixed_t& z) switch (src->getPortalAlignment()) { case PORG_FLOOR: - z = z - src->frontsector->floorplane.ZatPoint(src->v1->x, src->v1->y) + dst->frontsector->floorplane.ZatPoint(dst->v2->x, dst->v2->y); + z = z - src->frontsector->floorplane.ZatPoint(src->v1->fixX(), src->v1->fixY()) + dst->frontsector->floorplane.ZatPoint(dst->v2->fixX(), dst->v2->fixY()); return; case PORG_CEILING: - z = z - src->frontsector->ceilingplane.ZatPoint(src->v1->x, src->v1->y) + dst->frontsector->ceilingplane.ZatPoint(dst->v2->x, dst->v2->y); + z = z - src->frontsector->ceilingplane.ZatPoint(src->v1->fixX(), src->v1->fixY()) + dst->frontsector->ceilingplane.ZatPoint(dst->v2->fixX(), dst->v2->fixY()); return; default: @@ -655,8 +655,8 @@ fixed_t P_PointLineDistance(line_t* line, fixed_t x, fixed_t y) angle_t angle = R_PointToAngle2(0, 0, line->dx, line->dy); angle += ANGLE_180; - fixed_t dx = line->v1->x - x; - fixed_t dy = line->v1->y - y; + fixed_t dx = line->v1->fixX() - x; + fixed_t dy = line->v1->fixY() - y; fixed_t s = finesine[angle>>ANGLETOFINESHIFT]; fixed_t c = finecosine[angle>>ANGLETOFINESHIFT]; diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 42745f8d7..2eb5cebc8 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -404,8 +404,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, // sectors at the same time. if (back && !r_fakingunderwater && curline->frontsector->heightsec == NULL) { - if (rw_frontcz1 <= s->floorplane.ZatPoint (curline->v1->x, curline->v1->y) && - rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->x, curline->v2->y)) + if (rw_frontcz1 <= s->floorplane.ZatPoint (curline->v1->fixX(), curline->v1->fixY()) && + rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->fixX(), curline->v2->fixY())) { // Check that the window is actually visible for (int z = WallC.sx1; z < WallC.sx2; ++z) @@ -529,10 +529,10 @@ void R_AddLine (seg_t *line) // [RH] Color if not texturing line dc_color = (((int)(line - segs) * 8) + 4) & 255; - tx1 = line->v1->x - viewx; - tx2 = line->v2->x - viewx; - ty1 = line->v1->y - viewy; - ty2 = line->v2->y - viewy; + tx1 = line->v1->fixX() - viewx; + tx2 = line->v2->fixX() - viewx; + ty1 = line->v1->fixY() - viewy; + ty2 = line->v2->fixY() - viewy; // Reject lines not facing viewer if (DMulScale32 (ty1, tx1-tx2, tx1, ty2-ty1) >= 0) @@ -573,17 +573,17 @@ void R_AddLine (seg_t *line) { swapvalues (v1, v2); } - WallT.InitFromLine(v1->x - viewx, v1->y - viewy, v2->x - viewx, v2->y - viewy); + WallT.InitFromLine(v1->fixX() - viewx, v1->fixY() - viewy, v2->fixX() - viewx, v2->fixY() - viewy); } if (!(fake3D & FAKE3D_FAKEBACK)) { backsector = line->backsector; } - rw_frontcz1 = frontsector->ceilingplane.ZatPoint (line->v1->x, line->v1->y); - rw_frontfz1 = frontsector->floorplane.ZatPoint (line->v1->x, line->v1->y); - rw_frontcz2 = frontsector->ceilingplane.ZatPoint (line->v2->x, line->v2->y); - rw_frontfz2 = frontsector->floorplane.ZatPoint (line->v2->x, line->v2->y); + rw_frontcz1 = frontsector->ceilingplane.ZatPoint (line->v1->fixX(), line->v1->fixY()); + rw_frontfz1 = frontsector->floorplane.ZatPoint (line->v1->fixX(), line->v1->fixY()); + rw_frontcz2 = frontsector->ceilingplane.ZatPoint (line->v2->fixX(), line->v2->fixY()); + rw_frontfz2 = frontsector->floorplane.ZatPoint (line->v2->fixX(), line->v2->fixY()); rw_mustmarkfloor = rw_mustmarkceiling = false; rw_havehigh = rw_havelow = false; @@ -602,10 +602,10 @@ void R_AddLine (seg_t *line) } doorclosed = 0; // killough 4/16/98 - rw_backcz1 = backsector->ceilingplane.ZatPoint (line->v1->x, line->v1->y); - rw_backfz1 = backsector->floorplane.ZatPoint (line->v1->x, line->v1->y); - rw_backcz2 = backsector->ceilingplane.ZatPoint (line->v2->x, line->v2->y); - rw_backfz2 = backsector->floorplane.ZatPoint (line->v2->x, line->v2->y); + rw_backcz1 = backsector->ceilingplane.ZatPoint (line->v1->fixX(), line->v1->fixY()); + rw_backfz1 = backsector->floorplane.ZatPoint (line->v1->fixX(), line->v1->fixY()); + rw_backcz2 = backsector->ceilingplane.ZatPoint (line->v2->fixX(), line->v2->fixY()); + rw_backfz2 = backsector->floorplane.ZatPoint (line->v2->fixX(), line->v2->fixY()); // Cannot make these walls solid, because it can result in // sprite clipping problems for sprites near the wall diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 565fb2498..1d637394e 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -788,8 +788,8 @@ void DPolyobjInterpolation::UpdateInterpolation() { for(unsigned int i = 0; i < poly->Vertices.Size(); i++) { - oldverts[i*2 ] = poly->Vertices[i]->x; - oldverts[i*2+1] = poly->Vertices[i]->y; + oldverts[i*2 ] = poly->Vertices[i]->fixX(); + oldverts[i*2+1] = poly->Vertices[i]->fixY(); } oldcx = poly->CenterSpot.x; oldcy = poly->CenterSpot.y; @@ -805,8 +805,7 @@ void DPolyobjInterpolation::Restore() { for(unsigned int i = 0; i < poly->Vertices.Size(); i++) { - poly->Vertices[i]->x = bakverts[i*2 ]; - poly->Vertices[i]->y = bakverts[i*2+1]; + poly->Vertices[i]->set(bakverts[i*2 ], bakverts[i*2+1]); } poly->CenterSpot.x = bakcx; poly->CenterSpot.y = bakcy; @@ -824,17 +823,15 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio) bool changed = false; for(unsigned int i = 0; i < poly->Vertices.Size(); i++) { - fixed_t *px = &poly->Vertices[i]->x; - fixed_t *py = &poly->Vertices[i]->y; - - bakverts[i*2 ] = *px; - bakverts[i*2+1] = *py; + bakverts[i*2 ] = poly->Vertices[i]->fixX(); + bakverts[i*2+1] = poly->Vertices[i]->fixY(); if (bakverts[i * 2] != oldverts[i * 2] || bakverts[i * 2 + 1] != oldverts[i * 2 + 1]) { changed = true; - *px = oldverts[i * 2] + FixedMul(bakverts[i * 2] - oldverts[i * 2], smoothratio); - *py = oldverts[i * 2 + 1] + FixedMul(bakverts[i * 2 + 1] - oldverts[i * 2 + 1], smoothratio); + poly->Vertices[i]->set( + oldverts[i * 2] + FixedMul(bakverts[i * 2] - oldverts[i * 2], smoothratio), + oldverts[i * 2 + 1] + FixedMul(bakverts[i * 2 + 1] - oldverts[i * 2 + 1], smoothratio)); } } if (refcount == 0 && !changed) diff --git a/src/r_defs.h b/src/r_defs.h index c34fd8525..a8000f878 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -91,10 +91,33 @@ struct vertexdata_t double zCeiling, zFloor; DWORD flags; }; + +#ifdef USE_FLOAT +typedef float vtype; +#elif !defined USE_FIXED +typedef double vtype; +#endif + + struct vertex_t { +private: fixed_t x, y; +public: + + void set(fixed_t x, fixed_t y) + { + this->x = x; + this->y = y; + } + + void set(double x, double y) + { + this->x = FLOAT2FIXED(x); + this->y = FLOAT2FIXED(y); + } + double fX() const { return FIXED2DBL(x); @@ -105,6 +128,16 @@ struct vertex_t return FIXED2DBL(y); } + fixed_t fixX() const + { + return x; + } + + fixed_t fixY() const + { + return y; + } + DVector2 fPos() { return{ fX(), fY() }; @@ -320,7 +353,7 @@ struct secplane_t // Returns the value of z at vertex v fixed_t ZatPoint (const vertex_t *v) const { - return FixedMul (ic, -d - DMulScale16 (a, v->x, b, v->y)); + return FixedMul (ic, -d - DMulScale16 (a, v->fixX(), b, v->fixY())); } fixed_t ZatPoint (const AActor *ac) const @@ -342,7 +375,7 @@ struct secplane_t // Returns the value of z at vertex v if d is equal to dist fixed_t ZatPointDist (const vertex_t *v, fixed_t dist) { - return FixedMul (ic, -dist - DMulScale16 (a, v->x, b, v->y)); + return FixedMul (ic, -dist - DMulScale16 (a, v->fixX(), b, v->fixY())); } // Flips the plane's vertical orientiation, so that if it pointed up, @@ -404,7 +437,7 @@ struct secplane_t fixed_t PointToDist (const vertex_t *v, fixed_t z) const { - return -TMulScale16 (a, v->x, b, v->y, z, c); + return -TMulScale16 (a, v->fixX(), b, v->fixY(), z, c); } void SetAtHeight(fixed_t height, int ceiling) @@ -1254,12 +1287,12 @@ struct line_t DVector2 V1() const { - return{ FIXED2DBL(v1->x), FIXED2DBL(v1->y) }; + return v1->fPos(); } DVector2 V2() const { - return{ FIXED2DBL(v2->x), FIXED2DBL(v2->y) }; + return v1->fPos(); } DVector2 Delta() const diff --git a/src/r_main.cpp b/src/r_main.cpp index 8add28594..56945f406 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -704,20 +704,20 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) // Reflect the current view behind the mirror. if (pds->src->dx == 0) { // vertical mirror - viewx = v1->x - startx + v1->x; + viewx = v1->fixX() - startx + v1->fixX(); } else if (pds->src->dy == 0) { // horizontal mirror - viewy = v1->y - starty + v1->y; + viewy = v1->fixY() - starty + v1->fixY(); } else { // any mirror--use floats to avoid integer overflow vertex_t *v2 = pds->src->v2; - double dx = FIXED2DBL(v2->x - v1->x); - double dy = FIXED2DBL(v2->y - v1->y); - double x1 = FIXED2DBL(v1->x); - double y1 = FIXED2DBL(v1->y); + double dx = v2->fX() - v1->fX(); + double dy = v2->fY() - v1->fY(); + double x1 = v1->fX(); + double y1 = v1->fY(); double x = FIXED2DBL(startx); double y = FIXED2DBL(starty); @@ -727,8 +727,8 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) viewx = FLOAT2FIXED((x1 + r * dx)*2 - x); viewy = FLOAT2FIXED((y1 + r * dy)*2 - y); } - viewangle = 2*R_PointToAngle2 (pds->src->v1->x, pds->src->v1->y, - pds->src->v2->x, pds->src->v2->y) - startang; + viewangle = 2*R_PointToAngle2 (pds->src->v1->fixX(), pds->src->v1->fixY(), + pds->src->v2->fixX(), pds->src->v2->fixY()) - startang; } else diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 8a349516c..cdcc1ca11 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1388,10 +1388,10 @@ static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *d { if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { - fixed_t frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1->x, ds->curline->v1->y); - fixed_t frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1->x, ds->curline->v1->y); - fixed_t frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2->x, ds->curline->v2->y); - fixed_t frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2->x, ds->curline->v2->y); + fixed_t frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1->fixX(), ds->curline->v1->fixY()); + fixed_t frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1->fixX(), ds->curline->v1->fixY()); + fixed_t frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2->fixX(), ds->curline->v2->fixY()); + fixed_t frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2->fixX(), ds->curline->v2->fixY()); fixed_t top = MAX(frontcz1, frontcz2); fixed_t bot = MIN(frontfz1, frontfz2); if (fake3D & FAKE3D_CLIPTOP) @@ -2778,25 +2778,25 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) if (MirrorFlags & RF_XFLIP) { - x = curline->v2->x; - y = curline->v2->y; + x = curline->v2->fixX(); + y = curline->v2->fixY(); if (wallc->sx1 == 0 && 0 != (den = wallc->tx1 - wallc->tx2 + wallc->ty1 - wallc->ty2)) { int frac = SafeDivScale30 (wallc->ty1 + wallc->tx1, den); - x -= MulScale30 (frac, x - curline->v1->x); - y -= MulScale30 (frac, y - curline->v1->y); + x -= MulScale30 (frac, x - curline->v1->fixX()); + y -= MulScale30 (frac, y - curline->v1->fixY()); } z1 = viewz - plane.ZatPoint (x, y); if (wallc->sx2 > wallc->sx1 + 1) { - x = curline->v1->x; - y = curline->v1->y; + x = curline->v1->fixX(); + y = curline->v1->fixY(); if (wallc->sx2 == viewwidth && 0 != (den = wallc->tx1 - wallc->tx2 - wallc->ty1 + wallc->ty2)) { int frac = SafeDivScale30 (wallc->ty2 - wallc->tx2, den); - x += MulScale30 (frac, curline->v2->x - x); - y += MulScale30 (frac, curline->v2->y - y); + x += MulScale30 (frac, curline->v2->fixX() - x); + y += MulScale30 (frac, curline->v2->fixY() - y); } z2 = viewz - plane.ZatPoint (x, y); } @@ -2807,25 +2807,25 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) } else { - x = curline->v1->x; - y = curline->v1->y; + x = curline->v1->fixX(); + y = curline->v1->fixY(); if (wallc->sx1 == 0 && 0 != (den = wallc->tx1 - wallc->tx2 + wallc->ty1 - wallc->ty2)) { int frac = SafeDivScale30 (wallc->ty1 + wallc->tx1, den); - x += MulScale30 (frac, curline->v2->x - x); - y += MulScale30 (frac, curline->v2->y - y); + x += MulScale30 (frac, curline->v2->fixX() - x); + y += MulScale30 (frac, curline->v2->fixY() - y); } z1 = viewz - plane.ZatPoint (x, y); if (wallc->sx2 > wallc->sx1 + 1) { - x = curline->v2->x; - y = curline->v2->y; + x = curline->v2->fixX(); + y = curline->v2->fixY(); if (wallc->sx2 == viewwidth && 0 != (den = wallc->tx1 - wallc->tx2 - wallc->ty1 + wallc->ty2)) { int frac = SafeDivScale30 (wallc->ty2 - wallc->tx2, den); - x -= MulScale30 (frac, x - curline->v1->x); - y -= MulScale30 (frac, y - curline->v1->y); + x -= MulScale30 (frac, x - curline->v1->fixX()); + y -= MulScale30 (frac, y - curline->v1->fixY()); } z2 = viewz - plane.ZatPoint (x, y); } @@ -3101,7 +3101,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, decalx = FLOAT2FIXED(dcx); decaly = FLOAT2FIXED(dcy); - angle_t ang = R_PointToAngle2 (curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y) >> ANGLETOFINESHIFT; + angle_t ang = R_PointToAngle2 (curline->v1->fixX(), curline->v1->fixY(), curline->v2->fixX(), curline->v2->fixY()) >> ANGLETOFINESHIFT; lx = decalx - FixedMul (x1, finecosine[ang]) - viewx; lx2 = decalx + FixedMul (x2, finecosine[ang]) - viewx; ly = decaly - FixedMul (x1, finesine[ang]) - viewy; diff --git a/src/r_things.cpp b/src/r_things.cpp index a35af4867..158716a31 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2211,8 +2211,8 @@ void R_DrawSprite (vissprite_t *spr) } // Check if sprite is in front of draw seg: if ((!spr->bWallSprite && neardepth > spr->depth) || ((spr->bWallSprite || fardepth > spr->depth) && - DMulScale32(spr->gy - ds->curline->v1->y, ds->curline->v2->x - ds->curline->v1->x, - ds->curline->v1->x - spr->gx, ds->curline->v2->y - ds->curline->v1->y) <= 0)) + DMulScale32(spr->gy - ds->curline->v1->fixY(), ds->curline->v2->fixX() - ds->curline->v1->fixX(), + ds->curline->v1->fixX() - spr->gx, ds->curline->v2->fixY() - ds->curline->v1->fixY()) <= 0)) { // seg is behind sprite, so draw the mid texture if it has one if (ds->CurrentPortalUniq == CurrentPortalUniq && // [ZZ] instead, portal uniq check is made here