From 9a07f812698df3d4f6266a7f357831e1cbc0ad23 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Apr 2016 20:45:32 +0200 Subject: [PATCH] - renamed all ZatPoint variants that return a fixed point value to ZatPointFixed, to avoid accidental mixup with the floating point variants. --- src/actor.h | 4 ---- src/r_bsp.cpp | 24 ++++++++++++------------ src/r_defs.h | 22 +++++++++++++++------- src/r_main.cpp | 6 ++---- src/r_segs.cpp | 18 +++++++++--------- src/r_things.cpp | 14 +++++++------- 6 files changed, 45 insertions(+), 43 deletions(-) diff --git a/src/actor.h b/src/actor.h index b47572f5d..539144ed9 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1265,10 +1265,6 @@ public: if (!moving) Prev.Z = Z(); } - // These are not for general use as they do not link the actor into the world! - void SetXY(fixed_t xx, fixed_t yy) = delete; - void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz) = delete; - void SetXY(const DVector2 &npos) { __Pos.X = npos.X; diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index f1b9e97ae..4f664d1bc 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -395,8 +395,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, } } - fixed_t refceilz = s->ceilingplane.ZatPoint (viewx, viewy); - fixed_t orgceilz = sec->ceilingplane.ZatPoint (viewx, viewy); + fixed_t refceilz = s->ceilingplane.ZatPointFixed (viewx, viewy); + fixed_t orgceilz = sec->ceilingplane.ZatPointFixed(viewx, viewy); #if 1 // [RH] Allow viewing underwater areas through doors/windows that @@ -405,8 +405,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->fixX(), curline->v1->fixY()) && - rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->fixX(), curline->v2->fixY())) + if (rw_frontcz1 <= s->floorplane.ZatPointFixed (curline->v1) && + rw_frontcz2 <= s->floorplane.ZatPointFixed(curline->v2)) { // Check that the window is actually visible for (int z = WallC.sx1; z < WallC.sx2; ++z) @@ -581,10 +581,10 @@ void R_AddLine (seg_t *line) { backsector = line->backsector; } - 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_frontcz1 = frontsector->ceilingplane.ZatPointFixed(line->v1); + rw_frontfz1 = frontsector->floorplane.ZatPointFixed(line->v1); + rw_frontcz2 = frontsector->ceilingplane.ZatPointFixed(line->v2); + rw_frontfz2 = frontsector->floorplane.ZatPointFixed(line->v2); rw_mustmarkfloor = rw_mustmarkceiling = false; rw_havehigh = rw_havelow = false; @@ -603,10 +603,10 @@ void R_AddLine (seg_t *line) } doorclosed = 0; // killough 4/16/98 - 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()); + rw_backcz1 = backsector->ceilingplane.ZatPointFixed (line->v1); + rw_backfz1 = backsector->floorplane.ZatPointFixed(line->v1); + rw_backcz2 = backsector->ceilingplane.ZatPointFixed(line->v2); + rw_backfz2 = backsector->floorplane.ZatPointFixed(line->v2); // Cannot make these walls solid, because it can result in // sprite clipping problems for sprites near the wall diff --git a/src/r_defs.h b/src/r_defs.h index 3b3a0e0e1..10ad53c31 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -365,11 +365,25 @@ public: } // Returns the value of z at (x,y) - fixed_t ZatPoint (fixed_t x, fixed_t y) const + fixed_t ZatPoint(fixed_t x, fixed_t y) const = delete; // it is not allowed to call this. + + fixed_t ZatPointFixed(fixed_t x, fixed_t y) const { return FixedMul (ic, -d - DMulScale16 (a, x, b, y)); } + // This is for the software renderer + fixed_t ZatPointFixed(const DVector2 &pos) const + { + return xs_CRoundToInt((d + a*pos.X + b*pos.Y) * ic / (-65536.0)); + } + + fixed_t ZatPointFixed(const vertex_t *v) const + { + return FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY())); + } + + // Returns the value of z at (x,y) as a double double ZatPoint (double x, double y) const { @@ -381,12 +395,6 @@ public: return (d + a*pos.X + b*pos.Y) * ic / (-65536.0 * 65536.0); } - // This is for the software renderer - fixed_t ZatPointFixed(const DVector2 &pos) const - { - return xs_CRoundToInt((d + a*pos.X + b*pos.Y) * ic / (-65536.0)); - } - double ZatPoint(const vertex_t *v) const { diff --git a/src/r_main.cpp b/src/r_main.cpp index 7509cae84..3577b3c3b 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -728,10 +728,8 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) viewx = FLOAT2FIXED((x1 + r * dx)*2 - x); viewy = FLOAT2FIXED((y1 + r * dy)*2 - y); } - ViewAngle = pds->src->Delta().Angle(); - viewangle = 2*R_PointToAngle2 (pds->src->v1->fixX(), pds->src->v1->fixY(), - pds->src->v2->fixX(), pds->src->v2->fixY()) - startang; - + viewangle = pds->src->Delta().Angle().BAMs() - startang; + ViewAngle = AngleToFloat(viewangle); } else { diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 6b24103d9..0c645f14a 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -274,7 +274,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) { if (!(fake3D & FAKE3D_CLIPTOP)) { - sclipTop = sec->ceilingplane.ZatPoint(viewx, viewy); + sclipTop = sec->ceilingplane.ZatPointFixed(viewx, viewy); } for (i = frontsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--) { @@ -1385,10 +1385,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->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 frontcz1 = ds->curline->frontsector->ceilingplane.ZatPointFixed(ds->curline->v1); + fixed_t frontfz1 = ds->curline->frontsector->floorplane.ZatPointFixed(ds->curline->v1); + fixed_t frontcz2 = ds->curline->frontsector->ceilingplane.ZatPointFixed(ds->curline->v2); + fixed_t frontfz2 = ds->curline->frontsector->floorplane.ZatPointFixed(ds->curline->v2); fixed_t top = MAX(frontcz1, frontcz2); fixed_t bot = MIN(frontfz1, frontfz2); if (fake3D & FAKE3D_CLIPTOP) @@ -2783,7 +2783,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) x -= MulScale30 (frac, x - curline->v1->fixX()); y -= MulScale30 (frac, y - curline->v1->fixY()); } - z1 = viewz - plane.ZatPoint (x, y); + z1 = viewz - plane.ZatPointFixed(x, y); if (wallc->sx2 > wallc->sx1 + 1) { @@ -2795,7 +2795,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) x += MulScale30 (frac, curline->v2->fixX() - x); y += MulScale30 (frac, curline->v2->fixY() - y); } - z2 = viewz - plane.ZatPoint (x, y); + z2 = viewz - plane.ZatPointFixed(x, y); } else { @@ -2812,7 +2812,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) x += MulScale30 (frac, curline->v2->fixX() - x); y += MulScale30 (frac, curline->v2->fixY() - y); } - z1 = viewz - plane.ZatPoint (x, y); + z1 = viewz - plane.ZatPointFixed(x, y); if (wallc->sx2 > wallc->sx1 + 1) { @@ -2824,7 +2824,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) x -= MulScale30 (frac, x - curline->v1->fixX()); y -= MulScale30 (frac, y - curline->v1->fixY()); } - z2 = viewz - plane.ZatPoint (x, y); + z2 = viewz - plane.ZatPointFixed(x, y); } else { diff --git a/src/r_things.cpp b/src/r_things.cpp index fa7d8a88b..7eb1095da 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -937,19 +937,19 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor { if (fakeside == FAKED_AboveCeiling) { - if (gzt < heightsec->ceilingplane.ZatPoint (fx, fy)) + if (gzt < heightsec->ceilingplane.ZatPointFixed(fx, fy)) return; } else if (fakeside == FAKED_BelowFloor) { - if (gzb >= heightsec->floorplane.ZatPoint (fx, fy)) + if (gzb >= heightsec->floorplane.ZatPointFixed(fx, fy)) return; } else { - if (gzt < heightsec->floorplane.ZatPoint (fx, fy)) + if (gzt < heightsec->floorplane.ZatPointFixed(fx, fy)) return; - if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPoint (fx, fy)) + if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPointFixed(fx, fy)) return; } } @@ -1931,7 +1931,7 @@ void R_DrawSprite (vissprite_t *spr) { if (!(fake3D & FAKE3D_CLIPTOP)) { - sclipTop = spr->sector->ceilingplane.ZatPoint(viewx, viewy); + sclipTop = spr->sector->ceilingplane.ZatPointFixed(viewx, viewy); } sector_t *sec = NULL; for (i = spr->sector->e->XFloor.lightlist.Size() - 1; i >= 0; i--) @@ -2031,7 +2031,7 @@ void R_DrawSprite (vissprite_t *spr) { // only things in specially marked sectors if (spr->FakeFlatStat != FAKED_AboveCeiling) { - fixed_t hz = spr->heightsec->floorplane.ZatPoint (spr->gx, spr->gy); + fixed_t hz = spr->heightsec->floorplane.ZatPointFixed(spr->gx, spr->gy); fixed_t h = (centeryfrac - FixedMul (hz-viewz, scale)) >> FRACBITS; if (spr->FakeFlatStat == FAKED_BelowFloor) @@ -2053,7 +2053,7 @@ void R_DrawSprite (vissprite_t *spr) } if (spr->FakeFlatStat != FAKED_BelowFloor && !(spr->heightsec->MoreFlags & SECF_FAKEFLOORONLY)) { - fixed_t hz = spr->heightsec->ceilingplane.ZatPoint (spr->gx, spr->gy); + fixed_t hz = spr->heightsec->ceilingplane.ZatPointFixed(spr->gx, spr->gy); fixed_t h = (centeryfrac - FixedMul (hz-viewz, scale)) >> FRACBITS; if (spr->FakeFlatStat == FAKED_AboveCeiling)