Merge branch 'master' of c:\programming\doom-dev\zdoom

# Conflicts:
#	src/r_defs.h
This commit is contained in:
Christoph Oelckers 2016-04-23 09:43:21 +02:00
commit ba37854e44
28 changed files with 1040 additions and 1172 deletions

View file

@ -294,11 +294,11 @@ R_DrawTiltedPlane_ASM:
fmul dword [planelightfloat] fmul dword [planelightfloat]
fxch st1 fxch st1
fmul dword [planelightfloat] fmul dword [planelightfloat]
sub esp,8 sub esp,16
fistp dword [esp] fstp qword [esp]
fistp dword [esp+4] fstp qword [esp+8]
call R_CalcTiltedLighting call R_CalcTiltedLighting
add esp, 12 add esp, 20
xor eax, eax xor eax, eax
.litup add esp, 8 .litup add esp, 8

View file

@ -347,9 +347,6 @@ void P_SerializeWorld (FArchive &arc)
<< sec->seqType << sec->seqType
<< sec->friction << sec->friction
<< sec->movefactor << sec->movefactor
<< sec->floordata
<< sec->ceilingdata
<< sec->lightingdata
<< sec->stairlock << sec->stairlock
<< sec->prevsec << sec->prevsec
<< sec->nextsec << sec->nextsec
@ -464,7 +461,10 @@ void P_SerializeWorldActors(FArchive &arc)
for (i = 0, sec = sectors; i < numsectors; i++, sec++) for (i = 0, sec = sectors; i < numsectors; i++, sec++)
{ {
arc << sec->SoundTarget arc << sec->SoundTarget
<< sec->SecActTarget; << sec->SecActTarget
<< sec->floordata
<< sec->ceilingdata
<< sec->lightingdata;
} }
for (auto &s : sectorPortals) for (auto &s : sectorPortals)
{ {
@ -485,8 +485,8 @@ void extsector_t::Serialize(FArchive &arc)
FArchive &operator<< (FArchive &arc, side_t::part &p) FArchive &operator<< (FArchive &arc, side_t::part &p)
{ {
arc << p.xoffset << p.yoffset << p.interpolation << p.texture arc << p.xOffset << p.yOffset << p.interpolation << p.texture
<< p.xscale << p.yscale;// << p.Light; << p.xScale << p.yScale;// << p.Light;
return arc; return arc;
} }

View file

@ -549,8 +549,8 @@ void P_SpawnScrollers(void)
case Scroll_Texture_Offsets: case Scroll_Texture_Offsets:
// killough 3/2/98: scroll according to sidedef offsets // killough 3/2/98: scroll according to sidedef offsets
s = int(lines[i].sidedef[0] - sides); s = int(lines[i].sidedef[0] - sides);
new DScroller (EScroll::sc_side, -sides[s].GetTextureXOffset(side_t::mid), new DScroller (EScroll::sc_side, -sides[s].GetTextureXOffsetF(side_t::mid),
sides[s].GetTextureYOffset(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0])); sides[s].GetTextureYOffsetF(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0]));
break; break;
case Scroll_Texture_Left: case Scroll_Texture_Left:

View file

@ -2627,10 +2627,10 @@ void P_LoadSideDefs2 (MapData *map, FMissingTextureTracker &missingtex)
msd->rowoffset += 102; msd->rowoffset += 102;
} }
sd->SetTextureXOffset(LittleShort(msd->textureoffset)<<FRACBITS); sd->SetTextureXOffset(LittleShort(msd->textureoffset));
sd->SetTextureYOffset(LittleShort(msd->rowoffset)<<FRACBITS); sd->SetTextureYOffset(LittleShort(msd->rowoffset));
sd->SetTextureXScale(FRACUNIT); sd->SetTextureXScale(1.);
sd->SetTextureYScale(FRACUNIT); sd->SetTextureYScale(1.);
sd->linedef = NULL; sd->linedef = NULL;
sd->Flags = 0; sd->Flags = 0;
sd->Index = i; sd->Index = i;

View file

@ -21,8 +21,8 @@ F3DFloor *fakeFloor;
fixed_t fakeHeight; fixed_t fakeHeight;
fixed_t fakeAlpha; fixed_t fakeAlpha;
int fakeActive = 0; int fakeActive = 0;
fixed_t sclipBottom; double sclipBottom;
fixed_t sclipTop; double sclipTop;
HeightLevel *height_top = NULL; HeightLevel *height_top = NULL;
HeightLevel *height_cur = NULL; HeightLevel *height_cur = NULL;
int CurrentMirror = 0; int CurrentMirror = 0;

View file

@ -7,7 +7,7 @@
struct HeightLevel struct HeightLevel
{ {
fixed_t height; double height;
struct HeightLevel *prev; struct HeightLevel *prev;
struct HeightLevel *next; struct HeightLevel *next;
}; };
@ -51,8 +51,8 @@ extern int fake3D;
extern F3DFloor *fakeFloor; extern F3DFloor *fakeFloor;
extern fixed_t fakeAlpha; extern fixed_t fakeAlpha;
extern int fakeActive; extern int fakeActive;
extern fixed_t sclipBottom; extern double sclipBottom;
extern fixed_t sclipTop; extern double sclipTop;
extern HeightLevel *height_top; extern HeightLevel *height_top;
extern HeightLevel *height_cur; extern HeightLevel *height_cur;
extern int CurrentMirror; extern int CurrentMirror;

View file

@ -78,10 +78,10 @@ extern short wallbottom[MAXWIDTH];
extern short wallupper[MAXWIDTH]; extern short wallupper[MAXWIDTH];
extern short walllower[MAXWIDTH]; extern short walllower[MAXWIDTH];
fixed_t rw_backcz1, rw_backcz2; double rw_backcz1, rw_backcz2;
fixed_t rw_backfz1, rw_backfz2; double rw_backfz1, rw_backfz2;
fixed_t rw_frontcz1, rw_frontcz2; double rw_frontcz1, rw_frontcz2;
fixed_t rw_frontfz1, rw_frontfz2; double rw_frontfz1, rw_frontfz2;
size_t MaxDrawSegs; size_t MaxDrawSegs;
@ -336,7 +336,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
{ {
sector_t *heightsec = viewsector->heightsec; sector_t *heightsec = viewsector->heightsec;
bool underwater = r_fakingunderwater || bool underwater = r_fakingunderwater ||
(heightsec && heightsec->floorplane.PointOnSide(viewx, viewy, viewz) <= 0); (heightsec && heightsec->floorplane.PointOnSide(ViewPos) <= 0);
bool doorunderwater = false; bool doorunderwater = false;
int diffTex = (s->MoreFlags & SECF_CLIPFAKEPLANES); int diffTex = (s->MoreFlags & SECF_CLIPFAKEPLANES);
@ -395,8 +395,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
} }
} }
fixed_t refceilz = s->ceilingplane.ZatPointFixed (viewx, viewy); double refceilz = s->ceilingplane.ZatPoint(ViewPos);
fixed_t orgceilz = sec->ceilingplane.ZatPointFixed(viewx, viewy); double orgceilz = sec->ceilingplane.ZatPoint(ViewPos);
#if 1 #if 1
// [RH] Allow viewing underwater areas through doors/windows that // [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. // sectors at the same time.
if (back && !r_fakingunderwater && curline->frontsector->heightsec == NULL) if (back && !r_fakingunderwater && curline->frontsector->heightsec == NULL)
{ {
if (rw_frontcz1 <= s->floorplane.ZatPointFixed (curline->v1) && if (rw_frontcz1 <= s->floorplane.ZatPoint(curline->v1) &&
rw_frontcz2 <= s->floorplane.ZatPointFixed(curline->v2)) rw_frontcz2 <= s->floorplane.ZatPoint(curline->v2))
{ {
// Check that the window is actually visible // Check that the window is actually visible
for (int z = WallC.sx1; z < WallC.sx2; ++z) for (int z = WallC.sx1; z < WallC.sx2; ++z)
@ -470,7 +470,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
} }
FakeSide = FAKED_BelowFloor; FakeSide = FAKED_BelowFloor;
} }
else if (heightsec && heightsec->ceilingplane.PointOnSide(viewx, viewy, viewz) <= 0 && else if (heightsec && heightsec->ceilingplane.PointOnSide(ViewPos) <= 0 &&
orgceilz > refceilz && !(s->MoreFlags & SECF_FAKEFLOORONLY)) orgceilz > refceilz && !(s->MoreFlags & SECF_FAKEFLOORONLY))
{ // Above-ceiling hack { // Above-ceiling hack
tempsec->ceilingplane = s->ceilingplane; tempsec->ceilingplane = s->ceilingplane;
@ -540,23 +540,21 @@ void R_AddLine (seg_t *line)
{ {
static sector_t tempsec; // killough 3/8/98: ceiling/water hack static sector_t tempsec; // killough 3/8/98: ceiling/water hack
bool solid; bool solid;
fixed_t tx1, tx2, ty1, ty2; DVector2 pt1, pt2;
curline = line; curline = line;
// [RH] Color if not texturing line // [RH] Color if not texturing line
dc_color = (((int)(line - segs) * 8) + 4) & 255; dc_color = (((int)(line - segs) * 8) + 4) & 255;
tx1 = line->v1->fixX() - viewx; pt1 = line->v1->fPos() - ViewPos;
tx2 = line->v2->fixX() - viewx; pt2 = line->v2->fPos() - ViewPos;
ty1 = line->v1->fixY() - viewy;
ty2 = line->v2->fixY() - viewy;
// Reject lines not facing viewer // Reject lines not facing viewer
if (DMulScale32 (ty1, tx1-tx2, tx1, ty2-ty1) >= 0) if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0)
return; return;
if (WallC.Init(tx1, ty1, tx2, ty2, 32)) if (WallC.Init(pt1, pt2, 32.0 / (1 << 12)))
return; return;
if (WallC.sx1 >= WindowRight || WallC.sx2 <= WindowLeft) if (WallC.sx1 >= WindowRight || WallC.sx2 <= WindowLeft)
@ -591,17 +589,17 @@ void R_AddLine (seg_t *line)
{ {
swapvalues (v1, v2); swapvalues (v1, v2);
} }
WallT.InitFromLine(v1->fixX() - viewx, v1->fixY() - viewy, v2->fixX() - viewx, v2->fixY() - viewy); WallT.InitFromLine(v1->fPos() - ViewPos, v2->fPos() - ViewPos);
} }
if (!(fake3D & FAKE3D_FAKEBACK)) if (!(fake3D & FAKE3D_FAKEBACK))
{ {
backsector = line->backsector; backsector = line->backsector;
} }
rw_frontcz1 = frontsector->ceilingplane.ZatPointFixed(line->v1); rw_frontcz1 = frontsector->ceilingplane.ZatPoint(line->v1);
rw_frontfz1 = frontsector->floorplane.ZatPointFixed(line->v1); rw_frontfz1 = frontsector->floorplane.ZatPoint(line->v1);
rw_frontcz2 = frontsector->ceilingplane.ZatPointFixed(line->v2); rw_frontcz2 = frontsector->ceilingplane.ZatPoint(line->v2);
rw_frontfz2 = frontsector->floorplane.ZatPointFixed(line->v2); rw_frontfz2 = frontsector->floorplane.ZatPoint(line->v2);
rw_mustmarkfloor = rw_mustmarkceiling = false; rw_mustmarkfloor = rw_mustmarkceiling = false;
rw_havehigh = rw_havelow = false; rw_havehigh = rw_havelow = false;
@ -620,10 +618,10 @@ void R_AddLine (seg_t *line)
} }
doorclosed = 0; // killough 4/16/98 doorclosed = 0; // killough 4/16/98
rw_backcz1 = backsector->ceilingplane.ZatPointFixed (line->v1); rw_backcz1 = backsector->ceilingplane.ZatPoint(line->v1);
rw_backfz1 = backsector->floorplane.ZatPointFixed(line->v1); rw_backfz1 = backsector->floorplane.ZatPoint(line->v1);
rw_backcz2 = backsector->ceilingplane.ZatPointFixed(line->v2); rw_backcz2 = backsector->ceilingplane.ZatPoint(line->v2);
rw_backfz2 = backsector->floorplane.ZatPointFixed(line->v2); rw_backfz2 = backsector->floorplane.ZatPoint(line->v2);
// Cannot make these walls solid, because it can result in // Cannot make these walls solid, because it can result in
// sprite clipping problems for sprites near the wall // sprite clipping problems for sprites near the wall
@ -773,57 +771,55 @@ void R_AddLine (seg_t *line)
// //
// Transform and clip coordinates. Returns true if it was clipped away // Transform and clip coordinates. Returns true if it was clipped away
// //
bool FWallCoords::Init(int x1, int y1, int x2, int y2, int too_close) bool FWallCoords::Init(const DVector2 &pt1, const DVector2 &pt2, double too_close)
{ {
tx1 = DMulScale20(x1, viewsin, -y1, viewcos); tleft.X = float(pt1.X * ViewSin - pt1.Y * ViewCos);
tx2 = DMulScale20(x2, viewsin, -y2, viewcos); tright.X = float(pt2.X * ViewSin - pt2.Y * ViewCos);
ty1 = DMulScale20(x1, viewtancos, y1, viewtansin); tleft.Y = float(pt1.X * ViewTanCos + pt1.Y * ViewTanSin);
ty2 = DMulScale20(x2, viewtancos, y2, viewtansin); tright.Y = float(pt2.X * ViewTanCos + pt2.Y * ViewTanSin);
if (MirrorFlags & RF_XFLIP) if (MirrorFlags & RF_XFLIP)
{ {
int t = 256 - tx1; float t = -tleft.X;
tx1 = 256 - tx2; tleft.X = -tright.X;
tx2 = t; tright.X = t;
swapvalues(ty1, ty2); swapvalues(tleft.Y, tright.Y);
} }
if (tx1 >= -ty1) if (tleft.X >= -tleft.Y)
{ {
if (tx1 > ty1) return true; // left edge is off the right side if (tleft.X > tleft.Y) return true; // left edge is off the right side
if (ty1 == 0) return true; if (tleft.Y == 0) return true;
sx1 = (centerxfrac + Scale(tx1, centerxfrac, ty1)) >> FRACBITS; sx1 = xs_RoundToInt(CenterX + tleft.X * CenterX / tleft.Y);
if (tx1 >= 0) sx1 = MIN(viewwidth, sx1+1); // fix for signed divide sz1 = tleft.Y;
sz1 = ty1;
} }
else else
{ {
if (tx2 < -ty2) return true; // wall is off the left side if (tright.X < -tright.Y) return true; // wall is off the left side
fixed_t den = tx1 - tx2 - ty2 + ty1; float den = tleft.X - tright.X - tright.Y + tleft.Y;
if (den == 0) return true; if (den == 0) return true;
sx1 = 0; sx1 = 0;
sz1 = ty1 + Scale(ty2 - ty1, tx1 + ty1, den); sz1 = tleft.Y + (tright.Y - tleft.Y) * (tleft.X + tleft.Y) / den;
} }
if (sz1 < too_close) if (sz1 < too_close)
return true; return true;
if (tx2 <= ty2) if (tright.X <= tright.Y)
{ {
if (tx2 < -ty2) return true; // right edge is off the left side if (tright.X < -tright.Y) return true; // right edge is off the left side
if (ty2 == 0) return true; if (tright.Y == 0) return true;
sx2 = (centerxfrac + Scale(tx2, centerxfrac, ty2)) >> FRACBITS; sx2 = xs_RoundToInt(CenterX + tright.X * CenterX / tright.Y);
if (tx2 >= 0) sx2 = MIN(viewwidth, sx2+1); // fix for signed divide sz2 = tright.Y;
sz2 = ty2;
} }
else else
{ {
if (tx1 > ty1) return true; // wall is off the right side if (tleft.X > tleft.Y) return true; // wall is off the right side
fixed_t den = ty2 - ty1 - tx2 + tx1; float den = tright.Y - tleft.Y - tright.X + tleft.X;
if (den == 0) return true; if (den == 0) return true;
sx2 = viewwidth; sx2 = viewwidth;
sz2 = ty1 + Scale(ty2 - ty1, tx1 - ty1, den); sz2 = tleft.Y + (tright.Y - tleft.Y) * (tleft.X - tleft.Y) / den;
} }
if (sz2 < too_close || sx2 <= sx1) if (sz2 < too_close || sx2 <= sx1)
@ -834,28 +830,25 @@ bool FWallCoords::Init(int x1, int y1, int x2, int y2, int too_close)
void FWallTmapVals::InitFromWallCoords(const FWallCoords *wallc) void FWallTmapVals::InitFromWallCoords(const FWallCoords *wallc)
{ {
const FVector2 *left = &wallc->tleft;
const FVector2 *right = &wallc->tright;
if (MirrorFlags & RF_XFLIP) if (MirrorFlags & RF_XFLIP)
{ {
UoverZorg = (float)wallc->tx2 * centerx; swapvalues(left, right);
UoverZstep = (float)(-wallc->ty2);
InvZorg = (float)(wallc->tx2 - wallc->tx1) * centerx;
InvZstep = (float)(wallc->ty1 - wallc->ty2);
}
else
{
UoverZorg = (float)wallc->tx1 * centerx;
UoverZstep = (float)(-wallc->ty1);
InvZorg = (float)(wallc->tx1 - wallc->tx2) * centerx;
InvZstep = (float)(wallc->ty2 - wallc->ty1);
} }
UoverZorg = left->X * centerx;
UoverZstep = -left->Y;
InvZorg = (left->X - right->X) * centerx;
InvZstep = right->Y - left->Y;
} }
void FWallTmapVals::InitFromLine(int tx1, int ty1, int tx2, int ty2) void FWallTmapVals::InitFromLine(const DVector2 &left, const DVector2 &right)
{ // Coordinates should have already had viewx,viewy subtracted { // Coordinates should have already had viewx,viewy subtracted
fixed_t fullx1 = DMulScale20 (tx1, viewsin, -ty1, viewcos); double fullx1 = left.X * ViewSin - left.Y * ViewCos;
fixed_t fullx2 = DMulScale20 (tx2, viewsin, -ty2, viewcos); double fullx2 = right.X * ViewSin - right.Y * ViewCos;
fixed_t fully1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin); double fully1 = left.X * ViewTanCos + left.Y * ViewTanSin;
fixed_t fully2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin); double fully2 = right.X * ViewTanCos + right.Y * ViewTanSin;
if (MirrorFlags & RF_XFLIP) if (MirrorFlags & RF_XFLIP)
{ {
@ -863,10 +856,10 @@ void FWallTmapVals::InitFromLine(int tx1, int ty1, int tx2, int ty2)
fullx2 = -fullx2; fullx2 = -fullx2;
} }
UoverZorg = (float)fullx1 * centerx; UoverZorg = float(fullx1 * centerx);
UoverZstep = (float)(-fully1); UoverZstep = float(-fully1);
InvZorg = (float)(fullx1 - fullx2) * centerx; InvZorg = float((fullx1 - fullx2) * centerx);
InvZstep = (float)(fully2 - fully1); InvZstep = float(fully2 - fully1);
} }
// //
@ -896,24 +889,24 @@ static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
int boxy; int boxy;
int boxpos; int boxpos;
fixed_t x1, y1, x2, y2; double x1, y1, x2, y2;
fixed_t rx1, ry1, rx2, ry2; double rx1, ry1, rx2, ry2;
int sx1, sx2; int sx1, sx2;
cliprange_t* start; cliprange_t* start;
// Find the corners of the box // Find the corners of the box
// that define the edges from current viewpoint. // that define the edges from current viewpoint.
if (viewx <= bspcoord[BOXLEFT]) if (ViewPos.X <= FIXED2DBL(bspcoord[BOXLEFT]))
boxx = 0; boxx = 0;
else if (viewx < bspcoord[BOXRIGHT]) else if (ViewPos.X < FIXED2DBL(bspcoord[BOXRIGHT]))
boxx = 1; boxx = 1;
else else
boxx = 2; boxx = 2;
if (viewy >= bspcoord[BOXTOP]) if (ViewPos.Y >= FIXED2DBL(bspcoord[BOXTOP]))
boxy = 0; boxy = 0;
else if (viewy > bspcoord[BOXBOTTOM]) else if (ViewPos.Y > FIXED2DBL(bspcoord[BOXBOTTOM]))
boxy = 1; boxy = 1;
else else
boxy = 2; boxy = 2;
@ -922,26 +915,26 @@ static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
if (boxpos == 5) if (boxpos == 5)
return true; return true;
x1 = bspcoord[checkcoord[boxpos][0]] - viewx; x1 = FIXED2DBL(bspcoord[checkcoord[boxpos][0]]) - ViewPos.X;
y1 = bspcoord[checkcoord[boxpos][1]] - viewy; y1 = FIXED2DBL(bspcoord[checkcoord[boxpos][1]]) - ViewPos.Y;
x2 = bspcoord[checkcoord[boxpos][2]] - viewx; x2 = FIXED2DBL(bspcoord[checkcoord[boxpos][2]]) - ViewPos.X;
y2 = bspcoord[checkcoord[boxpos][3]] - viewy; y2 = FIXED2DBL(bspcoord[checkcoord[boxpos][3]]) - ViewPos.Y;
// check clip list for an open space // check clip list for an open space
// Sitting on a line? // Sitting on a line?
if (DMulScale32 (y1, x1-x2, x1, y2-y1) >= 0) if (y1 * (x1 - x2) + x1 * (y2 - y1) >= -EQUAL_EPSILON)
return true; return true;
rx1 = DMulScale20 (x1, viewsin, -y1, viewcos); rx1 = x1 * ViewSin - y1 * ViewCos;
rx2 = DMulScale20 (x2, viewsin, -y2, viewcos); rx2 = x2 * ViewSin - y2 * ViewCos;
ry1 = DMulScale20 (x1, viewtancos, y1, viewtansin); ry1 = x1 * ViewTanCos + y1 * ViewTanSin;
ry2 = DMulScale20 (x2, viewtancos, y2, viewtansin); ry2 = x2 * ViewTanCos + y2 * ViewTanSin;
if (MirrorFlags & RF_XFLIP) if (MirrorFlags & RF_XFLIP)
{ {
int t = 256-rx1; double t = -rx1;
rx1 = 256-rx2; rx1 = -rx2;
rx2 = t; rx2 = t;
swapvalues(ry1, ry2); swapvalues(ry1, ry2);
} }
@ -950,8 +943,7 @@ static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
{ {
if (rx1 > ry1) return false; // left edge is off the right side if (rx1 > ry1) return false; // left edge is off the right side
if (ry1 == 0) return false; if (ry1 == 0) return false;
sx1 = (centerxfrac + Scale (rx1, centerxfrac, ry1)) >> FRACBITS; sx1 = xs_RoundToInt(CenterX + rx1 * CenterX / ry1);
if (rx1 >= 0) sx1 = MIN<int> (viewwidth, sx1+1); // fix for signed divide
} }
else else
{ {
@ -964,8 +956,7 @@ static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
{ {
if (rx2 < -ry2) return false; // right edge is off the left side if (rx2 < -ry2) return false; // right edge is off the left side
if (ry2 == 0) return false; if (ry2 == 0) return false;
sx2 = (centerxfrac + Scale (rx2, centerxfrac, ry2)) >> FRACBITS; sx2 = xs_RoundToInt(CenterX + rx2 * CenterX / ry2);
if (rx2 >= 0) sx2 = MIN<int> (viewwidth, sx2+1); // fix for signed divide
} }
else else
{ {
@ -1116,7 +1107,7 @@ void R_Subsector (subsector_t *sub)
portal = frontsector->ValidatePortal(sector_t::ceiling); portal = frontsector->ValidatePortal(sector_t::ceiling);
ceilingplane = frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz) > 0 || ceilingplane = frontsector->ceilingplane.PointOnSide(ViewPos) > 0 ||
frontsector->GetTexture(sector_t::ceiling) == skyflatnum || frontsector->GetTexture(sector_t::ceiling) == skyflatnum ||
portal != NULL || portal != NULL ||
(frontsector->heightsec && (frontsector->heightsec &&
@ -1157,7 +1148,7 @@ void R_Subsector (subsector_t *sub)
// killough 10/98: add support for skies transferred from sidedefs // killough 10/98: add support for skies transferred from sidedefs
portal = frontsector->ValidatePortal(sector_t::floor); portal = frontsector->ValidatePortal(sector_t::floor);
floorplane = frontsector->floorplane.PointOnSide(viewx, viewy, viewz) > 0 || // killough 3/7/98 floorplane = frontsector->floorplane.PointOnSide(ViewPos) > 0 || // killough 3/7/98
frontsector->GetTexture(sector_t::floor) == skyflatnum || frontsector->GetTexture(sector_t::floor) == skyflatnum ||
portal != NULL || portal != NULL ||
(frontsector->heightsec && (frontsector->heightsec &&
@ -1408,7 +1399,7 @@ void R_RenderBSPNode (void *node)
node_t *bsp = (node_t *)node; node_t *bsp = (node_t *)node;
// Decide which side the view point is on. // Decide which side the view point is on.
int side = R_PointOnSide (viewx, viewy, bsp); int side = R_PointOnSide (ViewPos, bsp);
// Recursively divide front space (toward the viewer). // Recursively divide front space (toward the viewer).
R_RenderBSPNode (bsp->children[side]); R_RenderBSPNode (bsp->children[side]);

View file

@ -30,17 +30,17 @@
// The 3072 below is just an arbitrary value picked to avoid // The 3072 below is just an arbitrary value picked to avoid
// drawing lines the player is too close to that would overflow // drawing lines the player is too close to that would overflow
// the texture calculations. // the texture calculations.
#define TOO_CLOSE_Z 3072 #define TOO_CLOSE_Z (3072.0 / (1<<12))
struct FWallCoords struct FWallCoords
{ {
fixed_t tx1, tx2; // x coords at left, right of wall in view space rx1,rx2 FVector2 tleft; // coords at left of wall in view space rx1,ry1
fixed_t ty1, ty2; // y coords at left, right of wall in view space ry1,ry2 FVector2 tright; // coords at right of wall in view space rx2,ry2
float sz1, sz2; // depth at left, right of wall in screen space yb1,yb2
short sx1, sx2; // x coords at left, right of wall in screen space xb1,xb2 short sx1, sx2; // x coords at left, right of wall in screen space xb1,xb2
fixed_t sz1, sz2; // depth at left, right of wall in screen space yb1,yb2
bool Init(int x1, int y1, int x2, int y2, int too_close); bool Init(const DVector2 &pt1, const DVector2 &pt2, double too_close);
}; };
struct FWallTmapVals struct FWallTmapVals
@ -49,7 +49,7 @@ struct FWallTmapVals
float InvZorg, InvZstep; float InvZorg, InvZstep;
void InitFromWallCoords(const FWallCoords *wallc); void InitFromWallCoords(const FWallCoords *wallc);
void InitFromLine(int x1, int y1, int x2, int y2); void InitFromLine(const DVector2 &left, const DVector2 &right);
}; };
extern FWallCoords WallC; extern FWallCoords WallC;
@ -65,14 +65,14 @@ enum
struct drawseg_t struct drawseg_t
{ {
seg_t* curline; seg_t* curline;
fixed_t light, lightstep; float light, lightstep;
fixed_t iscale, iscalestep; float iscale, iscalestep;
short x1, x2; // Same as sx1 and sx2, but clipped to the drawseg short x1, x2; // Same as sx1 and sx2, but clipped to the drawseg
short sx1, sx2; // left, right of parent seg on screen short sx1, sx2; // left, right of parent seg on screen
fixed_t sz1, sz2; // z for left, right of parent seg on screen float sz1, sz2; // z for left, right of parent seg on screen
fixed_t siz1, siz2; // 1/z for left, right of parent seg on screen float siz1, siz2; // 1/z for left, right of parent seg on screen
fixed_t cx, cy, cdx, cdy; float cx, cy, cdx, cdy;
fixed_t yrepeat; float yscale;
BYTE silhouette; // 0=none, 1=bottom, 2=top, 3=both BYTE silhouette; // 0=none, 1=bottom, 2=top, 3=both
BYTE bFogBoundary; BYTE bFogBoundary;
BYTE bFakeBoundary; // for fake walls BYTE bFakeBoundary; // for fake walls
@ -82,7 +82,7 @@ struct drawseg_t
ptrdiff_t sprtopclip; // type short ptrdiff_t sprtopclip; // type short
ptrdiff_t sprbottomclip; // type short ptrdiff_t sprbottomclip; // type short
ptrdiff_t maskedtexturecol; // type short ptrdiff_t maskedtexturecol; // type short
ptrdiff_t swall; // type fixed_t ptrdiff_t swall; // type float
int fake; // ident fake drawseg, don't draw and clip sprites int fake; // ident fake drawseg, don't draw and clip sprites
// backups // backups
ptrdiff_t bkup; // sprtopclip backup, for mid and fake textures ptrdiff_t bkup; // sprtopclip backup, for mid and fake textures

View file

@ -351,9 +351,9 @@ public:
} }
// Returns the value of z at (0,0) This is used by the 3D floor code which does not handle slopes // Returns the value of z at (0,0) This is used by the 3D floor code which does not handle slopes
fixed_t Zat0 () const double Zat0() const
{ {
return FLOAT2FIXED(negiC*D); return negiC*D;
} }
// Returns the value of z at (x,y) // Returns the value of z at (x,y)
@ -387,6 +387,10 @@ public:
return (D + normal.X*pos.X + normal.Y*pos.Y) * negiC; return (D + normal.X*pos.X + normal.Y*pos.Y) * negiC;
} }
double ZatPoint(const FVector2 &pos) const
{
return (D + normal.X*pos.X + normal.Y*pos.Y) * negiC;
}
double ZatPoint(const vertex_t *v) const double ZatPoint(const vertex_t *v) const
{ {
@ -1200,10 +1204,10 @@ struct side_t
}; };
struct part struct part
{ {
fixed_t xoffset; double xOffset;
fixed_t yoffset; double yOffset;
fixed_t xscale; double xScale;
fixed_t yscale; double yScale;
FTextureID texture; FTextureID texture;
TObjPtr<DInterpolation> interpolation; TObjPtr<DInterpolation> interpolation;
//int Light; //int Light;
@ -1236,139 +1240,88 @@ struct side_t
textures[which].texture = tex; textures[which].texture = tex;
} }
void SetTextureXOffset(int which, fixed_t offset)
{
textures[which].xoffset = offset;
}
void SetTextureXOffset(fixed_t offset)
{
textures[top].xoffset =
textures[mid].xoffset =
textures[bottom].xoffset = offset;
}
void SetTextureXOffset(int which, double offset) void SetTextureXOffset(int which, double offset)
{ {
textures[which].xoffset = FLOAT2FIXED(offset); textures[which].xOffset = offset;;
} }
void SetTextureXOffset(double offset) void SetTextureXOffset(double offset)
{ {
textures[top].xoffset = textures[top].xOffset =
textures[mid].xoffset = textures[mid].xOffset =
textures[bottom].xoffset = FLOAT2FIXED(offset); textures[bottom].xOffset = offset;
}
fixed_t GetTextureXOffset(int which) const
{
return textures[which].xoffset;
} }
fixed_t GetTextureXOffset(int which) const = delete;
double GetTextureXOffsetF(int which) const double GetTextureXOffsetF(int which) const
{ {
return FIXED2DBL(textures[which].xoffset); return textures[which].xOffset;
}
void AddTextureXOffset(int which, fixed_t delta)
{
textures[which].xoffset += delta;
} }
void AddTextureXOffset(int which, fixed_t delta) = delete;
void AddTextureXOffset(int which, double delta) void AddTextureXOffset(int which, double delta)
{ {
textures[which].xoffset += FLOAT2FIXED(delta); textures[which].xOffset += delta;
} }
void SetTextureYOffset(int which, fixed_t offset)
{
textures[which].yoffset = offset;
}
void SetTextureYOffset(fixed_t offset)
{
textures[top].yoffset =
textures[mid].yoffset =
textures[bottom].yoffset = offset;
}
void SetTextureYOffset(int which, double offset) void SetTextureYOffset(int which, double offset)
{ {
textures[which].yoffset = FLOAT2FIXED(offset); textures[which].yOffset = offset;
} }
void SetTextureYOffset(double offset) void SetTextureYOffset(double offset)
{ {
textures[top].yoffset = textures[top].yOffset =
textures[mid].yoffset = textures[mid].yOffset =
textures[bottom].yoffset = FLOAT2FIXED(offset); textures[bottom].yOffset = offset;
}
fixed_t GetTextureYOffset(int which) const
{
return textures[which].yoffset;
} }
fixed_t GetTextureYOffset(int which) const = delete;
double GetTextureYOffsetF(int which) const double GetTextureYOffsetF(int which) const
{ {
return FIXED2DBL(textures[which].yoffset); return textures[which].yOffset;
}
void AddTextureYOffset(int which, fixed_t delta)
{
textures[which].yoffset += delta;
} }
void AddTextureYOffset(int which, fixed_t delta) = delete;
void AddTextureYOffset(int which, double delta) void AddTextureYOffset(int which, double delta)
{ {
textures[which].yoffset += FLOAT2FIXED(delta); textures[which].yOffset += delta;
} }
void SetTextureXScale(int which, fixed_t scale) void SetTextureXScale(int which, fixed_t scale) = delete;
{
textures[which].xscale = scale == 0 ? FRACUNIT : scale;
}
void SetTextureXScale(int which, double scale) void SetTextureXScale(int which, double scale)
{ {
textures[which].xscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale); textures[which].xScale = scale == 0 ? 1. : scale;
}
void SetTextureXScale(fixed_t scale)
{
textures[top].xscale = textures[mid].xscale = textures[bottom].xscale = scale == 0 ? FRACUNIT : scale;
} }
void SetTextureXScale(fixed_t scale) = delete;
void SetTextureXScale(double scale) void SetTextureXScale(double scale)
{ {
textures[top].xscale = textures[mid].xscale = textures[bottom].xscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale); textures[top].xScale = textures[mid].xScale = textures[bottom].xScale = scale == 0 ? 1. : scale;
}
fixed_t GetTextureXScale(int which) const
{
return textures[which].xscale;
} }
fixed_t GetTextureXScale(int which) const = delete;
double GetTextureXScaleF(int which) const double GetTextureXScaleF(int which) const
{ {
return FIXED2DBL(textures[which].xscale); return textures[which].xScale;
} }
void MultiplyTextureXScale(int which, double delta) void MultiplyTextureXScale(int which, double delta)
{ {
textures[which].xscale = fixed_t(textures[which].xscale * delta); textures[which].xScale *= delta;
}
void SetTextureYScale(int which, fixed_t scale)
{
textures[which].yscale = scale == 0 ? FRACUNIT : scale;
} }
void SetTextureYScale(int which, fixed_t scale) = delete;
void SetTextureYScale(int which, double scale) void SetTextureYScale(int which, double scale)
{ {
textures[which].yscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale); textures[which].yScale = scale == 0 ? 1. : scale;
} }
void SetTextureYScale(fixed_t scale) void SetTextureYScale(fixed_t scale) = delete;
{
textures[top].yscale = textures[mid].yscale = textures[bottom].yscale = scale == 0 ? FRACUNIT : scale;
}
void SetTextureYScale(double scale) void SetTextureYScale(double scale)
{ {
textures[top].yscale = textures[mid].yscale = textures[bottom].yscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale); textures[top].yScale = textures[mid].yScale = textures[bottom].yScale = scale == 0 ? 1. : scale;
}
fixed_t GetTextureYScale(int which) const
{
return textures[which].yscale;
} }
fixed_t GetTextureYScale(int which) const = delete;
double GetTextureYScaleF(int which) const double GetTextureYScaleF(int which) const
{ {
return FIXED2DBL(textures[which].yscale); return textures[which].yScale;
} }
void MultiplyTextureYScale(int which, double delta) void MultiplyTextureYScale(int which, double delta)
{ {
textures[which].yscale = fixed_t(textures[which].yscale * delta); textures[which].yScale *= delta;
} }
DInterpolation *SetInterpolation(int position); DInterpolation *SetInterpolation(int position);

View file

@ -86,6 +86,7 @@ void (*rt_map4cols)(int,int,int);
// R_DrawColumn // R_DrawColumn
// Source is the top of the column to scale. // Source is the top of the column to scale.
// //
double dc_texturemid;
extern "C" { extern "C" {
int dc_pitch=0xABadCafe; // [RH] Distance between rows int dc_pitch=0xABadCafe; // [RH] Distance between rows
@ -94,7 +95,6 @@ int dc_x;
int dc_yl; int dc_yl;
int dc_yh; int dc_yh;
fixed_t dc_iscale; fixed_t dc_iscale;
fixed_t dc_texturemid;
fixed_t dc_texturefrac; fixed_t dc_texturefrac;
int dc_color; // [RH] Color for column filler int dc_color; // [RH] Color for column filler
DWORD dc_srccolor; DWORD dc_srccolor;
@ -1757,8 +1757,8 @@ void mvlinec4 ()
#endif #endif
extern "C" short spanend[MAXHEIGHT]; extern "C" short spanend[MAXHEIGHT];
extern fixed_t rw_light; extern float rw_light;
extern fixed_t rw_lightstep; extern float rw_lightstep;
extern int wallshade; extern int wallshade;
static void R_DrawFogBoundarySection (int y, int y2, int x1) static void R_DrawFogBoundarySection (int y, int y2, int x1)
@ -1795,8 +1795,8 @@ void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip)
// to create new horizontal spans whenever the light changes enough that // to create new horizontal spans whenever the light changes enough that
// we need to use a new colormap. // we need to use a new colormap.
fixed_t lightstep = rw_lightstep; double lightstep = rw_lightstep;
fixed_t light = rw_light+lightstep*(x2-x1-1); double light = rw_light + rw_lightstep*(x2-x1-1);
int x = x2-1; int x = x2-1;
int t2 = uclip[x]; int t2 = uclip[x];
int b2 = dclip[x]; int b2 = dclip[x];

View file

@ -34,7 +34,7 @@ extern "C" int dc_x;
extern "C" int dc_yl; extern "C" int dc_yl;
extern "C" int dc_yh; extern "C" int dc_yh;
extern "C" fixed_t dc_iscale; extern "C" fixed_t dc_iscale;
extern "C" fixed_t dc_texturemid; extern double dc_texturemid;
extern "C" fixed_t dc_texturefrac; extern "C" fixed_t dc_texturefrac;
extern "C" int dc_color; // [RH] For flat colors (no texturing) extern "C" int dc_color; // [RH] For flat colors (no texturing)
extern "C" DWORD dc_srccolor; extern "C" DWORD dc_srccolor;
@ -285,12 +285,12 @@ bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)());
// to just use the texture's GetColumn() method. It just exists // to just use the texture's GetColumn() method. It just exists
// for double-layer skies. // for double-layer skies.
const BYTE *R_GetColumn (FTexture *tex, int col); const BYTE *R_GetColumn (FTexture *tex, int col);
void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn);
// maskwallscan is exactly like wallscan but does not draw anything where the texture is color 0. // maskwallscan is exactly like wallscan but does not draw anything where the texture is color 0.
void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn);
// transmaskwallscan is like maskwallscan, but it can also blend to the background // transmaskwallscan is like maskwallscan, but it can also blend to the background
void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn);
#endif #endif

View file

@ -1108,14 +1108,15 @@ void R_FillColumnHorizP (void)
void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span)
{ {
const fixed_t texturemid = FLOAT2FIXED(dc_texturemid);
while (span->Length != 0) while (span->Length != 0)
{ {
const int length = span->Length; const int length = span->Length;
const int top = span->TopOffset; const int top = span->TopOffset;
// calculate unclipped screen coordinates for post // calculate unclipped screen coordinates for post
dc_yl = (sprtopscreen + spryscale * top) >> FRACBITS; dc_yl = xs_RoundToInt(sprtopscreen + spryscale * top);
dc_yh = (sprtopscreen + spryscale * (top + length) - FRACUNIT) >> FRACBITS; dc_yh = xs_RoundToInt(sprtopscreen + spryscale * (top + length) - 1);
if (sprflipvert) if (sprflipvert)
{ {
@ -1136,7 +1137,7 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span)
if (sprflipvert) if (sprflipvert)
{ {
dc_texturefrac = (dc_yl*dc_iscale) - (top << FRACBITS) dc_texturefrac = (dc_yl*dc_iscale) - (top << FRACBITS)
- FixedMul (centeryfrac, dc_iscale) - dc_texturemid; - fixed_t(CenterY * dc_iscale) - texturemid;
const fixed_t maxfrac = length << FRACBITS; const fixed_t maxfrac = length << FRACBITS;
while (dc_texturefrac >= maxfrac) while (dc_texturefrac >= maxfrac)
{ {
@ -1154,8 +1155,8 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span)
} }
else else
{ {
dc_texturefrac = dc_texturemid - (top << FRACBITS) dc_texturefrac = texturemid - (top << FRACBITS)
+ (dc_yl*dc_iscale) - FixedMul (centeryfrac-FRACUNIT, dc_iscale); + (dc_yl*dc_iscale) - fixed_t((CenterY-1) * dc_iscale);
while (dc_texturefrac < 0) while (dc_texturefrac < 0)
{ {
if (++dc_yl > dc_yh) if (++dc_yl > dc_yh)

View file

@ -93,9 +93,9 @@ extern bool r_showviewer;
// PRIVATE DATA DECLARATIONS ----------------------------------------------- // PRIVATE DATA DECLARATIONS -----------------------------------------------
static float CurrentVisibility = 8.f; static double CurrentVisibility = 8.f;
static fixed_t MaxVisForWall; static double MaxVisForWall;
static fixed_t MaxVisForFloor; static double MaxVisForFloor;
bool r_dontmaplines; bool r_dontmaplines;
// PUBLIC DATA DEFINITIONS ------------------------------------------------- // PUBLIC DATA DEFINITIONS -------------------------------------------------
@ -103,34 +103,31 @@ bool r_dontmaplines;
CVAR (String, r_viewsize, "", CVAR_NOSET) CVAR (String, r_viewsize, "", CVAR_NOSET)
CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE) CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE)
fixed_t r_BaseVisibility; double r_BaseVisibility;
fixed_t r_WallVisibility; double r_WallVisibility;
fixed_t r_FloorVisibility; double r_FloorVisibility;
float r_TiltVisibility; float r_TiltVisibility;
fixed_t r_SpriteVisibility; double r_SpriteVisibility;
fixed_t r_ParticleVisibility; double r_ParticleVisibility;
fixed_t r_SkyVisibility;
fixed_t GlobVis; double GlobVis;
fixed_t viewingrangerecip; fixed_t viewingrangerecip;
fixed_t FocalLengthX; double FocalLengthX;
fixed_t FocalLengthY; double FocalLengthY;
float FocalLengthXfloat;
FDynamicColormap*basecolormap; // [RH] colormap currently drawing with FDynamicColormap*basecolormap; // [RH] colormap currently drawing with
int fixedlightlev; int fixedlightlev;
lighttable_t *fixedcolormap; lighttable_t *fixedcolormap;
FSpecialColormap *realfixedcolormap; FSpecialColormap *realfixedcolormap;
float WallTMapScale2; double WallTMapScale2;
bool bRenderingToCanvas; // [RH] True if rendering to a special canvas bool bRenderingToCanvas; // [RH] True if rendering to a special canvas
fixed_t globaluclip, globaldclip; double globaluclip, globaldclip;
fixed_t centerxfrac; double CenterX, CenterY;
fixed_t centeryfrac; double YaspectMul;
fixed_t yaspectmul; double BaseYaspectMul; // yaspectmul without a forced aspect ratio
fixed_t baseyaspectmul; // yaspectmul without a forced aspect ratio double IYaspectMul;
float iyaspectmulfloat; double InvZtoScale;
fixed_t InvZtoScale;
// just for profiling purposes // just for profiling purposes
int linecount; int linecount;
@ -188,9 +185,8 @@ static inline int viewangletox(int i)
} }
else else
{ {
int t = FixedMul(finetangent[i], FocalLengthX); double t = FIXED2DBL(finetangent[i]) * FocalLengthX;
t = (centerxfrac - t + FRACUNIT-1) >> FRACBITS; return clamp(xs_CeilToInt(CenterX - t), -1, viewwidth+1);
return clamp(t, -1, viewwidth+1);
} }
} }
@ -205,9 +201,8 @@ void R_InitTextureMapping ()
int i, x; int i, x;
// Calc focallength so FieldOfView fineangles covers viewwidth. // Calc focallength so FieldOfView fineangles covers viewwidth.
FocalLengthX = FixedDiv (centerxfrac, FocalTangent); FocalLengthX = CenterX / FocalTangent;
FocalLengthY = Scale (centerxfrac, yaspectmul, FocalTangent); FocalLengthY = FocalLengthX * YaspectMul;
FocalLengthXfloat = (float)FocalLengthX / 65536.f;
// This is 1/FocalTangent before the widescreen extension of FOV. // This is 1/FocalTangent before the widescreen extension of FOV.
viewingrangerecip = DivScale32(1, finetangent[FINEANGLES/4+(FieldOfView/2)]); viewingrangerecip = DivScale32(1, finetangent[FINEANGLES/4+(FieldOfView/2)]);
@ -224,9 +219,9 @@ void R_InitTextureMapping ()
// the drawn sky texture. // the drawn sky texture.
// The remaining arcs are done with tantoangle instead. // The remaining arcs are done with tantoangle instead.
const int t1 = MAX<int>(centerx - (FocalLengthX >> FRACBITS), 0); const int t1 = MAX(int(CenterX - FocalLengthX), 0);
const int t2 = MIN<int>(centerx + (FocalLengthX >> FRACBITS), viewwidth); const int t2 = MIN(int(CenterX + FocalLengthX), viewwidth);
const fixed_t dfocus = FocalLengthX >> DBITS; const fixed_t dfocus = FLOAT2FIXED(FocalLengthX) >> DBITS;
for (i = 0, x = t2; x >= t1; --x) for (i = 0, x = t2; x >= t1; --x)
{ {
@ -254,10 +249,10 @@ void R_InitTextureMapping ()
// //
//========================================================================== //==========================================================================
void R_SetVisibility (float vis) void R_SetVisibility(double vis)
{ {
// Allow negative visibilities, just for novelty's sake // Allow negative visibilities, just for novelty's sake
vis = clamp (vis, -204.7f, 204.7f); // (205 and larger do not work in 5:4 aspect ratio) vis = clamp(vis, -204.7, 204.7); // (205 and larger do not work in 5:4 aspect ratio)
CurrentVisibility = vis; CurrentVisibility = vis;
@ -268,7 +263,7 @@ void R_SetVisibility (float vis)
return; return;
} }
r_BaseVisibility = xs_RoundToInt(vis * 65536.f); r_BaseVisibility = vis;
// Prevent overflow on walls // Prevent overflow on walls
if (r_BaseVisibility < 0 && r_BaseVisibility < -MaxVisForWall) if (r_BaseVisibility < 0 && r_BaseVisibility < -MaxVisForWall)
@ -278,8 +273,8 @@ void R_SetVisibility (float vis)
else else
r_WallVisibility = r_BaseVisibility; r_WallVisibility = r_BaseVisibility;
r_WallVisibility = FixedMul (Scale (InvZtoScale, SCREENWIDTH*BaseRatioSizes[WidescreenRatio][1], r_WallVisibility = (InvZtoScale * SCREENWIDTH*BaseRatioSizes[WidescreenRatio][1] /
viewwidth*SCREENHEIGHT*3), FixedMul (r_WallVisibility, FocalTangent)); (viewwidth*SCREENHEIGHT*3)) * (r_WallVisibility * FocalTangent);
// Prevent overflow on floors/ceilings. Note that the calculation of // Prevent overflow on floors/ceilings. Note that the calculation of
// MaxVisForFloor means that planes less than two units from the player's // MaxVisForFloor means that planes less than two units from the player's
@ -292,9 +287,9 @@ void R_SetVisibility (float vis)
else else
r_FloorVisibility = r_BaseVisibility; r_FloorVisibility = r_BaseVisibility;
r_FloorVisibility = Scale (160*FRACUNIT, r_FloorVisibility, FocalLengthY); r_FloorVisibility = 160.0 * r_FloorVisibility / FocalLengthY;
r_TiltVisibility = vis * (float)FocalTangent * (16.f * 320.f) / (float)viewwidth; r_TiltVisibility = float(vis * FocalTangent * (16.f * 320.f) / viewwidth);
r_SpriteVisibility = r_WallVisibility; r_SpriteVisibility = r_WallVisibility;
} }
@ -304,7 +299,7 @@ void R_SetVisibility (float vis)
// //
//========================================================================== //==========================================================================
float R_GetVisibility () double R_GetVisibility()
{ {
return CurrentVisibility; return CurrentVisibility;
} }
@ -327,7 +322,7 @@ CCMD (r_visibility)
} }
else if (!netgame) else if (!netgame)
{ {
R_SetVisibility ((float)atof (argv[1])); R_SetVisibility(atof(argv[1]));
} }
else else
{ {
@ -359,8 +354,8 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight,
halfviewwidth = (viewwidth >> 1) - 1; halfviewwidth = (viewwidth >> 1) - 1;
lastcenteryfrac = 1<<30; lastcenteryfrac = 1<<30;
centerxfrac = centerx<<FRACBITS; CenterX = centerx;
centeryfrac = centery<<FRACBITS; CenterY = centery;
virtwidth = virtwidth2 = fullWidth; virtwidth = virtwidth2 = fullWidth;
virtheight = virtheight2 = fullHeight; virtheight = virtheight2 = fullHeight;
@ -383,27 +378,27 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight,
virtwidth = virtwidth * BaseRatioSizes[WidescreenRatio][3] / 48; virtwidth = virtwidth * BaseRatioSizes[WidescreenRatio][3] / 48;
} }
baseyaspectmul = Scale(320 << FRACBITS, virtheight2, r_Yaspect * virtwidth2); BaseYaspectMul = 320.0 * virtheight2 / (r_Yaspect * virtwidth2);
yaspectmul = Scale ((320<<FRACBITS), virtheight, r_Yaspect * virtwidth); YaspectMul = 320.0 * virtheight / (r_Yaspect * virtwidth);
iyaspectmulfloat = (float)virtwidth * r_Yaspect / 320.f / (float)virtheight; IYaspectMul = (double)virtwidth * r_Yaspect / 320.0 / virtheight;
InvZtoScale = yaspectmul * centerx; InvZtoScale = YaspectMul * CenterX;
WallTMapScale2 = iyaspectmulfloat * 64.f / (float)centerx; WallTMapScale2 = IYaspectMul / CenterX;
// psprite scales // psprite scales
pspritexscale = (centerxwide << FRACBITS) / 160; pspritexscale = centerxwide / 160.0;
pspriteyscale = FixedMul (pspritexscale, yaspectmul); pspriteyscale = pspritexscale * YaspectMul;
pspritexiscale = FixedDiv (FRACUNIT, pspritexscale); pspritexiscale = 1 / pspritexscale;
// thing clipping // thing clipping
clearbufshort (screenheightarray, viewwidth, (short)viewheight); clearbufshort (screenheightarray, viewwidth, (short)viewheight);
R_InitTextureMapping (); R_InitTextureMapping ();
MaxVisForWall = FixedMul (Scale (InvZtoScale, SCREENWIDTH*r_Yaspect, MaxVisForWall = (InvZtoScale * (SCREENWIDTH*r_Yaspect) /
viewwidth*SCREENHEIGHT), FocalTangent); (viewwidth*SCREENHEIGHT * FocalTangent));
MaxVisForWall = FixedDiv (0x7fff0000, MaxVisForWall); MaxVisForWall = 32767.0 / MaxVisForWall;
MaxVisForFloor = Scale (FixedDiv (0x7fff0000, viewheight<<(FRACBITS-2)), FocalLengthY, 160*FRACUNIT); MaxVisForFloor = 32767.0 / (viewheight * FocalLengthY / 160);
// Reset r_*Visibility vars // Reset r_*Visibility vars
R_SetVisibility(R_GetVisibility()); R_SetVisibility(R_GetVisibility());
@ -489,10 +484,8 @@ static void R_ShutdownRenderer()
void R_CopyStackedViewParameters() void R_CopyStackedViewParameters()
{ {
stacked_viewx = viewx; stacked_viewpos = ViewPos;
stacked_viewy = viewy; stacked_angle = ViewAngle;
stacked_viewz = viewz;
stacked_angle = viewangle;
stacked_extralight = extralight; stacked_extralight = extralight;
stacked_visibility = R_GetVisibility(); stacked_visibility = R_GetVisibility();
} }
@ -552,58 +545,59 @@ void R_SetupColormap(player_t *player)
void R_SetupFreelook() void R_SetupFreelook()
{ {
{ {
fixed_t dy; double dy;
if (camera != NULL) if (camera != NULL)
{ {
dy = FixedMul (FocalLengthY, finetangent[(ANGLE_90-viewpitch)>>ANGLETOFINESHIFT]); dy = FocalLengthY * (-ViewPitch).Tan();
} }
else else
{ {
dy = 0; dy = 0;
} }
centeryfrac = (viewheight << (FRACBITS-1)) + dy; CenterY = (viewheight / 2.0) + dy;
centery = centeryfrac >> FRACBITS; centery = xs_ToInt(CenterY);
globaluclip = FixedDiv (-centeryfrac, InvZtoScale); globaluclip = -CenterY / InvZtoScale;
globaldclip = FixedDiv ((viewheight<<FRACBITS)-centeryfrac, InvZtoScale); globaldclip = (viewheight - CenterY) / InvZtoScale;
//centeryfrac &= 0xffff0000; //centeryfrac &= 0xffff0000;
int e, i; int e, i;
i = 0; i = 0;
e = viewheight; e = viewheight;
fixed_t focus = FocalLengthY; float focus = float(FocalLengthY);
fixed_t den; float den;
float cy = float(CenterY);
if (i < centery) if (i < centery)
{ {
den = centeryfrac - (i << FRACBITS) - FRACUNIT/2; den = cy - i - 0.5f;
if (e <= centery) if (e <= centery)
{ {
do { do {
yslope[i] = FixedDiv (focus, den); yslope[i] = FLOAT2FIXED(focus / den);
den -= FRACUNIT; den -= 1;
} while (++i < e); } while (++i < e);
} }
else else
{ {
do { do {
yslope[i] = FixedDiv (focus, den); yslope[i] = FLOAT2FIXED(focus / den);
den -= FRACUNIT; den -= 1;
} while (++i < centery); } while (++i < centery);
den = (i << FRACBITS) - centeryfrac + FRACUNIT/2; den = i - cy + 0.5f;
do { do {
yslope[i] = FixedDiv (focus, den); yslope[i] = FLOAT2FIXED(focus / den);
den += FRACUNIT; den += 1;
} while (++i < e); } while (++i < e);
} }
} }
else else
{ {
den = (i << FRACBITS) - centeryfrac + FRACUNIT/2; den = i - cy + 0.5f;
do { do {
yslope[i] = FixedDiv (focus, den); yslope[i] = FLOAT2FIXED(focus / den);
den += FRACUNIT; den += 1;
} while (++i < e); } while (++i < e);
} }
} }
@ -688,10 +682,8 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
return; return;
} }
angle_t startang = viewangle; DAngle startang = ViewAngle;
fixed_t startx = viewx; DVector3 startpos = ViewPos;
fixed_t starty = viewy;
fixed_t startz = viewz;
DVector3 savedpath[2] = { ViewPath[0], ViewPath[1] }; DVector3 savedpath[2] = { ViewPath[0], ViewPath[1] };
ActorRenderFlags savedvisibility = camera? camera->renderflags & RF_INVISIBLE : ActorRenderFlags::FromInt(0); ActorRenderFlags savedvisibility = camera? camera->renderflags & RF_INVISIBLE : ActorRenderFlags::FromInt(0);
@ -707,44 +699,40 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
// Reflect the current view behind the mirror. // Reflect the current view behind the mirror.
if (pds->src->Delta().X == 0) if (pds->src->Delta().X == 0)
{ // vertical mirror { // vertical mirror
viewx = v1->fixX() - startx + v1->fixX(); ViewPos.X = v1->fX() - startpos.X + v1->fX();
} }
else if (pds->src->Delta().Y == 0) else if (pds->src->Delta().Y == 0)
{ // horizontal mirror { // horizontal mirror
viewy = v1->fixY() - starty + v1->fixY(); ViewPos.Y = v1->fY() - startpos.Y + v1->fY();
} }
else else
{ // any mirror--use floats to avoid integer overflow { // any mirror
vertex_t *v2 = pds->src->v2; vertex_t *v2 = pds->src->v2;
double dx = v2->fX() - v1->fX(); double dx = v2->fX() - v1->fX();
double dy = v2->fY() - v1->fY(); double dy = v2->fY() - v1->fY();
double x1 = v1->fX(); double x1 = v1->fX();
double y1 = v1->fY(); double y1 = v1->fY();
double x = FIXED2DBL(startx); double x = startpos.X;
double y = FIXED2DBL(starty); double y = startpos.Y;
// the above two cases catch len == 0 // the above two cases catch len == 0
double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy); double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy);
viewx = FLOAT2FIXED((x1 + r * dx)*2 - x); ViewPos.X = (x1 + r * dx)*2 - x;
viewy = FLOAT2FIXED((y1 + r * dy)*2 - y); ViewPos.Y = (y1 + r * dy)*2 - y;
} }
viewangle = pds->src->Delta().Angle().BAMs() - startang; ViewAngle = pds->src->Delta().Angle() - startang;
} }
else else
{ {
DVector3 view(FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz)); DVector3 view(ViewPos);
DAngle va = ANGLE2DBL(viewangle); DAngle va = ViewAngle;
P_TranslatePortalXY(pds->src, view.X, view.Y); P_TranslatePortalXY(pds->src, view.X, view.Y);
P_TranslatePortalZ(pds->src, view.Z); P_TranslatePortalZ(pds->src, view.Z);
P_TranslatePortalAngle(pds->src, va); P_TranslatePortalAngle(pds->src, va);
P_TranslatePortalXY(pds->src, ViewPath[0].X, ViewPath[0].Y); P_TranslatePortalXY(pds->src, ViewPath[0].X, ViewPath[0].Y);
P_TranslatePortalXY(pds->src, ViewPath[1].X, ViewPath[1].Y); P_TranslatePortalXY(pds->src, ViewPath[1].X, ViewPath[1].Y);
viewx = FLOAT2FIXED(view.X);
viewy = FLOAT2FIXED(view.Y);
viewz = FLOAT2FIXED(view.Z);
viewangle = va.BAMs();
if (!r_showviewer && camera) if (!r_showviewer && camera)
{ {
@ -760,15 +748,15 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
} }
} }
} }
ViewPos = view;
ViewAngle = va;
} }
ViewAngle = AngleToFloat(viewangle);
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; ViewSin = ViewAngle.Sin();
viewcos = finecosine[viewangle>>ANGLETOFINESHIFT]; ViewCos = ViewAngle.Cos();
viewtansin = FixedMul (FocalTangent, viewsin); ViewTanSin = FocalTangent * ViewSin;
viewtancos = FixedMul (FocalTangent, viewcos); ViewTanCos = FocalTangent * ViewCos;
R_CopyStackedViewParameters(); R_CopyStackedViewParameters();
@ -809,7 +797,7 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
R_DrawPortals (); R_DrawPortals ();
PlaneCycles.Unclock(); PlaneCycles.Unclock();
fixed_t vzp = viewz; double vzp = ViewPos.Z;
int prevuniq = CurrentPortalUniq; int prevuniq = CurrentPortalUniq;
// depth check is in another place right now // depth check is in another place right now
@ -838,14 +826,10 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
CurrentPortal = prevpds; CurrentPortal = prevpds;
MirrorFlags = prevmf; MirrorFlags = prevmf;
viewangle = startang; ViewAngle = startang;
viewx = startx; ViewPos = startpos;
viewy = starty;
viewz = startz;
ViewPath[0] = savedpath[0]; ViewPath[0] = savedpath[0];
ViewPath[1] = savedpath[1]; ViewPath[1] = savedpath[1];
ViewAngle = AngleToFloat(viewangle);
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
} }
//========================================================================== //==========================================================================

View file

@ -35,22 +35,21 @@ typedef BYTE lighttable_t; // This could be wider for >8 bit display.
// POV related. // POV related.
// //
extern bool bRenderingToCanvas; extern bool bRenderingToCanvas;
extern fixed_t viewcos; extern double ViewCos;
extern fixed_t viewsin; extern double ViewSin;
extern fixed_t viewingrangerecip; extern fixed_t viewingrangerecip;
extern fixed_t FocalLengthX, FocalLengthY; extern double FocalLengthX, FocalLengthY;
extern float FocalLengthXfloat; extern double InvZtoScale;
extern fixed_t InvZtoScale;
extern float WallTMapScale2; extern double WallTMapScale2;
extern int viewwindowx; extern int viewwindowx;
extern int viewwindowy; extern int viewwindowy;
extern fixed_t centerxfrac; extern double CenterX;
extern fixed_t centeryfrac; extern double CenterY;
extern fixed_t yaspectmul; extern double YaspectMul;
extern float iyaspectmulfloat; extern double IYaspectMul;
extern FDynamicColormap*basecolormap; // [RH] Colormap for sector currently being drawn extern FDynamicColormap*basecolormap; // [RH] Colormap for sector currently being drawn
@ -76,24 +75,23 @@ extern bool r_dontmaplines;
#define LIGHT2SHADE(l) ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128))) #define LIGHT2SHADE(l) ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128)))
// MAXLIGHTSCALE from original DOOM, divided by 2. // MAXLIGHTSCALE from original DOOM, divided by 2.
#define MAXLIGHTVIS (24*FRACUNIT) #define MAXLIGHTVIS (24.0)
// Convert a shade and visibility to a clamped colormap index. // Convert a shade and visibility to a clamped colormap index.
// Result is not fixed point. // Result is not fixed point.
// Change R_CalcTiltedLighting() when this changes. // Change R_CalcTiltedLighting() when this changes.
#define GETPALOOKUP(vis,shade) (clamp<int> (((shade)-MIN(MAXLIGHTVIS,(vis)))>>FRACBITS, 0, NUMCOLORMAPS-1)) #define GETPALOOKUP(vis,shade) (clamp<int> (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1))
extern fixed_t GlobVis; extern double GlobVis;
void R_SetVisibility (float visibility); void R_SetVisibility(double visibility);
float R_GetVisibility (); double R_GetVisibility();
extern fixed_t r_BaseVisibility; extern double r_BaseVisibility;
extern fixed_t r_WallVisibility; extern double r_WallVisibility;
extern fixed_t r_FloorVisibility; extern double r_FloorVisibility;
extern float r_TiltVisibility; extern float r_TiltVisibility;
extern fixed_t r_SpriteVisibility; extern double r_SpriteVisibility;
extern fixed_t r_SkyVisibility;
extern int r_actualextralight; extern int r_actualextralight;
extern bool foggy; extern bool foggy;
@ -138,9 +136,9 @@ void R_MultiresInit (void);
extern int stacked_extralight; extern int stacked_extralight;
extern float stacked_visibility; extern double stacked_visibility;
extern fixed_t stacked_viewx, stacked_viewy, stacked_viewz; extern DVector3 stacked_viewpos;
extern angle_t stacked_angle; extern DAngle stacked_angle;
extern void R_CopyStackedViewParameters(); extern void R_CopyStackedViewParameters();

View file

@ -98,9 +98,9 @@ visplane_t *ceilingplane;
// you are changing them to draw a stacked sector. Otherwise, stacked sectors // you are changing them to draw a stacked sector. Otherwise, stacked sectors
// won't draw in skyboxes properly. // won't draw in skyboxes properly.
int stacked_extralight; int stacked_extralight;
float stacked_visibility; double stacked_visibility;
fixed_t stacked_viewx, stacked_viewy, stacked_viewz; DVector3 stacked_viewpos;
angle_t stacked_angle; DAngle stacked_angle;
// //
@ -123,7 +123,7 @@ short ceilingclip[MAXWIDTH];
// texture mapping // texture mapping
// //
static fixed_t planeheight; static double planeheight;
extern "C" { extern "C" {
// //
@ -217,7 +217,7 @@ void R_MapPlane (int y, int x1)
// [RH] Notice that I dumped the caching scheme used by Doom. // [RH] Notice that I dumped the caching scheme used by Doom.
// It did not offer any appreciable speedup. // It did not offer any appreciable speedup.
distance = FixedMul (planeheight, yslope[y]); distance = xs_ToInt(planeheight * yslope[y]);
ds_xstep = FixedMul (distance, xstepscale); ds_xstep = FixedMul (distance, xstepscale);
ds_ystep = FixedMul (distance, ystepscale); ds_ystep = FixedMul (distance, ystepscale);
@ -228,7 +228,7 @@ void R_MapPlane (int y, int x1)
{ {
// Determine lighting based on the span's distance from the viewer. // Determine lighting based on the span's distance from the viewer.
ds_colormap = basecolormap->Maps + (GETPALOOKUP ( ds_colormap = basecolormap->Maps + (GETPALOOKUP (
FixedMul (GlobVis, abs (centeryfrac - (y << FRACBITS))), planeshade) << COLORMAPSHIFT); GlobVis * fabs(CenterY - y), planeshade) << COLORMAPSHIFT);
} }
#ifdef X86_ASM #ifdef X86_ASM
@ -253,9 +253,9 @@ void R_MapPlane (int y, int x1)
//========================================================================== //==========================================================================
extern "C" { extern "C" {
void R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width) void R_CalcTiltedLighting (double lval, double lend, int width)
{ {
fixed_t lstep; double lstep;
BYTE *lightfiller; BYTE *lightfiller;
BYTE *basecolormapdata = basecolormap->Maps; BYTE *basecolormapdata = basecolormap->Maps;
int i = 0; int i = 0;
@ -311,7 +311,7 @@ void R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
} }
while (i <= width && lval >= 0) while (i <= width && lval >= 0)
{ {
tiltlighting[i++] = basecolormapdata + ((lval >> FRACBITS) << COLORMAPSHIFT); tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT);
lval += lstep; lval += lstep;
} }
lightfiller = basecolormapdata; lightfiller = basecolormapdata;
@ -334,7 +334,7 @@ void R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
return; return;
while (i <= width && lval < (NUMCOLORMAPS-1)*FRACUNIT) while (i <= width && lval < (NUMCOLORMAPS-1)*FRACUNIT)
{ {
tiltlighting[i++] = basecolormapdata + ((lval >> FRACBITS) << COLORMAPSHIFT); tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT);
lval += lstep; lval += lstep;
} }
lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT);
@ -371,7 +371,7 @@ void R_MapTiltedPlane (int y, int x1)
{ {
uz = (iz + plane_sz[0]*width) * planelightfloat; uz = (iz + plane_sz[0]*width) * planelightfloat;
vz = iz * planelightfloat; vz = iz * planelightfloat;
R_CalcTiltedLighting (xs_RoundToInt(vz), xs_RoundToInt(uz), width); R_CalcTiltedLighting (vz, uz, width);
} }
uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx); uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx);
@ -640,9 +640,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
// check even more. // check even more.
if (check->extralight == stacked_extralight && if (check->extralight == stacked_extralight &&
check->visibility == stacked_visibility && check->visibility == stacked_visibility &&
check->viewx == stacked_viewx && check->viewpos == stacked_viewpos &&
check->viewy == stacked_viewy &&
check->viewz == stacked_viewz &&
( (
// headache inducing logic... :( // headache inducing logic... :(
(portal->mType != PORTS_STACKEDSECTORTHING) || (portal->mType != PORTS_STACKEDSECTORTHING) ||
@ -689,9 +687,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
CurrentPortalUniq == check->CurrentPortalUniq && CurrentPortalUniq == check->CurrentPortalUniq &&
MirrorFlags == check->MirrorFlags && MirrorFlags == check->MirrorFlags &&
CurrentSkybox == check->CurrentSkybox && CurrentSkybox == check->CurrentSkybox &&
viewx == check->viewx && ViewPos == check->viewpos
viewy == check->viewy &&
viewz == check->viewz
) )
{ {
return check; return check;
@ -715,9 +711,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
check->right = 0; check->right = 0;
check->extralight = stacked_extralight; check->extralight = stacked_extralight;
check->visibility = stacked_visibility; check->visibility = stacked_visibility;
check->viewx = stacked_viewx; check->viewpos = stacked_viewpos;
check->viewy = stacked_viewy;
check->viewz = stacked_viewz;
check->viewangle = stacked_angle; check->viewangle = stacked_angle;
check->Alpha = alpha; check->Alpha = alpha;
check->Additive = additive; check->Additive = additive;
@ -803,9 +797,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop)
new_pl->portal = pl->portal; new_pl->portal = pl->portal;
new_pl->extralight = pl->extralight; new_pl->extralight = pl->extralight;
new_pl->visibility = pl->visibility; new_pl->visibility = pl->visibility;
new_pl->viewx = pl->viewx; new_pl->viewpos = pl->viewpos;
new_pl->viewy = pl->viewy;
new_pl->viewz = pl->viewz;
new_pl->viewangle = pl->viewangle; new_pl->viewangle = pl->viewangle;
new_pl->sky = pl->sky; new_pl->sky = pl->sky;
new_pl->Alpha = pl->Alpha; new_pl->Alpha = pl->Alpha;
@ -850,13 +842,13 @@ inline void R_MakeSpans (int x, int t1, int b1, int t2, int b2, void (*mapfunc)(
static FTexture *frontskytex, *backskytex; static FTexture *frontskytex, *backskytex;
static angle_t skyflip; static angle_t skyflip;
static int frontpos, backpos; static int frontpos, backpos;
static fixed_t frontyScale; static double frontyScale;
static fixed_t frontcyl, backcyl; static fixed_t frontcyl, backcyl;
static fixed_t skymid; static double skymid;
static angle_t skyangle; static angle_t skyangle;
int frontiScale; static double frontiScale;
extern fixed_t swall[MAXWIDTH]; extern float swall[MAXWIDTH];
extern fixed_t lwall[MAXWIDTH]; extern fixed_t lwall[MAXWIDTH];
extern fixed_t rw_offset; extern fixed_t rw_offset;
extern FTexture *rw_pic; extern FTexture *rw_pic;
@ -924,13 +916,16 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x)
static void R_DrawSky (visplane_t *pl) static void R_DrawSky (visplane_t *pl)
{ {
int x; int x;
float swal;
if (pl->left >= pl->right) if (pl->left >= pl->right)
return; return;
dc_iscale = skyiscale; swal = skyiscale;
for (x = pl->left; x < pl->right; ++x)
clearbuf (swall+pl->left, pl->right-pl->left, dc_iscale<<2); {
swall[x] = swal;
}
if (MirrorFlags & RF_XFLIP) if (MirrorFlags & RF_XFLIP)
{ {
@ -955,8 +950,8 @@ static void R_DrawSky (visplane_t *pl)
rw_pic = frontskytex; rw_pic = frontskytex;
rw_offset = 0; rw_offset = 0;
frontyScale = FLOAT2FIXED(rw_pic->Scale.Y); frontyScale = rw_pic->Scale.Y;
dc_texturemid = MulScale16 (skymid, frontyScale); dc_texturemid = skymid * frontyScale;
if (1 << frontskytex->HeightBits == frontskytex->GetHeight()) if (1 << frontskytex->HeightBits == frontskytex->GetHeight())
{ // The texture tiles nicely { // The texture tiles nicely
@ -969,39 +964,26 @@ static void R_DrawSky (visplane_t *pl)
} }
else else
{ // The texture does not tile nicely { // The texture does not tile nicely
frontyScale = DivScale16 (skyscale, frontyScale); frontyScale *= skyscale;
frontiScale = DivScale32 (1, frontyScale); frontiScale = 1 / frontyScale;
// Sodding crap. Fixed point sucks when you want precision.
// TODO (if I'm feeling adventurous): Rewrite the renderer to use floating point
// coordinates to keep as much precision as possible until the final
// rasterization stage so fudges like this aren't needed.
if (viewheight <= 600)
{
skymid -= FRACUNIT;
}
R_DrawSkyStriped (pl); R_DrawSkyStriped (pl);
} }
} }
static void R_DrawSkyStriped (visplane_t *pl) static void R_DrawSkyStriped (visplane_t *pl)
{ {
fixed_t centerysave = centeryfrac; short drawheight = short(frontskytex->GetHeight() * frontyScale);
short drawheight = (short)MulScale16 (frontskytex->GetHeight(), frontyScale); double topfrac;
fixed_t topfrac; double iscale = frontiScale;
fixed_t iscale = frontiScale;
short top[MAXWIDTH], bot[MAXWIDTH]; short top[MAXWIDTH], bot[MAXWIDTH];
short yl, yh; short yl, yh;
int x; int x;
// So that I don't have to worry about fractional precision, chop off the topfrac = fmod(skymid + iscale * (1 - CenterY), frontskytex->GetHeight());
// fractional part of centeryfrac. if (topfrac < 0) topfrac += frontskytex->GetHeight();
centeryfrac = centery << FRACBITS;
topfrac = (skymid + iscale * (1-centery)) % (frontskytex->GetHeight() << FRACBITS);
if (topfrac < 0) topfrac += frontskytex->GetHeight() << FRACBITS;
yl = 0; yl = 0;
yh = (short)MulScale32 ((frontskytex->GetHeight() << FRACBITS) - topfrac, frontyScale); yh = short((frontskytex->GetHeight() - topfrac) * frontyScale);
dc_texturemid = topfrac - iscale * (1-centery); dc_texturemid = topfrac - iscale * (1 - CenterY);
fixed_t yScale = FLOAT2FIXED(rw_pic->Scale.Y);
while (yl < viewheight) while (yl < viewheight)
{ {
@ -1014,13 +996,12 @@ static void R_DrawSkyStriped (visplane_t *pl)
{ {
lastskycol[x] = 0xffffffff; lastskycol[x] = 0xffffffff;
} }
wallscan (pl->left, pl->right, top, bot, swall, lwall, yScale, wallscan (pl->left, pl->right, top, bot, swall, lwall, rw_pic->Scale.Y,
backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns);
yl = yh; yl = yh;
yh += drawheight; yh += drawheight;
dc_texturemid = iscale * (centery-yl-1); dc_texturemid = iscale * (centery-yl-1);
} }
centeryfrac = centerysave;
} }
//========================================================================== //==========================================================================
@ -1060,15 +1041,15 @@ int R_DrawPlanes ()
} }
// kg3D - draw all visplanes with "height" // kg3D - draw all visplanes with "height"
void R_DrawHeightPlanes(fixed_t height) void R_DrawHeightPlanes(double height)
{ {
visplane_t *pl; visplane_t *pl;
int i; int i;
ds_color = 3; ds_color = 3;
fixed_t oViewX = viewx, oViewY = viewy, oViewZ = viewz; DVector3 oViewPos = ViewPos;
angle_t oViewAngle = viewangle; DAngle oViewAngle = ViewAngle;
for (i = 0; i < MAXVISPLANES; i++) for (i = 0; i < MAXVISPLANES; i++)
{ {
@ -1078,24 +1059,15 @@ void R_DrawHeightPlanes(fixed_t height)
if(pl->CurrentSkybox != CurrentSkybox || pl->CurrentPortalUniq != CurrentPortalUniq) if(pl->CurrentSkybox != CurrentSkybox || pl->CurrentPortalUniq != CurrentPortalUniq)
continue; continue;
if(pl->sky < 0 && pl->height.Zat0() == height) { if(pl->sky < 0 && pl->height.Zat0() == height) {
viewx = pl->viewx; ViewPos = pl->viewpos;
viewy = pl->viewy; ViewAngle = pl->viewangle;
viewz = pl->viewz;
viewangle = pl->viewangle;
ViewAngle = AngleToFloat(viewangle);
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
MirrorFlags = pl->MirrorFlags; MirrorFlags = pl->MirrorFlags;
R_DrawSinglePlane (pl, pl->sky & 0x7FFFFFFF, pl->Additive, true); R_DrawSinglePlane (pl, pl->sky & 0x7FFFFFFF, pl->Additive, true);
} }
} }
} }
ViewPos = oViewPos;
viewx = oViewX; ViewAngle = oViewAngle;
viewy = oViewY;
viewz = oViewZ;
viewangle = oViewAngle;
ViewAngle = AngleToFloat(viewangle);
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
} }
@ -1186,7 +1158,7 @@ void R_DrawPortals ()
static TArray<size_t> interestingStack; static TArray<size_t> interestingStack;
static TArray<ptrdiff_t> drawsegStack; static TArray<ptrdiff_t> drawsegStack;
static TArray<ptrdiff_t> visspriteStack; static TArray<ptrdiff_t> visspriteStack;
static TArray<fixed_t> viewxStack, viewyStack, viewzStack; static TArray<DVector3> viewposStack;
static TArray<visplane_t *> visplaneStack; static TArray<visplane_t *> visplaneStack;
numskyboxes = 0; numskyboxes = 0;
@ -1198,15 +1170,13 @@ void R_DrawPortals ()
CurrentPortalInSkybox = true; CurrentPortalInSkybox = true;
int savedextralight = extralight; int savedextralight = extralight;
fixed_t savedx = viewx; DVector3 savedpos = ViewPos;
fixed_t savedy = viewy; DAngle savedangle = ViewAngle;
fixed_t savedz = viewz;
angle_t savedangle = viewangle;
ptrdiff_t savedvissprite_p = vissprite_p - vissprites; ptrdiff_t savedvissprite_p = vissprite_p - vissprites;
ptrdiff_t savedds_p = ds_p - drawsegs; ptrdiff_t savedds_p = ds_p - drawsegs;
ptrdiff_t savedlastopening = lastopening; ptrdiff_t savedlastopening = lastopening;
size_t savedinteresting = FirstInterestingDrawseg; size_t savedinteresting = FirstInterestingDrawseg;
float savedvisibility = R_GetVisibility (); double savedvisibility = R_GetVisibility();
AActor *savedcamera = camera; AActor *savedcamera = camera;
sector_t *savedsector = viewsector; sector_t *savedsector = viewsector;
@ -1241,11 +1211,8 @@ void R_DrawPortals ()
extralight = 0; extralight = 0;
R_SetVisibility(sky->args[0] * 0.25f); R_SetVisibility(sky->args[0] * 0.25f);
DVector3 viewpos = sky->InterpolatedPosition(r_TicFracF); ViewPos = sky->InterpolatedPosition(r_TicFracF);
viewx = FLOAT2FIXED(viewpos.X); ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF);
viewy = FLOAT2FIXED(viewpos.Y);
viewz = FLOAT2FIXED(viewpos.Z);
viewangle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF).BAMs();
R_CopyStackedViewParameters(); R_CopyStackedViewParameters();
break; break;
@ -1256,10 +1223,10 @@ void R_DrawPortals ()
case PORTS_LINKEDPORTAL: case PORTS_LINKEDPORTAL:
extralight = pl->extralight; extralight = pl->extralight;
R_SetVisibility (pl->visibility); R_SetVisibility (pl->visibility);
viewx = pl->viewx + FLOAT2FIXED(port->mDisplacement.X); ViewPos.X = pl->viewpos.X + port->mDisplacement.X;
viewy = pl->viewy + FLOAT2FIXED(port->mDisplacement.Y); ViewPos.Y = pl->viewpos.Y + port->mDisplacement.Y;
viewz = pl->viewz; ViewPos.Z = pl->viewpos.Z;
viewangle = pl->viewangle; ViewAngle = pl->viewangle;
break; break;
case PORTS_HORIZON: case PORTS_HORIZON:
@ -1274,9 +1241,6 @@ void R_DrawPortals ()
continue; continue;
} }
ViewAngle = AngleToFloat(viewangle);
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
port->mFlags |= PORTSF_INSKYBOX; port->mFlags |= PORTSF_INSKYBOX;
if (port->mPartner > 0) sectorPortals[port->mPartner].mFlags |= PORTSF_INSKYBOX; if (port->mPartner > 0) sectorPortals[port->mPartner].mFlags |= PORTSF_INSKYBOX;
camera = NULL; camera = NULL;
@ -1332,9 +1296,7 @@ void R_DrawPortals ()
drawsegStack.Push (diffnum); drawsegStack.Push (diffnum);
diffnum = firstvissprite - vissprites; diffnum = firstvissprite - vissprites;
visspriteStack.Push (diffnum); visspriteStack.Push (diffnum);
viewxStack.Push (viewx); viewposStack.Push(ViewPos);
viewyStack.Push (viewy);
viewzStack.Push (viewz);
visplaneStack.Push (pl); visplaneStack.Push (pl);
InSubsector = NULL; InSubsector = NULL;
@ -1357,9 +1319,9 @@ void R_DrawPortals ()
firstdrawseg = drawsegs + pd; firstdrawseg = drawsegs + pd;
visspriteStack.Pop (pd); visspriteStack.Pop (pd);
firstvissprite = vissprites + pd; firstvissprite = vissprites + pd;
viewxStack.Pop (viewx); // Masked textures and planes need the view
viewyStack.Pop (viewy); // coordinates restored for proper positioning. // Masked textures and planes need the view coordinates restored for proper positioning.
viewzStack.Pop (viewz); viewposStack.Pop(ViewPos);
R_DrawMasked (); R_DrawMasked ();
@ -1385,14 +1347,10 @@ void R_DrawPortals ()
camera = savedcamera; camera = savedcamera;
viewsector = savedsector; viewsector = savedsector;
viewx = savedx; ViewPos = savedpos;
viewy = savedy;
viewz = savedz;
R_SetVisibility(savedvisibility); R_SetVisibility(savedvisibility);
extralight = savedextralight; extralight = savedextralight;
viewangle = savedangle; ViewAngle = savedangle;
ViewAngle = AngleToFloat(viewangle);
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
R_SetViewAngle (); R_SetViewAngle ();
CurrentPortalInSkybox = false; CurrentPortalInSkybox = false;
@ -1432,7 +1390,7 @@ void R_DrawSkyPlane (visplane_t *pl)
} }
sky2tex = sky2texture; sky2tex = sky2texture;
skymid = skytexturemid; skymid = skytexturemid;
skyangle = viewangle; skyangle = ViewAngle.BAMs();
if (pl->picnum == skyflatnum) if (pl->picnum == skyflatnum)
{ {
@ -1489,10 +1447,10 @@ void R_DrawSkyPlane (visplane_t *pl)
// to allow sky rotation as well as careful positioning. // to allow sky rotation as well as careful positioning.
// However, the offset is scaled very small, so that it // However, the offset is scaled very small, so that it
// allows a long-period of sky rotation. // allows a long-period of sky rotation.
skyangle += s->GetTextureXOffset(pos); skyangle += FLOAT2FIXED(s->GetTextureXOffsetF(pos));
// Vertical offset allows careful sky positioning. // Vertical offset allows careful sky positioning.
skymid = s->GetTextureYOffset(pos) - 28*FRACUNIT; skymid = s->GetTextureYOffsetF(pos) - 28;
// We sometimes flip the picture horizontally. // We sometimes flip the picture horizontally.
// //
@ -1505,7 +1463,7 @@ void R_DrawSkyPlane (visplane_t *pl)
frontcyl = MAX(frontskytex->GetWidth(), frontxscale); frontcyl = MAX(frontskytex->GetWidth(), frontxscale);
if (skystretch) if (skystretch)
{ {
skymid = Scale(skymid, frontskytex->GetScaledHeight(), SKYSTRETCH_HEIGHT); skymid = skymid * frontskytex->GetScaledHeightDouble() / SKYSTRETCH_HEIGHT;
} }
} }
} }
@ -1560,23 +1518,23 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
double rad = planeang * (M_PI / ANGLE_180); double rad = planeang * (M_PI / ANGLE_180);
double cosine = cos(rad), sine = sin(rad); double cosine = cos(rad), sine = sin(rad);
pviewx = xs_RoundToInt(pl->xoffs + viewx * cosine - viewy * sine); pviewx = xs_RoundToInt(pl->xoffs + FLOAT2FIXED(ViewPos.X * cosine - ViewPos.Y * sine));
pviewy = xs_RoundToInt(pl->yoffs - viewx * sine - viewy * cosine); pviewy = xs_RoundToInt(pl->yoffs - FLOAT2FIXED(ViewPos.X * sine - ViewPos.Y * cosine));
} }
else else
{ {
pviewx = pl->xoffs + viewx; pviewx = pl->xoffs + FLOAT2FIXED(ViewPos.X);
pviewy = pl->yoffs - viewy; pviewy = pl->yoffs - FLOAT2FIXED(ViewPos.Y);
} }
pviewx = FixedMul (xscale, pviewx); pviewx = FixedMul (xscale, pviewx);
pviewy = FixedMul (yscale, pviewy); pviewy = FixedMul (yscale, pviewy);
// left to right mapping // left to right mapping
planeang = (viewangle - ANG90 + planeang) >> ANGLETOFINESHIFT; planeang = (ViewAngle.BAMs() - ANG90 + planeang) >> ANGLETOFINESHIFT;
// Scale will be unit scale at FocalLengthX (normally SCREENWIDTH/2) distance // Scale will be unit scale at FocalLengthX (normally SCREENWIDTH/2) distance
xstepscale = Scale (xscale, finecosine[planeang], FocalLengthX); xstepscale = fixed_t(FixedMul(xscale, finecosine[planeang]) / FocalLengthX);
ystepscale = Scale (yscale, -finesine[planeang], FocalLengthX); ystepscale = fixed_t(FixedMul(yscale, -finesine[planeang]) / FocalLengthX);
// [RH] flip for mirrors // [RH] flip for mirrors
if (MirrorFlags & RF_XFLIP) if (MirrorFlags & RF_XFLIP)
@ -1590,9 +1548,9 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
basexfrac = FixedMul (xscale, finecosine[planeang]) + x*xstepscale; basexfrac = FixedMul (xscale, finecosine[planeang]) + x*xstepscale;
baseyfrac = FixedMul (yscale, -finesine[planeang]) + x*ystepscale; baseyfrac = FixedMul (yscale, -finesine[planeang]) + x*ystepscale;
planeheight = abs (pl->height.Zat0() - viewz); planeheight = fabs(pl->height.Zat0() - ViewPos.Z);
GlobVis = FixedDiv (r_FloorVisibility, planeheight); GlobVis = r_FloorVisibility / planeheight;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false;
else if (fixedcolormap) else if (fixedcolormap)
@ -1678,15 +1636,11 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
return; return;
} }
double vx = FIXED2DBL(viewx);
double vy = FIXED2DBL(viewy);
double vz = FIXED2DBL(viewz);
lxscale = FIXED2DBL(pl->xscale) * ifloatpow2[ds_xbits]; lxscale = FIXED2DBL(pl->xscale) * ifloatpow2[ds_xbits];
lyscale = FIXED2DBL(pl->yscale) * ifloatpow2[ds_ybits]; lyscale = FIXED2DBL(pl->yscale) * ifloatpow2[ds_ybits];
xscale = 64.f / lxscale; xscale = 64.f / lxscale;
yscale = 64.f / lyscale; yscale = 64.f / lyscale;
zeroheight = pl->height.ZatPoint(vx, vy); zeroheight = pl->height.ZatPoint(ViewPos);
pviewx = MulScale (pl->xoffs, pl->xscale, ds_xbits); pviewx = MulScale (pl->xoffs, pl->xscale, ds_xbits);
pviewy = MulScale (pl->yoffs, pl->yscale, ds_ybits); pviewy = MulScale (pl->yoffs, pl->yscale, ds_ybits);
@ -1694,13 +1648,13 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
// p is the texture origin in view space // p is the texture origin in view space
// Don't add in the offsets at this stage, because doing so can result in // Don't add in the offsets at this stage, because doing so can result in
// errors if the flat is rotated. // errors if the flat is rotated.
ang = (ANG270 - viewangle) * (M_PI / ANGLE_180); ang = (DAngle(270.) - ViewAngle).Radians();
p[0] = vx * cos(ang) - vy * sin(ang); p[0] = ViewPos.X * cos(ang) - ViewPos.Y * sin(ang);
p[2] = vx * sin(ang) + vy * cos(ang); p[2] = ViewPos.X * sin(ang) + ViewPos.Y * cos(ang);
p[1] = pl->height.ZatPoint(0.0, 0.0) - vz; p[1] = pl->height.ZatPoint(0.0, 0.0) - ViewPos.Z;
// m is the v direction vector in view space // m is the v direction vector in view space
ang = (ANG180 - viewangle - pl->angle) * (M_PI / ANGLE_180); ang = (DAngle(180.) - ViewAngle).Radians();
m[0] = yscale * cos(ang); m[0] = yscale * cos(ang);
m[2] = yscale * sin(ang); m[2] = yscale * sin(ang);
// m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0)); // m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0));
@ -1717,21 +1671,21 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
// how much you slope the surface. Use the commented-out code above instead to keep // how much you slope the surface. Use the commented-out code above instead to keep
// the textures a constant size across the surface's plane instead. // the textures a constant size across the surface's plane instead.
ang = pl->angle * (M_PI / ANGLE_180); ang = pl->angle * (M_PI / ANGLE_180);
m[1] = pl->height.ZatPoint(vx + yscale * sin(ang), vy + yscale * cos(ang)) - zeroheight; m[1] = pl->height.ZatPoint(ViewPos.X + yscale * sin(ang), ViewPos.Y + yscale * cos(ang)) - zeroheight;
ang += PI/2; ang += PI/2;
n[1] = pl->height.ZatPoint(vx + xscale * sin(ang), vy + xscale * cos(ang)) - zeroheight; n[1] = pl->height.ZatPoint(ViewPos.X + xscale * sin(ang), ViewPos.Y + xscale * cos(ang)) - zeroheight;
plane_su = p ^ m; plane_su = p ^ m;
plane_sv = p ^ n; plane_sv = p ^ n;
plane_sz = m ^ n; plane_sz = m ^ n;
plane_su.Z *= FocalLengthXfloat; plane_su.Z *= FocalLengthX;
plane_sv.Z *= FocalLengthXfloat; plane_sv.Z *= FocalLengthX;
plane_sz.Z *= FocalLengthXfloat; plane_sz.Z *= FocalLengthX;
plane_su.Y *= iyaspectmulfloat; plane_su.Y *= IYaspectMul;
plane_sv.Y *= iyaspectmulfloat; plane_sv.Y *= IYaspectMul;
plane_sz.Y *= iyaspectmulfloat; plane_sz.Y *= IYaspectMul;
// Premultiply the texture vectors with the scale factors // Premultiply the texture vectors with the scale factors
plane_su *= 4294967296.f; plane_su *= 4294967296.f;
@ -1744,7 +1698,7 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
plane_sz[0] = -plane_sz[0]; plane_sz[0] = -plane_sz[0];
} }
planelightfloat = (r_TiltVisibility * lxscale * lyscale) / (fabs(pl->height.ZatPoint(FIXED2DBL(viewx), FIXED2DBL(viewy)) - FIXED2DBL(viewz))) / 65536.0; planelightfloat = (r_TiltVisibility * lxscale * lyscale) / (fabs(pl->height.ZatPoint(ViewPos) - ViewPos.Z)) / 65536.f;
if (pl->height.fC() > 0) if (pl->height.fC() > 0)
planelightfloat = -planelightfloat; planelightfloat = -planelightfloat;

View file

@ -50,9 +50,9 @@ struct visplane_s
// have stacked sectors inside a skybox. If the visplane is not for a // have stacked sectors inside a skybox. If the visplane is not for a
// stack, then they are unused. // stack, then they are unused.
int extralight; int extralight;
float visibility; double visibility;
fixed_t viewx, viewy, viewz; DVector3 viewpos;
angle_t viewangle; DAngle viewangle;
fixed_t Alpha; fixed_t Alpha;
bool Additive; bool Additive;

File diff suppressed because it is too large Load diff

View file

@ -31,10 +31,10 @@ extern short *openings;
extern ptrdiff_t lastopening; extern ptrdiff_t lastopening;
extern size_t maxopenings; extern size_t maxopenings;
int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc); int OWallMost (short *mostbuf, double z, const FWallCoords *wallc);
int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc); int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc);
void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat, int x1, int x2); void PrepWall (float *swall, fixed_t *lwall, double walxrepeat, int x1, int x2);
void PrepLWall (fixed_t *lwall, fixed_t walxrepeat, int x1, int x2); void PrepLWall (fixed_t *lwall, double walxrepeat, int x1, int x2);
ptrdiff_t R_NewOpening (ptrdiff_t len); ptrdiff_t R_NewOpening (ptrdiff_t len);
@ -42,11 +42,11 @@ void R_CheckDrawSegs ();
void R_RenderSegLoop (); void R_RenderSegLoop ();
extern fixed_t swall[MAXWIDTH]; extern float swall[MAXWIDTH];
extern fixed_t lwall[MAXWIDTH]; extern fixed_t lwall[MAXWIDTH];
extern fixed_t rw_light; // [RH] Scale lights with viewsize adjustments extern float rw_light; // [RH] Scale lights with viewsize adjustments
extern fixed_t rw_lightstep; extern float rw_lightstep;
extern fixed_t rw_lightleft; extern float rw_lightleft;
extern fixed_t rw_offset; extern fixed_t rw_offset;
/* portal structure, this is used in r_ code in order to store drawsegs with portals (and mirrors) */ /* portal structure, this is used in r_ code in order to store drawsegs with portals (and mirrors) */

View file

@ -40,9 +40,9 @@
// //
FTextureID skyflatnum; FTextureID skyflatnum;
FTextureID sky1texture, sky2texture; FTextureID sky1texture, sky2texture;
fixed_t skytexturemid; double skytexturemid;
fixed_t skyscale; double skyscale;
fixed_t skyiscale; float skyiscale;
bool skystretch; bool skystretch;
fixed_t sky1cyl, sky2cyl; fixed_t sky1cyl, sky2cyl;
@ -54,7 +54,7 @@ CUSTOM_CVAR (Bool, r_stretchsky, true, CVAR_ARCHIVE)
R_InitSkyMap (); R_InitSkyMap ();
} }
fixed_t freelookviewheight; int freelookviewheight;
//========================================================================== //==========================================================================
// //
@ -103,28 +103,27 @@ void R_InitSkyMap ()
&& skyheight >= 128 && skyheight >= 128
&& level.IsFreelookAllowed() && level.IsFreelookAllowed()
&& !(level.flags & LEVEL_FORCENOSKYSTRETCH)) ? 1 : 0; && !(level.flags & LEVEL_FORCENOSKYSTRETCH)) ? 1 : 0;
skytexturemid = -28*FRACUNIT; skytexturemid = -28;
} }
else if (skyheight > 200) else if (skyheight > 200)
{ {
skytexturemid = FLOAT2FIXED((200 - skyheight) * skytex1->Scale.Y); skytexturemid = (200 - skyheight) * skytex1->Scale.Y;
} }
if (viewwidth != 0 && viewheight != 0) if (viewwidth != 0 && viewheight != 0)
{ {
skyiscale = (r_Yaspect*FRACUNIT) / ((freelookviewheight * viewwidth) / viewwidth); skyiscale = float(r_Yaspect / freelookviewheight);
skyscale = (((freelookviewheight * viewwidth) / viewwidth) << FRACBITS) / skyscale = freelookviewheight / r_Yaspect;
(r_Yaspect);
skyiscale = Scale (skyiscale, FieldOfView, 2048); skyiscale *= FieldOfView / 2048.f;
skyscale = Scale (skyscale, 2048, FieldOfView); skyscale *= 2048.0 / FieldOfView;
} }
if (skystretch) if (skystretch)
{ {
skyscale = Scale(skyscale, SKYSTRETCH_HEIGHT, skyheight); skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight;
skyiscale = Scale(skyiscale, skyheight, SKYSTRETCH_HEIGHT); skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT;
skytexturemid = Scale(skytexturemid, skyheight, SKYSTRETCH_HEIGHT); skytexturemid *= skyheight / (double)SKYSTRETCH_HEIGHT;
} }
// The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees, // The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees,

View file

@ -28,11 +28,11 @@ extern FTextureID skyflatnum;
extern fixed_t sky1cyl, sky2cyl; extern fixed_t sky1cyl, sky2cyl;
extern FTextureID sky1texture, sky2texture; extern FTextureID sky1texture, sky2texture;
extern double sky1pos, sky2pos; extern double sky1pos, sky2pos;
extern fixed_t skytexturemid; extern double skytexturemid;
extern fixed_t skyiscale; extern float skyiscale;
extern fixed_t skyscale; extern double skyscale;
extern bool skystretch; extern bool skystretch;
extern fixed_t freelookviewheight; extern int freelookviewheight;
#define SKYSTRETCH_HEIGHT 228 #define SKYSTRETCH_HEIGHT 228

File diff suppressed because it is too large Load diff

View file

@ -32,15 +32,20 @@
struct vissprite_t struct vissprite_t
{ {
short x1, x2; short x1, x2;
fixed_t gx, gy, gz; // origin in world coordinates FVector3 gpos; // origin in world coordinates
union
{
float gzb, gzt; // global bottom / top for silhouette clipping
int y1, y2; // top / bottom of particle on screen
};
angle_t angle; angle_t angle;
fixed_t gzb, gzt; // global bottom / top for silhouette clipping fixed_t xscale;
fixed_t xscale, yscale; float yscale;
fixed_t depth; float depth;
fixed_t idepth; // 1/z float idepth; // 1/z
fixed_t deltax, deltay; float deltax, deltay;
DWORD FillColor; DWORD FillColor;
fixed_t floorclip; double floorclip;
union union
{ {
FTexture *pic; FTexture *pic;
@ -51,7 +56,7 @@ struct vissprite_t
// Used by face sprites // Used by face sprites
struct struct
{ {
fixed_t texturemid; double texturemid;
fixed_t startfrac; // horizontal position of x1 fixed_t startfrac; // horizontal position of x1
fixed_t xiscale; // negative if flipped fixed_t xiscale; // negative if flipped
}; };
@ -63,8 +68,8 @@ struct vissprite_t
// Used by voxels // Used by voxels
struct struct
{ {
fixed_t vx, vy, vz; // view origin FVector3 vpos; // view origin
angle_t vang; // view angle FAngle vang; // view angle
}; };
}; };
sector_t *heightsec; // killough 3/27/98: height sector for underwater/fake ceiling sector_t *heightsec; // killough 3/27/98: height sector for underwater/fake ceiling
@ -81,6 +86,9 @@ struct vissprite_t
DWORD Translation; // [RH] for color translation DWORD Translation; // [RH] for color translation
visstyle_t Style; visstyle_t Style;
int CurrentPortalUniq; // [ZZ] to identify the portal that this thing is in. used for clipping. int CurrentPortalUniq; // [ZZ] to identify the portal that this thing is in. used for clipping.
vissprite_t() {}
vissprite_t &vissprite_t::operator= (const vissprite_t &o) { memcpy(this, &o, sizeof *this); return *this; }
}; };
struct particle_t; struct particle_t;
@ -101,13 +109,13 @@ extern short screenheightarray[MAXWIDTH];
// vars for R_DrawMaskedColumn // vars for R_DrawMaskedColumn
extern short* mfloorclip; extern short* mfloorclip;
extern short* mceilingclip; extern short* mceilingclip;
extern fixed_t spryscale; extern double spryscale;
extern fixed_t sprtopscreen; extern double sprtopscreen;
extern bool sprflipvert; extern bool sprflipvert;
extern fixed_t pspritexscale; extern double pspritexscale;
extern fixed_t pspriteyscale; extern double pspritexiscale;
extern fixed_t pspritexiscale; extern double pspriteyscale;
extern FTexture *WallSpriteTile; extern FTexture *WallSpriteTile;
@ -128,9 +136,9 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly);
enum { DVF_OFFSCREEN = 1, DVF_SPANSONLY = 2, DVF_MIRRORED = 4 }; enum { DVF_OFFSCREEN = 1, DVF_SPANSONLY = 2, DVF_MIRRORED = 4 };
void R_DrawVoxel(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, void R_DrawVoxel(const FVector3 &viewpos, FAngle viewangle,
fixed_t dasprx, fixed_t daspry, fixed_t dasprz, angle_t dasprang, const FVector3 &sprpos, angle_t dasprang,
fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj, fixed_t daxscale, fixed_t dayscale, struct FVoxel *voxobj,
lighttable_t *colormap, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags); lighttable_t *colormap, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags);
void R_ClipVisSprite (vissprite_t *vis, int xl, int xh); void R_ClipVisSprite (vissprite_t *vis, int xl, int xh);

View file

@ -123,8 +123,8 @@ int otic;
sector_t *viewsector; sector_t *viewsector;
fixed_t viewcos, viewtancos; double ViewCos, ViewTanCos;
fixed_t viewsin, viewtansin; double ViewSin, ViewTanSin;
AActor *camera; // [RH] camera to draw from. doesn't have to be a player AActor *camera; // [RH] camera to draw from. doesn't have to be a player
@ -142,7 +142,7 @@ int WidescreenRatio;
int setblocks; int setblocks;
int extralight; int extralight;
bool setsizeneeded; bool setsizeneeded;
fixed_t FocalTangent; double FocalTangent;
unsigned int R_OldBlend = ~0; unsigned int R_OldBlend = ~0;
int validcount = 1; // increment every time a check is made int validcount = 1; // increment every time a check is made
@ -150,9 +150,8 @@ int FieldOfView = 2048; // Fineangles in the SCREENWIDTH wide window
FCanvasTextureInfo *FCanvasTextureInfo::List; FCanvasTextureInfo *FCanvasTextureInfo::List;
fixed_t viewx, viewy, viewz; DVector3a view;
angle_t viewangle; DAngle viewpitch;
int viewpitch;
// CODE -------------------------------------------------------------------- // CODE --------------------------------------------------------------------
@ -463,7 +462,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
fov = 170*FINEANGLES/360; fov = 170*FINEANGLES/360;
} }
FocalTangent = finetangent[FINEANGLES/4+fov/2]; FocalTangent = FIXED2FLOAT(finetangent[FINEANGLES/4+fov/2]);
Renderer->SetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio); Renderer->SetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio);
} }
@ -737,11 +736,11 @@ void R_ResetViewInterpolation ()
void R_SetViewAngle () void R_SetViewAngle ()
{ {
viewsin = FLOAT2FIXED(ViewAngle.Sin()); ViewSin = ViewAngle.Sin();
viewcos = FLOAT2FIXED(ViewAngle.Cos()); ViewCos = ViewAngle.Cos();
viewtansin = FixedMul (FocalTangent, viewsin); ViewTanSin = FocalTangent * ViewSin;
viewtancos = FixedMul (FocalTangent, viewcos); ViewTanCos = FocalTangent * ViewCos;
} }
//========================================================================== //==========================================================================
@ -1108,12 +1107,6 @@ void R_SetupFrame (AActor *actor)
} }
} }
viewx = FLOAT2FIXED(ViewPos.X);
viewy = FLOAT2FIXED(ViewPos.Y);
viewz = FLOAT2FIXED(ViewPos.Z);
viewangle = ViewAngle.BAMs();
viewpitch = ViewPitch.BAMs();
Renderer->CopyStackedViewParameters(); Renderer->CopyStackedViewParameters();
Renderer->SetupFrame(player); Renderer->SetupFrame(player);

View file

@ -17,18 +17,14 @@ extern DAngle ViewAngle;
extern DAngle ViewPitch; extern DAngle ViewPitch;
extern DVector3 ViewPath[2]; extern DVector3 ViewPath[2];
extern fixed_t viewx, viewy, viewz;
extern angle_t viewangle;
extern int viewpitch;
extern "C" int centerx, centerxwide; extern "C" int centerx, centerxwide;
extern "C" int centery; extern "C" int centery;
extern int setblocks; extern int setblocks;
extern fixed_t viewtancos; extern double ViewTanCos;
extern fixed_t viewtansin; extern double ViewTanSin;
extern fixed_t FocalTangent; extern double FocalTangent;
extern bool r_NoInterpolate; extern bool r_NoInterpolate;
extern int validcount; extern int validcount;
@ -43,7 +39,7 @@ extern DWORD r_FrameTime;
extern int extralight; extern int extralight;
extern unsigned int R_OldBlend; extern unsigned int R_OldBlend;
const int r_Yaspect = 200; // Why did I make this a variable? It's never set anywhere. const double r_Yaspect = 200.0; // Why did I make this a variable? It's never set anywhere.
//========================================================================== //==========================================================================
// //

View file

@ -199,33 +199,26 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
unmaskedSpan[1].Length = 0; unmaskedSpan[1].Length = 0;
} }
fixed_t centeryback = centeryfrac; double centeryback = CenterY;
centeryfrac = 0; CenterY = 0;
sprtopscreen = FLOAT2FIXED(y0);
// There is not enough precision in the drawing routines to keep the full // There is not enough precision in the drawing routines to keep the full
// precision for y0. :( // precision for y0. :(
sprtopscreen &= ~(FRACUNIT - 1); double dummy;
sprtopscreen = modf(y0, &dummy);
double yscale = parms.destheight / img->GetHeight(); double yscale = parms.destheight / img->GetHeight();
double iyscale = 1 / yscale; double iyscale = 1 / yscale;
spryscale = FLOAT2FIXED(yscale); spryscale = yscale;
assert(spryscale > 2); assert(spryscale > 0);
#if 0
// Fix precision errors that are noticeable at some resolutions
if ((y0 + parms.destheight) > (y0 + yscale * img->GetHeight()))
{
spryscale++;
}
#endif
sprflipvert = false; sprflipvert = false;
//dc_iscale = FLOAT2FIXED(iyscale); //dc_iscale = FLOAT2FIXED(iyscale);
//dc_texturemid = FLOAT2FIXED((-y0) * iyscale); //dc_texturemid = (-y0) * iyscale;
//dc_iscale = 0xffffffffu / (unsigned)spryscale; //dc_iscale = 0xffffffffu / (unsigned)spryscale;
dc_iscale = DivScale32(1, spryscale); dc_iscale = FLOAT2FIXED(1 / spryscale);
dc_texturemid = FixedMul(-sprtopscreen, dc_iscale) + FixedMul(centeryfrac-FRACUNIT, dc_iscale); dc_texturemid = (CenterY - 1 - sprtopscreen) * dc_iscale / 65536;
fixed_t frac = 0; fixed_t frac = 0;
double xiscale = img->GetWidth() / parms.destwidth; double xiscale = img->GetWidth() / parms.destwidth;
double x2 = x0 + parms.destwidth; double x2 = x0 + parms.destwidth;
@ -325,7 +318,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
frac += xiscale_i; frac += xiscale_i;
} }
} }
centeryfrac = centeryback; CenterY = centeryback;
} }
R_FinishSetPatchStyle (); R_FinishSetPatchStyle ();

View file

@ -72,11 +72,11 @@ const char *GetVersionString();
// SAVESIG should match SAVEVER. // SAVESIG should match SAVEVER.
// MINSAVEVER is the minimum level snapshot version that can be loaded. // MINSAVEVER is the minimum level snapshot version that can be loaded.
#define MINSAVEVER 4540 #define MINSAVEVER 4541
// Use 4500 as the base git save version, since it's higher than the // Use 4500 as the base git save version, since it's higher than the
// SVN revision ever got. // SVN revision ever got.
#define SAVEVER 4540 #define SAVEVER 4541
#define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY2(x) #x
#define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)

View file

@ -112,6 +112,15 @@ protected:
} }
}; };
finline static int32_t xs_ToFixed(int32_t n, real64 val)
{
#if _xs_DEFAULT_CONVERSION==0
return xs_CRoundToInt(val, _xs_doublemagic/(1<<n));
#else
return (long)((val)*(1<<N));
#endif
}

View file

@ -6,8 +6,8 @@ include( CheckFunctionExists )
include( CheckTypeSize ) include( CheckTypeSize )
if( MSVC ) if( MSVC )
# Runtime type information is required # Runtime type information is required and don't complain about uint32_t to bool conversions
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR /wd4800" )
endif() endif()
set( PACKAGE_NAME re2c ) set( PACKAGE_NAME re2c )