mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 06:12:19 +00:00
Merge branch 'master' of c:\programming\doom-dev\zdoom
# Conflicts: # src/r_defs.h
This commit is contained in:
commit
ba37854e44
28 changed files with 1040 additions and 1172 deletions
|
@ -294,11 +294,11 @@ R_DrawTiltedPlane_ASM:
|
|||
fmul dword [planelightfloat]
|
||||
fxch st1
|
||||
fmul dword [planelightfloat]
|
||||
sub esp,8
|
||||
fistp dword [esp]
|
||||
fistp dword [esp+4]
|
||||
sub esp,16
|
||||
fstp qword [esp]
|
||||
fstp qword [esp+8]
|
||||
call R_CalcTiltedLighting
|
||||
add esp, 12
|
||||
add esp, 20
|
||||
xor eax, eax
|
||||
|
||||
.litup add esp, 8
|
||||
|
|
|
@ -347,9 +347,6 @@ void P_SerializeWorld (FArchive &arc)
|
|||
<< sec->seqType
|
||||
<< sec->friction
|
||||
<< sec->movefactor
|
||||
<< sec->floordata
|
||||
<< sec->ceilingdata
|
||||
<< sec->lightingdata
|
||||
<< sec->stairlock
|
||||
<< sec->prevsec
|
||||
<< sec->nextsec
|
||||
|
@ -464,7 +461,10 @@ void P_SerializeWorldActors(FArchive &arc)
|
|||
for (i = 0, sec = sectors; i < numsectors; i++, sec++)
|
||||
{
|
||||
arc << sec->SoundTarget
|
||||
<< sec->SecActTarget;
|
||||
<< sec->SecActTarget
|
||||
<< sec->floordata
|
||||
<< sec->ceilingdata
|
||||
<< sec->lightingdata;
|
||||
}
|
||||
for (auto &s : sectorPortals)
|
||||
{
|
||||
|
@ -485,8 +485,8 @@ void extsector_t::Serialize(FArchive &arc)
|
|||
|
||||
FArchive &operator<< (FArchive &arc, side_t::part &p)
|
||||
{
|
||||
arc << p.xoffset << p.yoffset << p.interpolation << p.texture
|
||||
<< p.xscale << p.yscale;// << p.Light;
|
||||
arc << p.xOffset << p.yOffset << p.interpolation << p.texture
|
||||
<< p.xScale << p.yScale;// << p.Light;
|
||||
return arc;
|
||||
}
|
||||
|
||||
|
|
|
@ -549,8 +549,8 @@ void P_SpawnScrollers(void)
|
|||
case Scroll_Texture_Offsets:
|
||||
// killough 3/2/98: scroll according to sidedef offsets
|
||||
s = int(lines[i].sidedef[0] - sides);
|
||||
new DScroller (EScroll::sc_side, -sides[s].GetTextureXOffset(side_t::mid),
|
||||
sides[s].GetTextureYOffset(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0]));
|
||||
new DScroller (EScroll::sc_side, -sides[s].GetTextureXOffsetF(side_t::mid),
|
||||
sides[s].GetTextureYOffsetF(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0]));
|
||||
break;
|
||||
|
||||
case Scroll_Texture_Left:
|
||||
|
|
|
@ -2627,10 +2627,10 @@ void P_LoadSideDefs2 (MapData *map, FMissingTextureTracker &missingtex)
|
|||
msd->rowoffset += 102;
|
||||
}
|
||||
|
||||
sd->SetTextureXOffset(LittleShort(msd->textureoffset)<<FRACBITS);
|
||||
sd->SetTextureYOffset(LittleShort(msd->rowoffset)<<FRACBITS);
|
||||
sd->SetTextureXScale(FRACUNIT);
|
||||
sd->SetTextureYScale(FRACUNIT);
|
||||
sd->SetTextureXOffset(LittleShort(msd->textureoffset));
|
||||
sd->SetTextureYOffset(LittleShort(msd->rowoffset));
|
||||
sd->SetTextureXScale(1.);
|
||||
sd->SetTextureYScale(1.);
|
||||
sd->linedef = NULL;
|
||||
sd->Flags = 0;
|
||||
sd->Index = i;
|
||||
|
|
|
@ -21,8 +21,8 @@ F3DFloor *fakeFloor;
|
|||
fixed_t fakeHeight;
|
||||
fixed_t fakeAlpha;
|
||||
int fakeActive = 0;
|
||||
fixed_t sclipBottom;
|
||||
fixed_t sclipTop;
|
||||
double sclipBottom;
|
||||
double sclipTop;
|
||||
HeightLevel *height_top = NULL;
|
||||
HeightLevel *height_cur = NULL;
|
||||
int CurrentMirror = 0;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
struct HeightLevel
|
||||
{
|
||||
fixed_t height;
|
||||
double height;
|
||||
struct HeightLevel *prev;
|
||||
struct HeightLevel *next;
|
||||
};
|
||||
|
@ -51,8 +51,8 @@ extern int fake3D;
|
|||
extern F3DFloor *fakeFloor;
|
||||
extern fixed_t fakeAlpha;
|
||||
extern int fakeActive;
|
||||
extern fixed_t sclipBottom;
|
||||
extern fixed_t sclipTop;
|
||||
extern double sclipBottom;
|
||||
extern double sclipTop;
|
||||
extern HeightLevel *height_top;
|
||||
extern HeightLevel *height_cur;
|
||||
extern int CurrentMirror;
|
||||
|
|
185
src/r_bsp.cpp
185
src/r_bsp.cpp
|
@ -78,10 +78,10 @@ extern short wallbottom[MAXWIDTH];
|
|||
extern short wallupper[MAXWIDTH];
|
||||
extern short walllower[MAXWIDTH];
|
||||
|
||||
fixed_t rw_backcz1, rw_backcz2;
|
||||
fixed_t rw_backfz1, rw_backfz2;
|
||||
fixed_t rw_frontcz1, rw_frontcz2;
|
||||
fixed_t rw_frontfz1, rw_frontfz2;
|
||||
double rw_backcz1, rw_backcz2;
|
||||
double rw_backfz1, rw_backfz2;
|
||||
double rw_frontcz1, rw_frontcz2;
|
||||
double rw_frontfz1, rw_frontfz2;
|
||||
|
||||
|
||||
size_t MaxDrawSegs;
|
||||
|
@ -336,7 +336,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
|
|||
{
|
||||
sector_t *heightsec = viewsector->heightsec;
|
||||
bool underwater = r_fakingunderwater ||
|
||||
(heightsec && heightsec->floorplane.PointOnSide(viewx, viewy, viewz) <= 0);
|
||||
(heightsec && heightsec->floorplane.PointOnSide(ViewPos) <= 0);
|
||||
bool doorunderwater = false;
|
||||
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);
|
||||
fixed_t orgceilz = sec->ceilingplane.ZatPointFixed(viewx, viewy);
|
||||
double refceilz = s->ceilingplane.ZatPoint(ViewPos);
|
||||
double orgceilz = sec->ceilingplane.ZatPoint(ViewPos);
|
||||
|
||||
#if 1
|
||||
// [RH] Allow viewing underwater areas through doors/windows that
|
||||
|
@ -405,8 +405,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
|
|||
// sectors at the same time.
|
||||
if (back && !r_fakingunderwater && curline->frontsector->heightsec == NULL)
|
||||
{
|
||||
if (rw_frontcz1 <= s->floorplane.ZatPointFixed (curline->v1) &&
|
||||
rw_frontcz2 <= s->floorplane.ZatPointFixed(curline->v2))
|
||||
if (rw_frontcz1 <= s->floorplane.ZatPoint(curline->v1) &&
|
||||
rw_frontcz2 <= s->floorplane.ZatPoint(curline->v2))
|
||||
{
|
||||
// Check that the window is actually visible
|
||||
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;
|
||||
}
|
||||
else if (heightsec && heightsec->ceilingplane.PointOnSide(viewx, viewy, viewz) <= 0 &&
|
||||
else if (heightsec && heightsec->ceilingplane.PointOnSide(ViewPos) <= 0 &&
|
||||
orgceilz > refceilz && !(s->MoreFlags & SECF_FAKEFLOORONLY))
|
||||
{ // Above-ceiling hack
|
||||
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
|
||||
bool solid;
|
||||
fixed_t tx1, tx2, ty1, ty2;
|
||||
DVector2 pt1, pt2;
|
||||
|
||||
curline = line;
|
||||
|
||||
// [RH] Color if not texturing line
|
||||
dc_color = (((int)(line - segs) * 8) + 4) & 255;
|
||||
|
||||
tx1 = line->v1->fixX() - viewx;
|
||||
tx2 = line->v2->fixX() - viewx;
|
||||
ty1 = line->v1->fixY() - viewy;
|
||||
ty2 = line->v2->fixY() - viewy;
|
||||
pt1 = line->v1->fPos() - ViewPos;
|
||||
pt2 = line->v2->fPos() - ViewPos;
|
||||
|
||||
// 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;
|
||||
|
||||
if (WallC.Init(tx1, ty1, tx2, ty2, 32))
|
||||
if (WallC.Init(pt1, pt2, 32.0 / (1 << 12)))
|
||||
return;
|
||||
|
||||
if (WallC.sx1 >= WindowRight || WallC.sx2 <= WindowLeft)
|
||||
|
@ -591,17 +589,17 @@ void R_AddLine (seg_t *line)
|
|||
{
|
||||
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))
|
||||
{
|
||||
backsector = line->backsector;
|
||||
}
|
||||
rw_frontcz1 = frontsector->ceilingplane.ZatPointFixed(line->v1);
|
||||
rw_frontfz1 = frontsector->floorplane.ZatPointFixed(line->v1);
|
||||
rw_frontcz2 = frontsector->ceilingplane.ZatPointFixed(line->v2);
|
||||
rw_frontfz2 = frontsector->floorplane.ZatPointFixed(line->v2);
|
||||
rw_frontcz1 = frontsector->ceilingplane.ZatPoint(line->v1);
|
||||
rw_frontfz1 = frontsector->floorplane.ZatPoint(line->v1);
|
||||
rw_frontcz2 = frontsector->ceilingplane.ZatPoint(line->v2);
|
||||
rw_frontfz2 = frontsector->floorplane.ZatPoint(line->v2);
|
||||
|
||||
rw_mustmarkfloor = rw_mustmarkceiling = false;
|
||||
rw_havehigh = rw_havelow = false;
|
||||
|
@ -620,10 +618,10 @@ void R_AddLine (seg_t *line)
|
|||
}
|
||||
doorclosed = 0; // killough 4/16/98
|
||||
|
||||
rw_backcz1 = backsector->ceilingplane.ZatPointFixed (line->v1);
|
||||
rw_backfz1 = backsector->floorplane.ZatPointFixed(line->v1);
|
||||
rw_backcz2 = backsector->ceilingplane.ZatPointFixed(line->v2);
|
||||
rw_backfz2 = backsector->floorplane.ZatPointFixed(line->v2);
|
||||
rw_backcz1 = backsector->ceilingplane.ZatPoint(line->v1);
|
||||
rw_backfz1 = backsector->floorplane.ZatPoint(line->v1);
|
||||
rw_backcz2 = backsector->ceilingplane.ZatPoint(line->v2);
|
||||
rw_backfz2 = backsector->floorplane.ZatPoint(line->v2);
|
||||
|
||||
// Cannot make these walls solid, because it can result in
|
||||
// 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
|
||||
//
|
||||
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);
|
||||
tx2 = DMulScale20(x2, viewsin, -y2, viewcos);
|
||||
tleft.X = float(pt1.X * ViewSin - pt1.Y * ViewCos);
|
||||
tright.X = float(pt2.X * ViewSin - pt2.Y * ViewCos);
|
||||
|
||||
ty1 = DMulScale20(x1, viewtancos, y1, viewtansin);
|
||||
ty2 = DMulScale20(x2, viewtancos, y2, viewtansin);
|
||||
tleft.Y = float(pt1.X * ViewTanCos + pt1.Y * ViewTanSin);
|
||||
tright.Y = float(pt2.X * ViewTanCos + pt2.Y * ViewTanSin);
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
int t = 256 - tx1;
|
||||
tx1 = 256 - tx2;
|
||||
tx2 = t;
|
||||
swapvalues(ty1, ty2);
|
||||
float t = -tleft.X;
|
||||
tleft.X = -tright.X;
|
||||
tright.X = t;
|
||||
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 (ty1 == 0) return true;
|
||||
sx1 = (centerxfrac + Scale(tx1, centerxfrac, ty1)) >> FRACBITS;
|
||||
if (tx1 >= 0) sx1 = MIN(viewwidth, sx1+1); // fix for signed divide
|
||||
sz1 = ty1;
|
||||
if (tleft.X > tleft.Y) return true; // left edge is off the right side
|
||||
if (tleft.Y == 0) return true;
|
||||
sx1 = xs_RoundToInt(CenterX + tleft.X * CenterX / tleft.Y);
|
||||
sz1 = tleft.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tx2 < -ty2) return true; // wall is off the left side
|
||||
fixed_t den = tx1 - tx2 - ty2 + ty1;
|
||||
if (tright.X < -tright.Y) return true; // wall is off the left side
|
||||
float den = tleft.X - tright.X - tright.Y + tleft.Y;
|
||||
if (den == 0) return true;
|
||||
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)
|
||||
return true;
|
||||
|
||||
if (tx2 <= ty2)
|
||||
if (tright.X <= tright.Y)
|
||||
{
|
||||
if (tx2 < -ty2) return true; // right edge is off the left side
|
||||
if (ty2 == 0) return true;
|
||||
sx2 = (centerxfrac + Scale(tx2, centerxfrac, ty2)) >> FRACBITS;
|
||||
if (tx2 >= 0) sx2 = MIN(viewwidth, sx2+1); // fix for signed divide
|
||||
sz2 = ty2;
|
||||
if (tright.X < -tright.Y) return true; // right edge is off the left side
|
||||
if (tright.Y == 0) return true;
|
||||
sx2 = xs_RoundToInt(CenterX + tright.X * CenterX / tright.Y);
|
||||
sz2 = tright.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tx1 > ty1) return true; // wall is off the right side
|
||||
fixed_t den = ty2 - ty1 - tx2 + tx1;
|
||||
if (tleft.X > tleft.Y) return true; // wall is off the right side
|
||||
float den = tright.Y - tleft.Y - tright.X + tleft.X;
|
||||
if (den == 0) return true;
|
||||
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)
|
||||
|
@ -834,28 +830,25 @@ bool FWallCoords::Init(int x1, int y1, int x2, int y2, int too_close)
|
|||
|
||||
void FWallTmapVals::InitFromWallCoords(const FWallCoords *wallc)
|
||||
{
|
||||
const FVector2 *left = &wallc->tleft;
|
||||
const FVector2 *right = &wallc->tright;
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
UoverZorg = (float)wallc->tx2 * centerx;
|
||||
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);
|
||||
swapvalues(left, right);
|
||||
}
|
||||
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
|
||||
fixed_t fullx1 = DMulScale20 (tx1, viewsin, -ty1, viewcos);
|
||||
fixed_t fullx2 = DMulScale20 (tx2, viewsin, -ty2, viewcos);
|
||||
fixed_t fully1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin);
|
||||
fixed_t fully2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin);
|
||||
double fullx1 = left.X * ViewSin - left.Y * ViewCos;
|
||||
double fullx2 = right.X * ViewSin - right.Y * ViewCos;
|
||||
double fully1 = left.X * ViewTanCos + left.Y * ViewTanSin;
|
||||
double fully2 = right.X * ViewTanCos + right.Y * ViewTanSin;
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
|
@ -863,10 +856,10 @@ void FWallTmapVals::InitFromLine(int tx1, int ty1, int tx2, int ty2)
|
|||
fullx2 = -fullx2;
|
||||
}
|
||||
|
||||
UoverZorg = (float)fullx1 * centerx;
|
||||
UoverZstep = (float)(-fully1);
|
||||
InvZorg = (float)(fullx1 - fullx2) * centerx;
|
||||
InvZstep = (float)(fully2 - fully1);
|
||||
UoverZorg = float(fullx1 * centerx);
|
||||
UoverZstep = float(-fully1);
|
||||
InvZorg = float((fullx1 - fullx2) * centerx);
|
||||
InvZstep = float(fully2 - fully1);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -896,24 +889,24 @@ static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
|
|||
int boxy;
|
||||
int boxpos;
|
||||
|
||||
fixed_t x1, y1, x2, y2;
|
||||
fixed_t rx1, ry1, rx2, ry2;
|
||||
double x1, y1, x2, y2;
|
||||
double rx1, ry1, rx2, ry2;
|
||||
int sx1, sx2;
|
||||
|
||||
cliprange_t* start;
|
||||
|
||||
// Find the corners of the box
|
||||
// that define the edges from current viewpoint.
|
||||
if (viewx <= bspcoord[BOXLEFT])
|
||||
if (ViewPos.X <= FIXED2DBL(bspcoord[BOXLEFT]))
|
||||
boxx = 0;
|
||||
else if (viewx < bspcoord[BOXRIGHT])
|
||||
else if (ViewPos.X < FIXED2DBL(bspcoord[BOXRIGHT]))
|
||||
boxx = 1;
|
||||
else
|
||||
boxx = 2;
|
||||
|
||||
if (viewy >= bspcoord[BOXTOP])
|
||||
if (ViewPos.Y >= FIXED2DBL(bspcoord[BOXTOP]))
|
||||
boxy = 0;
|
||||
else if (viewy > bspcoord[BOXBOTTOM])
|
||||
else if (ViewPos.Y > FIXED2DBL(bspcoord[BOXBOTTOM]))
|
||||
boxy = 1;
|
||||
else
|
||||
boxy = 2;
|
||||
|
@ -922,26 +915,26 @@ static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
|
|||
if (boxpos == 5)
|
||||
return true;
|
||||
|
||||
x1 = bspcoord[checkcoord[boxpos][0]] - viewx;
|
||||
y1 = bspcoord[checkcoord[boxpos][1]] - viewy;
|
||||
x2 = bspcoord[checkcoord[boxpos][2]] - viewx;
|
||||
y2 = bspcoord[checkcoord[boxpos][3]] - viewy;
|
||||
x1 = FIXED2DBL(bspcoord[checkcoord[boxpos][0]]) - ViewPos.X;
|
||||
y1 = FIXED2DBL(bspcoord[checkcoord[boxpos][1]]) - ViewPos.Y;
|
||||
x2 = FIXED2DBL(bspcoord[checkcoord[boxpos][2]]) - ViewPos.X;
|
||||
y2 = FIXED2DBL(bspcoord[checkcoord[boxpos][3]]) - ViewPos.Y;
|
||||
|
||||
// check clip list for an open space
|
||||
|
||||
// Sitting on a line?
|
||||
if (DMulScale32 (y1, x1-x2, x1, y2-y1) >= 0)
|
||||
if (y1 * (x1 - x2) + x1 * (y2 - y1) >= -EQUAL_EPSILON)
|
||||
return true;
|
||||
|
||||
rx1 = DMulScale20 (x1, viewsin, -y1, viewcos);
|
||||
rx2 = DMulScale20 (x2, viewsin, -y2, viewcos);
|
||||
ry1 = DMulScale20 (x1, viewtancos, y1, viewtansin);
|
||||
ry2 = DMulScale20 (x2, viewtancos, y2, viewtansin);
|
||||
rx1 = x1 * ViewSin - y1 * ViewCos;
|
||||
rx2 = x2 * ViewSin - y2 * ViewCos;
|
||||
ry1 = x1 * ViewTanCos + y1 * ViewTanSin;
|
||||
ry2 = x2 * ViewTanCos + y2 * ViewTanSin;
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
int t = 256-rx1;
|
||||
rx1 = 256-rx2;
|
||||
double t = -rx1;
|
||||
rx1 = -rx2;
|
||||
rx2 = t;
|
||||
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 (ry1 == 0) return false;
|
||||
sx1 = (centerxfrac + Scale (rx1, centerxfrac, ry1)) >> FRACBITS;
|
||||
if (rx1 >= 0) sx1 = MIN<int> (viewwidth, sx1+1); // fix for signed divide
|
||||
sx1 = xs_RoundToInt(CenterX + rx1 * CenterX / ry1);
|
||||
}
|
||||
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 (ry2 == 0) return false;
|
||||
sx2 = (centerxfrac + Scale (rx2, centerxfrac, ry2)) >> FRACBITS;
|
||||
if (rx2 >= 0) sx2 = MIN<int> (viewwidth, sx2+1); // fix for signed divide
|
||||
sx2 = xs_RoundToInt(CenterX + rx2 * CenterX / ry2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1116,7 +1107,7 @@ void R_Subsector (subsector_t *sub)
|
|||
|
||||
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 ||
|
||||
portal != NULL ||
|
||||
(frontsector->heightsec &&
|
||||
|
@ -1157,7 +1148,7 @@ void R_Subsector (subsector_t *sub)
|
|||
// killough 10/98: add support for skies transferred from sidedefs
|
||||
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 ||
|
||||
portal != NULL ||
|
||||
(frontsector->heightsec &&
|
||||
|
@ -1408,7 +1399,7 @@ void R_RenderBSPNode (void *node)
|
|||
node_t *bsp = (node_t *)node;
|
||||
|
||||
// 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).
|
||||
R_RenderBSPNode (bsp->children[side]);
|
||||
|
|
26
src/r_bsp.h
26
src/r_bsp.h
|
@ -30,17 +30,17 @@
|
|||
// The 3072 below is just an arbitrary value picked to avoid
|
||||
// drawing lines the player is too close to that would overflow
|
||||
// the texture calculations.
|
||||
#define TOO_CLOSE_Z 3072
|
||||
#define TOO_CLOSE_Z (3072.0 / (1<<12))
|
||||
|
||||
struct FWallCoords
|
||||
{
|
||||
fixed_t tx1, tx2; // x coords at left, right of wall in view space rx1,rx2
|
||||
fixed_t ty1, ty2; // y coords at left, right of wall in view space ry1,ry2
|
||||
FVector2 tleft; // coords at left of wall in view space rx1,ry1
|
||||
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
|
||||
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
|
||||
|
@ -49,7 +49,7 @@ struct FWallTmapVals
|
|||
float InvZorg, InvZstep;
|
||||
|
||||
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;
|
||||
|
@ -65,14 +65,14 @@ enum
|
|||
struct drawseg_t
|
||||
{
|
||||
seg_t* curline;
|
||||
fixed_t light, lightstep;
|
||||
fixed_t iscale, iscalestep;
|
||||
float light, lightstep;
|
||||
float iscale, iscalestep;
|
||||
short x1, x2; // Same as sx1 and sx2, but clipped to the drawseg
|
||||
short sx1, sx2; // left, right of parent seg on screen
|
||||
fixed_t 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
|
||||
fixed_t cx, cy, cdx, cdy;
|
||||
fixed_t yrepeat;
|
||||
float sz1, sz2; // z for left, right of parent seg on screen
|
||||
float siz1, siz2; // 1/z for left, right of parent seg on screen
|
||||
float cx, cy, cdx, cdy;
|
||||
float yscale;
|
||||
BYTE silhouette; // 0=none, 1=bottom, 2=top, 3=both
|
||||
BYTE bFogBoundary;
|
||||
BYTE bFakeBoundary; // for fake walls
|
||||
|
@ -82,7 +82,7 @@ struct drawseg_t
|
|||
ptrdiff_t sprtopclip; // type short
|
||||
ptrdiff_t sprbottomclip; // 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
|
||||
// backups
|
||||
ptrdiff_t bkup; // sprtopclip backup, for mid and fake textures
|
||||
|
|
129
src/r_defs.h
129
src/r_defs.h
|
@ -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
|
||||
fixed_t Zat0 () const
|
||||
double Zat0() const
|
||||
{
|
||||
return FLOAT2FIXED(negiC*D);
|
||||
return negiC*D;
|
||||
}
|
||||
|
||||
// Returns the value of z at (x,y)
|
||||
|
@ -387,6 +387,10 @@ public:
|
|||
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
|
||||
{
|
||||
|
@ -1200,10 +1204,10 @@ struct side_t
|
|||
};
|
||||
struct part
|
||||
{
|
||||
fixed_t xoffset;
|
||||
fixed_t yoffset;
|
||||
fixed_t xscale;
|
||||
fixed_t yscale;
|
||||
double xOffset;
|
||||
double yOffset;
|
||||
double xScale;
|
||||
double yScale;
|
||||
FTextureID texture;
|
||||
TObjPtr<DInterpolation> interpolation;
|
||||
//int Light;
|
||||
|
@ -1236,139 +1240,88 @@ struct side_t
|
|||
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)
|
||||
{
|
||||
textures[which].xoffset = FLOAT2FIXED(offset);
|
||||
textures[which].xOffset = offset;;
|
||||
}
|
||||
void SetTextureXOffset(double offset)
|
||||
{
|
||||
textures[top].xoffset =
|
||||
textures[mid].xoffset =
|
||||
textures[bottom].xoffset = FLOAT2FIXED(offset);
|
||||
}
|
||||
fixed_t GetTextureXOffset(int which) const
|
||||
{
|
||||
return textures[which].xoffset;
|
||||
textures[top].xOffset =
|
||||
textures[mid].xOffset =
|
||||
textures[bottom].xOffset = offset;
|
||||
}
|
||||
fixed_t GetTextureXOffset(int which) const = delete;
|
||||
double GetTextureXOffsetF(int which) const
|
||||
{
|
||||
return FIXED2DBL(textures[which].xoffset);
|
||||
}
|
||||
void AddTextureXOffset(int which, fixed_t delta)
|
||||
{
|
||||
textures[which].xoffset += delta;
|
||||
return textures[which].xOffset;
|
||||
}
|
||||
void AddTextureXOffset(int which, fixed_t delta) = delete;
|
||||
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)
|
||||
{
|
||||
textures[which].yoffset = FLOAT2FIXED(offset);
|
||||
textures[which].yOffset = offset;
|
||||
}
|
||||
void SetTextureYOffset(double offset)
|
||||
{
|
||||
textures[top].yoffset =
|
||||
textures[mid].yoffset =
|
||||
textures[bottom].yoffset = FLOAT2FIXED(offset);
|
||||
}
|
||||
fixed_t GetTextureYOffset(int which) const
|
||||
{
|
||||
return textures[which].yoffset;
|
||||
textures[top].yOffset =
|
||||
textures[mid].yOffset =
|
||||
textures[bottom].yOffset = offset;
|
||||
}
|
||||
fixed_t GetTextureYOffset(int which) const = delete;
|
||||
double GetTextureYOffsetF(int which) const
|
||||
{
|
||||
return FIXED2DBL(textures[which].yoffset);
|
||||
}
|
||||
void AddTextureYOffset(int which, fixed_t delta)
|
||||
{
|
||||
textures[which].yoffset += delta;
|
||||
return textures[which].yOffset;
|
||||
}
|
||||
void AddTextureYOffset(int which, fixed_t delta) = delete;
|
||||
void AddTextureYOffset(int which, double delta)
|
||||
{
|
||||
textures[which].yoffset += FLOAT2FIXED(delta);
|
||||
textures[which].yOffset += delta;
|
||||
}
|
||||
|
||||
void SetTextureXScale(int which, fixed_t scale)
|
||||
{
|
||||
textures[which].xscale = scale == 0 ? FRACUNIT : scale;
|
||||
}
|
||||
void SetTextureXScale(int which, fixed_t scale) = delete;
|
||||
void SetTextureXScale(int which, double scale)
|
||||
{
|
||||
textures[which].xscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale);
|
||||
}
|
||||
void SetTextureXScale(fixed_t scale)
|
||||
{
|
||||
textures[top].xscale = textures[mid].xscale = textures[bottom].xscale = scale == 0 ? FRACUNIT : scale;
|
||||
textures[which].xScale = scale == 0 ? 1. : scale;
|
||||
}
|
||||
void SetTextureXScale(fixed_t scale) = delete;
|
||||
void SetTextureXScale(double scale)
|
||||
{
|
||||
textures[top].xscale = textures[mid].xscale = textures[bottom].xscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale);
|
||||
}
|
||||
fixed_t GetTextureXScale(int which) const
|
||||
{
|
||||
return textures[which].xscale;
|
||||
textures[top].xScale = textures[mid].xScale = textures[bottom].xScale = scale == 0 ? 1. : scale;
|
||||
}
|
||||
fixed_t GetTextureXScale(int which) const = delete;
|
||||
double GetTextureXScaleF(int which) const
|
||||
{
|
||||
return FIXED2DBL(textures[which].xscale);
|
||||
return textures[which].xScale;
|
||||
}
|
||||
|
||||
void MultiplyTextureXScale(int which, double delta)
|
||||
{
|
||||
textures[which].xscale = fixed_t(textures[which].xscale * delta);
|
||||
}
|
||||
|
||||
|
||||
void SetTextureYScale(int which, fixed_t scale)
|
||||
{
|
||||
textures[which].yscale = scale == 0 ? FRACUNIT : scale;
|
||||
textures[which].xScale *= delta;
|
||||
}
|
||||
|
||||
void SetTextureYScale(int which, fixed_t scale) = delete;
|
||||
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)
|
||||
{
|
||||
textures[top].yscale = textures[mid].yscale = textures[bottom].yscale = scale == 0 ? FRACUNIT : scale;
|
||||
}
|
||||
void SetTextureYScale(fixed_t scale) = delete;
|
||||
void SetTextureYScale(double scale)
|
||||
{
|
||||
textures[top].yscale = textures[mid].yscale = textures[bottom].yscale = scale == 0 ? FRACUNIT : FLOAT2FIXED(scale);
|
||||
}
|
||||
fixed_t GetTextureYScale(int which) const
|
||||
{
|
||||
return textures[which].yscale;
|
||||
textures[top].yScale = textures[mid].yScale = textures[bottom].yScale = scale == 0 ? 1. : scale;
|
||||
}
|
||||
fixed_t GetTextureYScale(int which) const = delete;
|
||||
double GetTextureYScaleF(int which) const
|
||||
{
|
||||
return FIXED2DBL(textures[which].yscale);
|
||||
return textures[which].yScale;
|
||||
}
|
||||
void MultiplyTextureYScale(int which, double delta)
|
||||
{
|
||||
textures[which].yscale = fixed_t(textures[which].yscale * delta);
|
||||
textures[which].yScale *= delta;
|
||||
}
|
||||
|
||||
DInterpolation *SetInterpolation(int position);
|
||||
|
|
|
@ -86,6 +86,7 @@ void (*rt_map4cols)(int,int,int);
|
|||
// R_DrawColumn
|
||||
// Source is the top of the column to scale.
|
||||
//
|
||||
double dc_texturemid;
|
||||
extern "C" {
|
||||
int dc_pitch=0xABadCafe; // [RH] Distance between rows
|
||||
|
||||
|
@ -94,7 +95,6 @@ int dc_x;
|
|||
int dc_yl;
|
||||
int dc_yh;
|
||||
fixed_t dc_iscale;
|
||||
fixed_t dc_texturemid;
|
||||
fixed_t dc_texturefrac;
|
||||
int dc_color; // [RH] Color for column filler
|
||||
DWORD dc_srccolor;
|
||||
|
@ -1757,8 +1757,8 @@ void mvlinec4 ()
|
|||
#endif
|
||||
|
||||
extern "C" short spanend[MAXHEIGHT];
|
||||
extern fixed_t rw_light;
|
||||
extern fixed_t rw_lightstep;
|
||||
extern float rw_light;
|
||||
extern float rw_lightstep;
|
||||
extern int wallshade;
|
||||
|
||||
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
|
||||
// we need to use a new colormap.
|
||||
|
||||
fixed_t lightstep = rw_lightstep;
|
||||
fixed_t light = rw_light+lightstep*(x2-x1-1);
|
||||
double lightstep = rw_lightstep;
|
||||
double light = rw_light + rw_lightstep*(x2-x1-1);
|
||||
int x = x2-1;
|
||||
int t2 = uclip[x];
|
||||
int b2 = dclip[x];
|
||||
|
|
|
@ -34,7 +34,7 @@ extern "C" int dc_x;
|
|||
extern "C" int dc_yl;
|
||||
extern "C" int dc_yh;
|
||||
extern "C" fixed_t dc_iscale;
|
||||
extern "C" fixed_t dc_texturemid;
|
||||
extern double dc_texturemid;
|
||||
extern "C" fixed_t dc_texturefrac;
|
||||
extern "C" int dc_color; // [RH] For flat colors (no texturing)
|
||||
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
|
||||
// for double-layer skies.
|
||||
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.
|
||||
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
|
||||
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
|
||||
|
|
|
@ -1108,14 +1108,15 @@ void R_FillColumnHorizP (void)
|
|||
|
||||
void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span)
|
||||
{
|
||||
const fixed_t texturemid = FLOAT2FIXED(dc_texturemid);
|
||||
while (span->Length != 0)
|
||||
{
|
||||
const int length = span->Length;
|
||||
const int top = span->TopOffset;
|
||||
|
||||
// calculate unclipped screen coordinates for post
|
||||
dc_yl = (sprtopscreen + spryscale * top) >> FRACBITS;
|
||||
dc_yh = (sprtopscreen + spryscale * (top + length) - FRACUNIT) >> FRACBITS;
|
||||
dc_yl = xs_RoundToInt(sprtopscreen + spryscale * top);
|
||||
dc_yh = xs_RoundToInt(sprtopscreen + spryscale * (top + length) - 1);
|
||||
|
||||
if (sprflipvert)
|
||||
{
|
||||
|
@ -1136,7 +1137,7 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span)
|
|||
if (sprflipvert)
|
||||
{
|
||||
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;
|
||||
while (dc_texturefrac >= maxfrac)
|
||||
{
|
||||
|
@ -1154,8 +1155,8 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span)
|
|||
}
|
||||
else
|
||||
{
|
||||
dc_texturefrac = dc_texturemid - (top << FRACBITS)
|
||||
+ (dc_yl*dc_iscale) - FixedMul (centeryfrac-FRACUNIT, dc_iscale);
|
||||
dc_texturefrac = texturemid - (top << FRACBITS)
|
||||
+ (dc_yl*dc_iscale) - fixed_t((CenterY-1) * dc_iscale);
|
||||
while (dc_texturefrac < 0)
|
||||
{
|
||||
if (++dc_yl > dc_yh)
|
||||
|
|
198
src/r_main.cpp
198
src/r_main.cpp
|
@ -93,9 +93,9 @@ extern bool r_showviewer;
|
|||
|
||||
// PRIVATE DATA DECLARATIONS -----------------------------------------------
|
||||
|
||||
static float CurrentVisibility = 8.f;
|
||||
static fixed_t MaxVisForWall;
|
||||
static fixed_t MaxVisForFloor;
|
||||
static double CurrentVisibility = 8.f;
|
||||
static double MaxVisForWall;
|
||||
static double MaxVisForFloor;
|
||||
bool r_dontmaplines;
|
||||
|
||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||
|
@ -103,34 +103,31 @@ bool r_dontmaplines;
|
|||
CVAR (String, r_viewsize, "", CVAR_NOSET)
|
||||
CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE)
|
||||
|
||||
fixed_t r_BaseVisibility;
|
||||
fixed_t r_WallVisibility;
|
||||
fixed_t r_FloorVisibility;
|
||||
double r_BaseVisibility;
|
||||
double r_WallVisibility;
|
||||
double r_FloorVisibility;
|
||||
float r_TiltVisibility;
|
||||
fixed_t r_SpriteVisibility;
|
||||
fixed_t r_ParticleVisibility;
|
||||
fixed_t r_SkyVisibility;
|
||||
double r_SpriteVisibility;
|
||||
double r_ParticleVisibility;
|
||||
|
||||
fixed_t GlobVis;
|
||||
double GlobVis;
|
||||
fixed_t viewingrangerecip;
|
||||
fixed_t FocalLengthX;
|
||||
fixed_t FocalLengthY;
|
||||
float FocalLengthXfloat;
|
||||
double FocalLengthX;
|
||||
double FocalLengthY;
|
||||
FDynamicColormap*basecolormap; // [RH] colormap currently drawing with
|
||||
int fixedlightlev;
|
||||
lighttable_t *fixedcolormap;
|
||||
FSpecialColormap *realfixedcolormap;
|
||||
float WallTMapScale2;
|
||||
double WallTMapScale2;
|
||||
|
||||
|
||||
bool bRenderingToCanvas; // [RH] True if rendering to a special canvas
|
||||
fixed_t globaluclip, globaldclip;
|
||||
fixed_t centerxfrac;
|
||||
fixed_t centeryfrac;
|
||||
fixed_t yaspectmul;
|
||||
fixed_t baseyaspectmul; // yaspectmul without a forced aspect ratio
|
||||
float iyaspectmulfloat;
|
||||
fixed_t InvZtoScale;
|
||||
double globaluclip, globaldclip;
|
||||
double CenterX, CenterY;
|
||||
double YaspectMul;
|
||||
double BaseYaspectMul; // yaspectmul without a forced aspect ratio
|
||||
double IYaspectMul;
|
||||
double InvZtoScale;
|
||||
|
||||
// just for profiling purposes
|
||||
int linecount;
|
||||
|
@ -188,9 +185,8 @@ static inline int viewangletox(int i)
|
|||
}
|
||||
else
|
||||
{
|
||||
int t = FixedMul(finetangent[i], FocalLengthX);
|
||||
t = (centerxfrac - t + FRACUNIT-1) >> FRACBITS;
|
||||
return clamp(t, -1, viewwidth+1);
|
||||
double t = FIXED2DBL(finetangent[i]) * FocalLengthX;
|
||||
return clamp(xs_CeilToInt(CenterX - t), -1, viewwidth+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,9 +201,8 @@ void R_InitTextureMapping ()
|
|||
int i, x;
|
||||
|
||||
// Calc focallength so FieldOfView fineangles covers viewwidth.
|
||||
FocalLengthX = FixedDiv (centerxfrac, FocalTangent);
|
||||
FocalLengthY = Scale (centerxfrac, yaspectmul, FocalTangent);
|
||||
FocalLengthXfloat = (float)FocalLengthX / 65536.f;
|
||||
FocalLengthX = CenterX / FocalTangent;
|
||||
FocalLengthY = FocalLengthX * YaspectMul;
|
||||
|
||||
// This is 1/FocalTangent before the widescreen extension of FOV.
|
||||
viewingrangerecip = DivScale32(1, finetangent[FINEANGLES/4+(FieldOfView/2)]);
|
||||
|
@ -224,9 +219,9 @@ void R_InitTextureMapping ()
|
|||
// the drawn sky texture.
|
||||
// The remaining arcs are done with tantoangle instead.
|
||||
|
||||
const int t1 = MAX<int>(centerx - (FocalLengthX >> FRACBITS), 0);
|
||||
const int t2 = MIN<int>(centerx + (FocalLengthX >> FRACBITS), viewwidth);
|
||||
const fixed_t dfocus = FocalLengthX >> DBITS;
|
||||
const int t1 = MAX(int(CenterX - FocalLengthX), 0);
|
||||
const int t2 = MIN(int(CenterX + FocalLengthX), viewwidth);
|
||||
const fixed_t dfocus = FLOAT2FIXED(FocalLengthX) >> DBITS;
|
||||
|
||||
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
|
||||
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;
|
||||
|
||||
|
@ -268,7 +263,7 @@ void R_SetVisibility (float vis)
|
|||
return;
|
||||
}
|
||||
|
||||
r_BaseVisibility = xs_RoundToInt(vis * 65536.f);
|
||||
r_BaseVisibility = vis;
|
||||
|
||||
// Prevent overflow on walls
|
||||
if (r_BaseVisibility < 0 && r_BaseVisibility < -MaxVisForWall)
|
||||
|
@ -278,8 +273,8 @@ void R_SetVisibility (float vis)
|
|||
else
|
||||
r_WallVisibility = r_BaseVisibility;
|
||||
|
||||
r_WallVisibility = FixedMul (Scale (InvZtoScale, SCREENWIDTH*BaseRatioSizes[WidescreenRatio][1],
|
||||
viewwidth*SCREENHEIGHT*3), FixedMul (r_WallVisibility, FocalTangent));
|
||||
r_WallVisibility = (InvZtoScale * SCREENWIDTH*BaseRatioSizes[WidescreenRatio][1] /
|
||||
(viewwidth*SCREENHEIGHT*3)) * (r_WallVisibility * FocalTangent);
|
||||
|
||||
// Prevent overflow on floors/ceilings. Note that the calculation of
|
||||
// MaxVisForFloor means that planes less than two units from the player's
|
||||
|
@ -292,9 +287,9 @@ void R_SetVisibility (float vis)
|
|||
else
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -304,7 +299,7 @@ void R_SetVisibility (float vis)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
float R_GetVisibility ()
|
||||
double R_GetVisibility()
|
||||
{
|
||||
return CurrentVisibility;
|
||||
}
|
||||
|
@ -327,7 +322,7 @@ CCMD (r_visibility)
|
|||
}
|
||||
else if (!netgame)
|
||||
{
|
||||
R_SetVisibility ((float)atof (argv[1]));
|
||||
R_SetVisibility(atof(argv[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -359,8 +354,8 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight,
|
|||
halfviewwidth = (viewwidth >> 1) - 1;
|
||||
|
||||
lastcenteryfrac = 1<<30;
|
||||
centerxfrac = centerx<<FRACBITS;
|
||||
centeryfrac = centery<<FRACBITS;
|
||||
CenterX = centerx;
|
||||
CenterY = centery;
|
||||
|
||||
virtwidth = virtwidth2 = fullWidth;
|
||||
virtheight = virtheight2 = fullHeight;
|
||||
|
@ -383,27 +378,27 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight,
|
|||
virtwidth = virtwidth * BaseRatioSizes[WidescreenRatio][3] / 48;
|
||||
}
|
||||
|
||||
baseyaspectmul = Scale(320 << FRACBITS, virtheight2, r_Yaspect * virtwidth2);
|
||||
yaspectmul = Scale ((320<<FRACBITS), virtheight, r_Yaspect * virtwidth);
|
||||
iyaspectmulfloat = (float)virtwidth * r_Yaspect / 320.f / (float)virtheight;
|
||||
InvZtoScale = yaspectmul * centerx;
|
||||
BaseYaspectMul = 320.0 * virtheight2 / (r_Yaspect * virtwidth2);
|
||||
YaspectMul = 320.0 * virtheight / (r_Yaspect * virtwidth);
|
||||
IYaspectMul = (double)virtwidth * r_Yaspect / 320.0 / virtheight;
|
||||
InvZtoScale = YaspectMul * CenterX;
|
||||
|
||||
WallTMapScale2 = iyaspectmulfloat * 64.f / (float)centerx;
|
||||
WallTMapScale2 = IYaspectMul / CenterX;
|
||||
|
||||
// psprite scales
|
||||
pspritexscale = (centerxwide << FRACBITS) / 160;
|
||||
pspriteyscale = FixedMul (pspritexscale, yaspectmul);
|
||||
pspritexiscale = FixedDiv (FRACUNIT, pspritexscale);
|
||||
pspritexscale = centerxwide / 160.0;
|
||||
pspriteyscale = pspritexscale * YaspectMul;
|
||||
pspritexiscale = 1 / pspritexscale;
|
||||
|
||||
// thing clipping
|
||||
clearbufshort (screenheightarray, viewwidth, (short)viewheight);
|
||||
|
||||
R_InitTextureMapping ();
|
||||
|
||||
MaxVisForWall = FixedMul (Scale (InvZtoScale, SCREENWIDTH*r_Yaspect,
|
||||
viewwidth*SCREENHEIGHT), FocalTangent);
|
||||
MaxVisForWall = FixedDiv (0x7fff0000, MaxVisForWall);
|
||||
MaxVisForFloor = Scale (FixedDiv (0x7fff0000, viewheight<<(FRACBITS-2)), FocalLengthY, 160*FRACUNIT);
|
||||
MaxVisForWall = (InvZtoScale * (SCREENWIDTH*r_Yaspect) /
|
||||
(viewwidth*SCREENHEIGHT * FocalTangent));
|
||||
MaxVisForWall = 32767.0 / MaxVisForWall;
|
||||
MaxVisForFloor = 32767.0 / (viewheight * FocalLengthY / 160);
|
||||
|
||||
// Reset r_*Visibility vars
|
||||
R_SetVisibility(R_GetVisibility());
|
||||
|
@ -489,10 +484,8 @@ static void R_ShutdownRenderer()
|
|||
|
||||
void R_CopyStackedViewParameters()
|
||||
{
|
||||
stacked_viewx = viewx;
|
||||
stacked_viewy = viewy;
|
||||
stacked_viewz = viewz;
|
||||
stacked_angle = viewangle;
|
||||
stacked_viewpos = ViewPos;
|
||||
stacked_angle = ViewAngle;
|
||||
stacked_extralight = extralight;
|
||||
stacked_visibility = R_GetVisibility();
|
||||
}
|
||||
|
@ -552,58 +545,59 @@ void R_SetupColormap(player_t *player)
|
|||
void R_SetupFreelook()
|
||||
{
|
||||
{
|
||||
fixed_t dy;
|
||||
double dy;
|
||||
|
||||
if (camera != NULL)
|
||||
{
|
||||
dy = FixedMul (FocalLengthY, finetangent[(ANGLE_90-viewpitch)>>ANGLETOFINESHIFT]);
|
||||
dy = FocalLengthY * (-ViewPitch).Tan();
|
||||
}
|
||||
else
|
||||
{
|
||||
dy = 0;
|
||||
}
|
||||
|
||||
centeryfrac = (viewheight << (FRACBITS-1)) + dy;
|
||||
centery = centeryfrac >> FRACBITS;
|
||||
globaluclip = FixedDiv (-centeryfrac, InvZtoScale);
|
||||
globaldclip = FixedDiv ((viewheight<<FRACBITS)-centeryfrac, InvZtoScale);
|
||||
CenterY = (viewheight / 2.0) + dy;
|
||||
centery = xs_ToInt(CenterY);
|
||||
globaluclip = -CenterY / InvZtoScale;
|
||||
globaldclip = (viewheight - CenterY) / InvZtoScale;
|
||||
|
||||
//centeryfrac &= 0xffff0000;
|
||||
int e, i;
|
||||
|
||||
i = 0;
|
||||
e = viewheight;
|
||||
fixed_t focus = FocalLengthY;
|
||||
fixed_t den;
|
||||
float focus = float(FocalLengthY);
|
||||
float den;
|
||||
float cy = float(CenterY);
|
||||
if (i < centery)
|
||||
{
|
||||
den = centeryfrac - (i << FRACBITS) - FRACUNIT/2;
|
||||
den = cy - i - 0.5f;
|
||||
if (e <= centery)
|
||||
{
|
||||
do {
|
||||
yslope[i] = FixedDiv (focus, den);
|
||||
den -= FRACUNIT;
|
||||
yslope[i] = FLOAT2FIXED(focus / den);
|
||||
den -= 1;
|
||||
} while (++i < e);
|
||||
}
|
||||
else
|
||||
{
|
||||
do {
|
||||
yslope[i] = FixedDiv (focus, den);
|
||||
den -= FRACUNIT;
|
||||
yslope[i] = FLOAT2FIXED(focus / den);
|
||||
den -= 1;
|
||||
} while (++i < centery);
|
||||
den = (i << FRACBITS) - centeryfrac + FRACUNIT/2;
|
||||
den = i - cy + 0.5f;
|
||||
do {
|
||||
yslope[i] = FixedDiv (focus, den);
|
||||
den += FRACUNIT;
|
||||
yslope[i] = FLOAT2FIXED(focus / den);
|
||||
den += 1;
|
||||
} while (++i < e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
den = (i << FRACBITS) - centeryfrac + FRACUNIT/2;
|
||||
den = i - cy + 0.5f;
|
||||
do {
|
||||
yslope[i] = FixedDiv (focus, den);
|
||||
den += FRACUNIT;
|
||||
yslope[i] = FLOAT2FIXED(focus / den);
|
||||
den += 1;
|
||||
} while (++i < e);
|
||||
}
|
||||
}
|
||||
|
@ -688,10 +682,8 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
|
|||
return;
|
||||
}
|
||||
|
||||
angle_t startang = viewangle;
|
||||
fixed_t startx = viewx;
|
||||
fixed_t starty = viewy;
|
||||
fixed_t startz = viewz;
|
||||
DAngle startang = ViewAngle;
|
||||
DVector3 startpos = ViewPos;
|
||||
DVector3 savedpath[2] = { ViewPath[0], ViewPath[1] };
|
||||
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.
|
||||
if (pds->src->Delta().X == 0)
|
||||
{ // vertical mirror
|
||||
viewx = v1->fixX() - startx + v1->fixX();
|
||||
ViewPos.X = v1->fX() - startpos.X + v1->fX();
|
||||
}
|
||||
else if (pds->src->Delta().Y == 0)
|
||||
{ // horizontal mirror
|
||||
viewy = v1->fixY() - starty + v1->fixY();
|
||||
ViewPos.Y = v1->fY() - startpos.Y + v1->fY();
|
||||
}
|
||||
else
|
||||
{ // any mirror--use floats to avoid integer overflow
|
||||
{ // any mirror
|
||||
vertex_t *v2 = pds->src->v2;
|
||||
|
||||
double dx = v2->fX() - v1->fX();
|
||||
double dy = v2->fY() - v1->fY();
|
||||
double x1 = v1->fX();
|
||||
double y1 = v1->fY();
|
||||
double x = FIXED2DBL(startx);
|
||||
double y = FIXED2DBL(starty);
|
||||
double x = startpos.X;
|
||||
double y = startpos.Y;
|
||||
|
||||
// the above two cases catch len == 0
|
||||
double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy);
|
||||
|
||||
viewx = FLOAT2FIXED((x1 + r * dx)*2 - x);
|
||||
viewy = FLOAT2FIXED((y1 + r * dy)*2 - y);
|
||||
ViewPos.X = (x1 + r * dx)*2 - x;
|
||||
ViewPos.Y = (y1 + r * dy)*2 - y;
|
||||
}
|
||||
viewangle = pds->src->Delta().Angle().BAMs() - startang;
|
||||
ViewAngle = pds->src->Delta().Angle() - startang;
|
||||
}
|
||||
else
|
||||
{
|
||||
DVector3 view(FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz));
|
||||
DAngle va = ANGLE2DBL(viewangle);
|
||||
DVector3 view(ViewPos);
|
||||
DAngle va = ViewAngle;
|
||||
P_TranslatePortalXY(pds->src, view.X, view.Y);
|
||||
P_TranslatePortalZ(pds->src, view.Z);
|
||||
P_TranslatePortalAngle(pds->src, va);
|
||||
P_TranslatePortalXY(pds->src, ViewPath[0].X, ViewPath[0].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)
|
||||
{
|
||||
|
@ -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];
|
||||
viewcos = finecosine[viewangle>>ANGLETOFINESHIFT];
|
||||
ViewSin = ViewAngle.Sin();
|
||||
ViewCos = ViewAngle.Cos();
|
||||
|
||||
viewtansin = FixedMul (FocalTangent, viewsin);
|
||||
viewtancos = FixedMul (FocalTangent, viewcos);
|
||||
ViewTanSin = FocalTangent * ViewSin;
|
||||
ViewTanCos = FocalTangent * ViewCos;
|
||||
|
||||
R_CopyStackedViewParameters();
|
||||
|
||||
|
@ -809,7 +797,7 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
|
|||
R_DrawPortals ();
|
||||
PlaneCycles.Unclock();
|
||||
|
||||
fixed_t vzp = viewz;
|
||||
double vzp = ViewPos.Z;
|
||||
|
||||
int prevuniq = CurrentPortalUniq;
|
||||
// depth check is in another place right now
|
||||
|
@ -838,14 +826,10 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
|
|||
|
||||
CurrentPortal = prevpds;
|
||||
MirrorFlags = prevmf;
|
||||
viewangle = startang;
|
||||
viewx = startx;
|
||||
viewy = starty;
|
||||
viewz = startz;
|
||||
ViewAngle = startang;
|
||||
ViewPos = startpos;
|
||||
ViewPath[0] = savedpath[0];
|
||||
ViewPath[1] = savedpath[1];
|
||||
ViewAngle = AngleToFloat(viewangle);
|
||||
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
44
src/r_main.h
44
src/r_main.h
|
@ -35,22 +35,21 @@ typedef BYTE lighttable_t; // This could be wider for >8 bit display.
|
|||
// POV related.
|
||||
//
|
||||
extern bool bRenderingToCanvas;
|
||||
extern fixed_t viewcos;
|
||||
extern fixed_t viewsin;
|
||||
extern double ViewCos;
|
||||
extern double ViewSin;
|
||||
extern fixed_t viewingrangerecip;
|
||||
extern fixed_t FocalLengthX, FocalLengthY;
|
||||
extern float FocalLengthXfloat;
|
||||
extern fixed_t InvZtoScale;
|
||||
extern double FocalLengthX, FocalLengthY;
|
||||
extern double InvZtoScale;
|
||||
|
||||
extern float WallTMapScale2;
|
||||
extern double WallTMapScale2;
|
||||
|
||||
extern int viewwindowx;
|
||||
extern int viewwindowy;
|
||||
|
||||
extern fixed_t centerxfrac;
|
||||
extern fixed_t centeryfrac;
|
||||
extern fixed_t yaspectmul;
|
||||
extern float iyaspectmulfloat;
|
||||
extern double CenterX;
|
||||
extern double CenterY;
|
||||
extern double YaspectMul;
|
||||
extern double IYaspectMul;
|
||||
|
||||
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)))
|
||||
|
||||
// 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.
|
||||
// Result is not fixed point.
|
||||
// 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);
|
||||
float R_GetVisibility ();
|
||||
void R_SetVisibility(double visibility);
|
||||
double R_GetVisibility();
|
||||
|
||||
extern fixed_t r_BaseVisibility;
|
||||
extern fixed_t r_WallVisibility;
|
||||
extern fixed_t r_FloorVisibility;
|
||||
extern double r_BaseVisibility;
|
||||
extern double r_WallVisibility;
|
||||
extern double r_FloorVisibility;
|
||||
extern float r_TiltVisibility;
|
||||
extern fixed_t r_SpriteVisibility;
|
||||
extern fixed_t r_SkyVisibility;
|
||||
extern double r_SpriteVisibility;
|
||||
|
||||
extern int r_actualextralight;
|
||||
extern bool foggy;
|
||||
|
@ -138,9 +136,9 @@ void R_MultiresInit (void);
|
|||
|
||||
|
||||
extern int stacked_extralight;
|
||||
extern float stacked_visibility;
|
||||
extern fixed_t stacked_viewx, stacked_viewy, stacked_viewz;
|
||||
extern angle_t stacked_angle;
|
||||
extern double stacked_visibility;
|
||||
extern DVector3 stacked_viewpos;
|
||||
extern DAngle stacked_angle;
|
||||
|
||||
extern void R_CopyStackedViewParameters();
|
||||
|
||||
|
|
222
src/r_plane.cpp
222
src/r_plane.cpp
|
@ -98,9 +98,9 @@ visplane_t *ceilingplane;
|
|||
// you are changing them to draw a stacked sector. Otherwise, stacked sectors
|
||||
// won't draw in skyboxes properly.
|
||||
int stacked_extralight;
|
||||
float stacked_visibility;
|
||||
fixed_t stacked_viewx, stacked_viewy, stacked_viewz;
|
||||
angle_t stacked_angle;
|
||||
double stacked_visibility;
|
||||
DVector3 stacked_viewpos;
|
||||
DAngle stacked_angle;
|
||||
|
||||
|
||||
//
|
||||
|
@ -123,7 +123,7 @@ short ceilingclip[MAXWIDTH];
|
|||
// texture mapping
|
||||
//
|
||||
|
||||
static fixed_t planeheight;
|
||||
static double planeheight;
|
||||
|
||||
extern "C" {
|
||||
//
|
||||
|
@ -217,7 +217,7 @@ void R_MapPlane (int y, int x1)
|
|||
// [RH] Notice that I dumped the caching scheme used by Doom.
|
||||
// It did not offer any appreciable speedup.
|
||||
|
||||
distance = FixedMul (planeheight, yslope[y]);
|
||||
distance = xs_ToInt(planeheight * yslope[y]);
|
||||
|
||||
ds_xstep = FixedMul (distance, xstepscale);
|
||||
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.
|
||||
ds_colormap = basecolormap->Maps + (GETPALOOKUP (
|
||||
FixedMul (GlobVis, abs (centeryfrac - (y << FRACBITS))), planeshade) << COLORMAPSHIFT);
|
||||
GlobVis * fabs(CenterY - y), planeshade) << COLORMAPSHIFT);
|
||||
}
|
||||
|
||||
#ifdef X86_ASM
|
||||
|
@ -253,9 +253,9 @@ void R_MapPlane (int y, int x1)
|
|||
//==========================================================================
|
||||
|
||||
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 *basecolormapdata = basecolormap->Maps;
|
||||
int i = 0;
|
||||
|
@ -311,7 +311,7 @@ void R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
|
|||
}
|
||||
while (i <= width && lval >= 0)
|
||||
{
|
||||
tiltlighting[i++] = basecolormapdata + ((lval >> FRACBITS) << COLORMAPSHIFT);
|
||||
tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT);
|
||||
lval += lstep;
|
||||
}
|
||||
lightfiller = basecolormapdata;
|
||||
|
@ -334,7 +334,7 @@ void R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
|
|||
return;
|
||||
while (i <= width && lval < (NUMCOLORMAPS-1)*FRACUNIT)
|
||||
{
|
||||
tiltlighting[i++] = basecolormapdata + ((lval >> FRACBITS) << COLORMAPSHIFT);
|
||||
tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT);
|
||||
lval += lstep;
|
||||
}
|
||||
lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT);
|
||||
|
@ -371,7 +371,7 @@ void R_MapTiltedPlane (int y, int x1)
|
|||
{
|
||||
uz = (iz + plane_sz[0]*width) * 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);
|
||||
|
@ -640,9 +640,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
|
|||
// check even more.
|
||||
if (check->extralight == stacked_extralight &&
|
||||
check->visibility == stacked_visibility &&
|
||||
check->viewx == stacked_viewx &&
|
||||
check->viewy == stacked_viewy &&
|
||||
check->viewz == stacked_viewz &&
|
||||
check->viewpos == stacked_viewpos &&
|
||||
(
|
||||
// headache inducing logic... :(
|
||||
(portal->mType != PORTS_STACKEDSECTORTHING) ||
|
||||
|
@ -689,9 +687,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
|
|||
CurrentPortalUniq == check->CurrentPortalUniq &&
|
||||
MirrorFlags == check->MirrorFlags &&
|
||||
CurrentSkybox == check->CurrentSkybox &&
|
||||
viewx == check->viewx &&
|
||||
viewy == check->viewy &&
|
||||
viewz == check->viewz
|
||||
ViewPos == check->viewpos
|
||||
)
|
||||
{
|
||||
return check;
|
||||
|
@ -715,9 +711,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
|
|||
check->right = 0;
|
||||
check->extralight = stacked_extralight;
|
||||
check->visibility = stacked_visibility;
|
||||
check->viewx = stacked_viewx;
|
||||
check->viewy = stacked_viewy;
|
||||
check->viewz = stacked_viewz;
|
||||
check->viewpos = stacked_viewpos;
|
||||
check->viewangle = stacked_angle;
|
||||
check->Alpha = alpha;
|
||||
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->extralight = pl->extralight;
|
||||
new_pl->visibility = pl->visibility;
|
||||
new_pl->viewx = pl->viewx;
|
||||
new_pl->viewy = pl->viewy;
|
||||
new_pl->viewz = pl->viewz;
|
||||
new_pl->viewpos = pl->viewpos;
|
||||
new_pl->viewangle = pl->viewangle;
|
||||
new_pl->sky = pl->sky;
|
||||
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 angle_t skyflip;
|
||||
static int frontpos, backpos;
|
||||
static fixed_t frontyScale;
|
||||
static double frontyScale;
|
||||
static fixed_t frontcyl, backcyl;
|
||||
static fixed_t skymid;
|
||||
static double skymid;
|
||||
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 rw_offset;
|
||||
extern FTexture *rw_pic;
|
||||
|
@ -924,13 +916,16 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x)
|
|||
static void R_DrawSky (visplane_t *pl)
|
||||
{
|
||||
int x;
|
||||
float swal;
|
||||
|
||||
if (pl->left >= pl->right)
|
||||
return;
|
||||
|
||||
dc_iscale = skyiscale;
|
||||
|
||||
clearbuf (swall+pl->left, pl->right-pl->left, dc_iscale<<2);
|
||||
swal = skyiscale;
|
||||
for (x = pl->left; x < pl->right; ++x)
|
||||
{
|
||||
swall[x] = swal;
|
||||
}
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
|
@ -955,8 +950,8 @@ static void R_DrawSky (visplane_t *pl)
|
|||
rw_pic = frontskytex;
|
||||
rw_offset = 0;
|
||||
|
||||
frontyScale = FLOAT2FIXED(rw_pic->Scale.Y);
|
||||
dc_texturemid = MulScale16 (skymid, frontyScale);
|
||||
frontyScale = rw_pic->Scale.Y;
|
||||
dc_texturemid = skymid * frontyScale;
|
||||
|
||||
if (1 << frontskytex->HeightBits == frontskytex->GetHeight())
|
||||
{ // The texture tiles nicely
|
||||
|
@ -969,39 +964,26 @@ static void R_DrawSky (visplane_t *pl)
|
|||
}
|
||||
else
|
||||
{ // The texture does not tile nicely
|
||||
frontyScale = DivScale16 (skyscale, frontyScale);
|
||||
frontiScale = DivScale32 (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;
|
||||
}
|
||||
frontyScale *= skyscale;
|
||||
frontiScale = 1 / frontyScale;
|
||||
R_DrawSkyStriped (pl);
|
||||
}
|
||||
}
|
||||
|
||||
static void R_DrawSkyStriped (visplane_t *pl)
|
||||
{
|
||||
fixed_t centerysave = centeryfrac;
|
||||
short drawheight = (short)MulScale16 (frontskytex->GetHeight(), frontyScale);
|
||||
fixed_t topfrac;
|
||||
fixed_t iscale = frontiScale;
|
||||
short drawheight = short(frontskytex->GetHeight() * frontyScale);
|
||||
double topfrac;
|
||||
double iscale = frontiScale;
|
||||
short top[MAXWIDTH], bot[MAXWIDTH];
|
||||
short yl, yh;
|
||||
int x;
|
||||
|
||||
// So that I don't have to worry about fractional precision, chop off the
|
||||
// fractional part of centeryfrac.
|
||||
centeryfrac = centery << FRACBITS;
|
||||
topfrac = (skymid + iscale * (1-centery)) % (frontskytex->GetHeight() << FRACBITS);
|
||||
if (topfrac < 0) topfrac += frontskytex->GetHeight() << FRACBITS;
|
||||
topfrac = fmod(skymid + iscale * (1 - CenterY), frontskytex->GetHeight());
|
||||
if (topfrac < 0) topfrac += frontskytex->GetHeight();
|
||||
yl = 0;
|
||||
yh = (short)MulScale32 ((frontskytex->GetHeight() << FRACBITS) - topfrac, frontyScale);
|
||||
dc_texturemid = topfrac - iscale * (1-centery);
|
||||
fixed_t yScale = FLOAT2FIXED(rw_pic->Scale.Y);
|
||||
yh = short((frontskytex->GetHeight() - topfrac) * frontyScale);
|
||||
dc_texturemid = topfrac - iscale * (1 - CenterY);
|
||||
|
||||
while (yl < viewheight)
|
||||
{
|
||||
|
@ -1014,13 +996,12 @@ static void R_DrawSkyStriped (visplane_t *pl)
|
|||
{
|
||||
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);
|
||||
yl = yh;
|
||||
yh += drawheight;
|
||||
dc_texturemid = iscale * (centery-yl-1);
|
||||
}
|
||||
centeryfrac = centerysave;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -1060,15 +1041,15 @@ int R_DrawPlanes ()
|
|||
}
|
||||
|
||||
// kg3D - draw all visplanes with "height"
|
||||
void R_DrawHeightPlanes(fixed_t height)
|
||||
void R_DrawHeightPlanes(double height)
|
||||
{
|
||||
visplane_t *pl;
|
||||
int i;
|
||||
|
||||
ds_color = 3;
|
||||
|
||||
fixed_t oViewX = viewx, oViewY = viewy, oViewZ = viewz;
|
||||
angle_t oViewAngle = viewangle;
|
||||
DVector3 oViewPos = ViewPos;
|
||||
DAngle oViewAngle = ViewAngle;
|
||||
|
||||
for (i = 0; i < MAXVISPLANES; i++)
|
||||
{
|
||||
|
@ -1078,24 +1059,15 @@ void R_DrawHeightPlanes(fixed_t height)
|
|||
if(pl->CurrentSkybox != CurrentSkybox || pl->CurrentPortalUniq != CurrentPortalUniq)
|
||||
continue;
|
||||
if(pl->sky < 0 && pl->height.Zat0() == height) {
|
||||
viewx = pl->viewx;
|
||||
viewy = pl->viewy;
|
||||
viewz = pl->viewz;
|
||||
viewangle = pl->viewangle;
|
||||
ViewAngle = AngleToFloat(viewangle);
|
||||
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
|
||||
ViewPos = pl->viewpos;
|
||||
ViewAngle = pl->viewangle;
|
||||
MirrorFlags = pl->MirrorFlags;
|
||||
R_DrawSinglePlane (pl, pl->sky & 0x7FFFFFFF, pl->Additive, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewx = oViewX;
|
||||
viewy = oViewY;
|
||||
viewz = oViewZ;
|
||||
viewangle = oViewAngle;
|
||||
ViewAngle = AngleToFloat(viewangle);
|
||||
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
|
||||
ViewPos = oViewPos;
|
||||
ViewAngle = oViewAngle;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1186,7 +1158,7 @@ void R_DrawPortals ()
|
|||
static TArray<size_t> interestingStack;
|
||||
static TArray<ptrdiff_t> drawsegStack;
|
||||
static TArray<ptrdiff_t> visspriteStack;
|
||||
static TArray<fixed_t> viewxStack, viewyStack, viewzStack;
|
||||
static TArray<DVector3> viewposStack;
|
||||
static TArray<visplane_t *> visplaneStack;
|
||||
|
||||
numskyboxes = 0;
|
||||
|
@ -1198,15 +1170,13 @@ void R_DrawPortals ()
|
|||
CurrentPortalInSkybox = true;
|
||||
|
||||
int savedextralight = extralight;
|
||||
fixed_t savedx = viewx;
|
||||
fixed_t savedy = viewy;
|
||||
fixed_t savedz = viewz;
|
||||
angle_t savedangle = viewangle;
|
||||
DVector3 savedpos = ViewPos;
|
||||
DAngle savedangle = ViewAngle;
|
||||
ptrdiff_t savedvissprite_p = vissprite_p - vissprites;
|
||||
ptrdiff_t savedds_p = ds_p - drawsegs;
|
||||
ptrdiff_t savedlastopening = lastopening;
|
||||
size_t savedinteresting = FirstInterestingDrawseg;
|
||||
float savedvisibility = R_GetVisibility ();
|
||||
double savedvisibility = R_GetVisibility();
|
||||
AActor *savedcamera = camera;
|
||||
sector_t *savedsector = viewsector;
|
||||
|
||||
|
@ -1241,11 +1211,8 @@ void R_DrawPortals ()
|
|||
extralight = 0;
|
||||
R_SetVisibility(sky->args[0] * 0.25f);
|
||||
|
||||
DVector3 viewpos = sky->InterpolatedPosition(r_TicFracF);
|
||||
viewx = FLOAT2FIXED(viewpos.X);
|
||||
viewy = FLOAT2FIXED(viewpos.Y);
|
||||
viewz = FLOAT2FIXED(viewpos.Z);
|
||||
viewangle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF).BAMs();
|
||||
ViewPos = sky->InterpolatedPosition(r_TicFracF);
|
||||
ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF);
|
||||
|
||||
R_CopyStackedViewParameters();
|
||||
break;
|
||||
|
@ -1256,10 +1223,10 @@ void R_DrawPortals ()
|
|||
case PORTS_LINKEDPORTAL:
|
||||
extralight = pl->extralight;
|
||||
R_SetVisibility (pl->visibility);
|
||||
viewx = pl->viewx + FLOAT2FIXED(port->mDisplacement.X);
|
||||
viewy = pl->viewy + FLOAT2FIXED(port->mDisplacement.Y);
|
||||
viewz = pl->viewz;
|
||||
viewangle = pl->viewangle;
|
||||
ViewPos.X = pl->viewpos.X + port->mDisplacement.X;
|
||||
ViewPos.Y = pl->viewpos.Y + port->mDisplacement.Y;
|
||||
ViewPos.Z = pl->viewpos.Z;
|
||||
ViewAngle = pl->viewangle;
|
||||
break;
|
||||
|
||||
case PORTS_HORIZON:
|
||||
|
@ -1274,9 +1241,6 @@ void R_DrawPortals ()
|
|||
continue;
|
||||
}
|
||||
|
||||
ViewAngle = AngleToFloat(viewangle);
|
||||
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
|
||||
|
||||
port->mFlags |= PORTSF_INSKYBOX;
|
||||
if (port->mPartner > 0) sectorPortals[port->mPartner].mFlags |= PORTSF_INSKYBOX;
|
||||
camera = NULL;
|
||||
|
@ -1332,9 +1296,7 @@ void R_DrawPortals ()
|
|||
drawsegStack.Push (diffnum);
|
||||
diffnum = firstvissprite - vissprites;
|
||||
visspriteStack.Push (diffnum);
|
||||
viewxStack.Push (viewx);
|
||||
viewyStack.Push (viewy);
|
||||
viewzStack.Push (viewz);
|
||||
viewposStack.Push(ViewPos);
|
||||
visplaneStack.Push (pl);
|
||||
|
||||
InSubsector = NULL;
|
||||
|
@ -1357,9 +1319,9 @@ void R_DrawPortals ()
|
|||
firstdrawseg = drawsegs + pd;
|
||||
visspriteStack.Pop (pd);
|
||||
firstvissprite = vissprites + pd;
|
||||
viewxStack.Pop (viewx); // Masked textures and planes need the view
|
||||
viewyStack.Pop (viewy); // coordinates restored for proper positioning.
|
||||
viewzStack.Pop (viewz);
|
||||
|
||||
// Masked textures and planes need the view coordinates restored for proper positioning.
|
||||
viewposStack.Pop(ViewPos);
|
||||
|
||||
R_DrawMasked ();
|
||||
|
||||
|
@ -1385,14 +1347,10 @@ void R_DrawPortals ()
|
|||
|
||||
camera = savedcamera;
|
||||
viewsector = savedsector;
|
||||
viewx = savedx;
|
||||
viewy = savedy;
|
||||
viewz = savedz;
|
||||
ViewPos = savedpos;
|
||||
R_SetVisibility(savedvisibility);
|
||||
extralight = savedextralight;
|
||||
viewangle = savedangle;
|
||||
ViewAngle = AngleToFloat(viewangle);
|
||||
ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) };
|
||||
ViewAngle = savedangle;
|
||||
R_SetViewAngle ();
|
||||
|
||||
CurrentPortalInSkybox = false;
|
||||
|
@ -1432,7 +1390,7 @@ void R_DrawSkyPlane (visplane_t *pl)
|
|||
}
|
||||
sky2tex = sky2texture;
|
||||
skymid = skytexturemid;
|
||||
skyangle = viewangle;
|
||||
skyangle = ViewAngle.BAMs();
|
||||
|
||||
if (pl->picnum == skyflatnum)
|
||||
{
|
||||
|
@ -1489,10 +1447,10 @@ void R_DrawSkyPlane (visplane_t *pl)
|
|||
// to allow sky rotation as well as careful positioning.
|
||||
// However, the offset is scaled very small, so that it
|
||||
// allows a long-period of sky rotation.
|
||||
skyangle += s->GetTextureXOffset(pos);
|
||||
skyangle += FLOAT2FIXED(s->GetTextureXOffsetF(pos));
|
||||
|
||||
// Vertical offset allows careful sky positioning.
|
||||
skymid = s->GetTextureYOffset(pos) - 28*FRACUNIT;
|
||||
skymid = s->GetTextureYOffsetF(pos) - 28;
|
||||
|
||||
// We sometimes flip the picture horizontally.
|
||||
//
|
||||
|
@ -1505,7 +1463,7 @@ void R_DrawSkyPlane (visplane_t *pl)
|
|||
frontcyl = MAX(frontskytex->GetWidth(), frontxscale);
|
||||
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 cosine = cos(rad), sine = sin(rad);
|
||||
|
||||
pviewx = xs_RoundToInt(pl->xoffs + viewx * cosine - viewy * sine);
|
||||
pviewy = xs_RoundToInt(pl->yoffs - viewx * sine - viewy * cosine);
|
||||
pviewx = xs_RoundToInt(pl->xoffs + FLOAT2FIXED(ViewPos.X * cosine - ViewPos.Y * sine));
|
||||
pviewy = xs_RoundToInt(pl->yoffs - FLOAT2FIXED(ViewPos.X * sine - ViewPos.Y * cosine));
|
||||
}
|
||||
else
|
||||
{
|
||||
pviewx = pl->xoffs + viewx;
|
||||
pviewy = pl->yoffs - viewy;
|
||||
pviewx = pl->xoffs + FLOAT2FIXED(ViewPos.X);
|
||||
pviewy = pl->yoffs - FLOAT2FIXED(ViewPos.Y);
|
||||
}
|
||||
|
||||
pviewx = FixedMul (xscale, pviewx);
|
||||
pviewy = FixedMul (yscale, pviewy);
|
||||
|
||||
// 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
|
||||
xstepscale = Scale (xscale, finecosine[planeang], FocalLengthX);
|
||||
ystepscale = Scale (yscale, -finesine[planeang], FocalLengthX);
|
||||
xstepscale = fixed_t(FixedMul(xscale, finecosine[planeang]) / FocalLengthX);
|
||||
ystepscale = fixed_t(FixedMul(yscale, -finesine[planeang]) / FocalLengthX);
|
||||
|
||||
// [RH] flip for mirrors
|
||||
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;
|
||||
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)
|
||||
ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false;
|
||||
else if (fixedcolormap)
|
||||
|
@ -1678,15 +1636,11 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
|
|||
return;
|
||||
}
|
||||
|
||||
double vx = FIXED2DBL(viewx);
|
||||
double vy = FIXED2DBL(viewy);
|
||||
double vz = FIXED2DBL(viewz);
|
||||
|
||||
lxscale = FIXED2DBL(pl->xscale) * ifloatpow2[ds_xbits];
|
||||
lyscale = FIXED2DBL(pl->yscale) * ifloatpow2[ds_ybits];
|
||||
xscale = 64.f / lxscale;
|
||||
yscale = 64.f / lyscale;
|
||||
zeroheight = pl->height.ZatPoint(vx, vy);
|
||||
zeroheight = pl->height.ZatPoint(ViewPos);
|
||||
|
||||
pviewx = MulScale (pl->xoffs, pl->xscale, ds_xbits);
|
||||
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
|
||||
// Don't add in the offsets at this stage, because doing so can result in
|
||||
// errors if the flat is rotated.
|
||||
ang = (ANG270 - viewangle) * (M_PI / ANGLE_180);
|
||||
p[0] = vx * cos(ang) - vy * sin(ang);
|
||||
p[2] = vx * sin(ang) + vy * cos(ang);
|
||||
p[1] = pl->height.ZatPoint(0.0, 0.0) - vz;
|
||||
ang = (DAngle(270.) - ViewAngle).Radians();
|
||||
p[0] = ViewPos.X * cos(ang) - ViewPos.Y * sin(ang);
|
||||
p[2] = ViewPos.X * sin(ang) + ViewPos.Y * cos(ang);
|
||||
p[1] = pl->height.ZatPoint(0.0, 0.0) - ViewPos.Z;
|
||||
|
||||
// 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[2] = yscale * sin(ang);
|
||||
// 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
|
||||
// the textures a constant size across the surface's plane instead.
|
||||
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;
|
||||
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_sv = p ^ n;
|
||||
plane_sz = m ^ n;
|
||||
|
||||
plane_su.Z *= FocalLengthXfloat;
|
||||
plane_sv.Z *= FocalLengthXfloat;
|
||||
plane_sz.Z *= FocalLengthXfloat;
|
||||
plane_su.Z *= FocalLengthX;
|
||||
plane_sv.Z *= FocalLengthX;
|
||||
plane_sz.Z *= FocalLengthX;
|
||||
|
||||
plane_su.Y *= iyaspectmulfloat;
|
||||
plane_sv.Y *= iyaspectmulfloat;
|
||||
plane_sz.Y *= iyaspectmulfloat;
|
||||
plane_su.Y *= IYaspectMul;
|
||||
plane_sv.Y *= IYaspectMul;
|
||||
plane_sz.Y *= IYaspectMul;
|
||||
|
||||
// Premultiply the texture vectors with the scale factors
|
||||
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];
|
||||
}
|
||||
|
||||
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)
|
||||
planelightfloat = -planelightfloat;
|
||||
|
|
|
@ -50,9 +50,9 @@ struct visplane_s
|
|||
// have stacked sectors inside a skybox. If the visplane is not for a
|
||||
// stack, then they are unused.
|
||||
int extralight;
|
||||
float visibility;
|
||||
fixed_t viewx, viewy, viewz;
|
||||
angle_t viewangle;
|
||||
double visibility;
|
||||
DVector3 viewpos;
|
||||
DAngle viewangle;
|
||||
fixed_t Alpha;
|
||||
bool Additive;
|
||||
|
||||
|
|
660
src/r_segs.cpp
660
src/r_segs.cpp
File diff suppressed because it is too large
Load diff
14
src/r_segs.h
14
src/r_segs.h
|
@ -31,10 +31,10 @@ extern short *openings;
|
|||
extern ptrdiff_t lastopening;
|
||||
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);
|
||||
void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat, int x1, int x2);
|
||||
void PrepLWall (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, double walxrepeat, int x1, int x2);
|
||||
|
||||
ptrdiff_t R_NewOpening (ptrdiff_t len);
|
||||
|
||||
|
@ -42,11 +42,11 @@ void R_CheckDrawSegs ();
|
|||
|
||||
void R_RenderSegLoop ();
|
||||
|
||||
extern fixed_t swall[MAXWIDTH];
|
||||
extern float swall[MAXWIDTH];
|
||||
extern fixed_t lwall[MAXWIDTH];
|
||||
extern fixed_t rw_light; // [RH] Scale lights with viewsize adjustments
|
||||
extern fixed_t rw_lightstep;
|
||||
extern fixed_t rw_lightleft;
|
||||
extern float rw_light; // [RH] Scale lights with viewsize adjustments
|
||||
extern float rw_lightstep;
|
||||
extern float rw_lightleft;
|
||||
extern fixed_t rw_offset;
|
||||
|
||||
/* portal structure, this is used in r_ code in order to store drawsegs with portals (and mirrors) */
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
//
|
||||
FTextureID skyflatnum;
|
||||
FTextureID sky1texture, sky2texture;
|
||||
fixed_t skytexturemid;
|
||||
fixed_t skyscale;
|
||||
fixed_t skyiscale;
|
||||
double skytexturemid;
|
||||
double skyscale;
|
||||
float skyiscale;
|
||||
bool skystretch;
|
||||
|
||||
fixed_t sky1cyl, sky2cyl;
|
||||
|
@ -54,7 +54,7 @@ CUSTOM_CVAR (Bool, r_stretchsky, true, CVAR_ARCHIVE)
|
|||
R_InitSkyMap ();
|
||||
}
|
||||
|
||||
fixed_t freelookviewheight;
|
||||
int freelookviewheight;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -103,28 +103,27 @@ void R_InitSkyMap ()
|
|||
&& skyheight >= 128
|
||||
&& level.IsFreelookAllowed()
|
||||
&& !(level.flags & LEVEL_FORCENOSKYSTRETCH)) ? 1 : 0;
|
||||
skytexturemid = -28*FRACUNIT;
|
||||
skytexturemid = -28;
|
||||
}
|
||||
else if (skyheight > 200)
|
||||
{
|
||||
skytexturemid = FLOAT2FIXED((200 - skyheight) * skytex1->Scale.Y);
|
||||
skytexturemid = (200 - skyheight) * skytex1->Scale.Y;
|
||||
}
|
||||
|
||||
if (viewwidth != 0 && viewheight != 0)
|
||||
{
|
||||
skyiscale = (r_Yaspect*FRACUNIT) / ((freelookviewheight * viewwidth) / viewwidth);
|
||||
skyscale = (((freelookviewheight * viewwidth) / viewwidth) << FRACBITS) /
|
||||
(r_Yaspect);
|
||||
skyiscale = float(r_Yaspect / freelookviewheight);
|
||||
skyscale = freelookviewheight / r_Yaspect;
|
||||
|
||||
skyiscale = Scale (skyiscale, FieldOfView, 2048);
|
||||
skyscale = Scale (skyscale, 2048, FieldOfView);
|
||||
skyiscale *= FieldOfView / 2048.f;
|
||||
skyscale *= 2048.0 / FieldOfView;
|
||||
}
|
||||
|
||||
if (skystretch)
|
||||
{
|
||||
skyscale = Scale(skyscale, SKYSTRETCH_HEIGHT, skyheight);
|
||||
skyiscale = Scale(skyiscale, skyheight, SKYSTRETCH_HEIGHT);
|
||||
skytexturemid = Scale(skytexturemid, skyheight, SKYSTRETCH_HEIGHT);
|
||||
skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight;
|
||||
skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT;
|
||||
skytexturemid *= skyheight / (double)SKYSTRETCH_HEIGHT;
|
||||
}
|
||||
|
||||
// The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees,
|
||||
|
|
|
@ -28,11 +28,11 @@ extern FTextureID skyflatnum;
|
|||
extern fixed_t sky1cyl, sky2cyl;
|
||||
extern FTextureID sky1texture, sky2texture;
|
||||
extern double sky1pos, sky2pos;
|
||||
extern fixed_t skytexturemid;
|
||||
extern fixed_t skyiscale;
|
||||
extern fixed_t skyscale;
|
||||
extern double skytexturemid;
|
||||
extern float skyiscale;
|
||||
extern double skyscale;
|
||||
extern bool skystretch;
|
||||
extern fixed_t freelookviewheight;
|
||||
extern int freelookviewheight;
|
||||
|
||||
#define SKYSTRETCH_HEIGHT 228
|
||||
|
||||
|
|
473
src/r_things.cpp
473
src/r_things.cpp
File diff suppressed because it is too large
Load diff
|
@ -32,15 +32,20 @@
|
|||
struct vissprite_t
|
||||
{
|
||||
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;
|
||||
fixed_t gzb, gzt; // global bottom / top for silhouette clipping
|
||||
fixed_t xscale, yscale;
|
||||
fixed_t depth;
|
||||
fixed_t idepth; // 1/z
|
||||
fixed_t deltax, deltay;
|
||||
fixed_t xscale;
|
||||
float yscale;
|
||||
float depth;
|
||||
float idepth; // 1/z
|
||||
float deltax, deltay;
|
||||
DWORD FillColor;
|
||||
fixed_t floorclip;
|
||||
double floorclip;
|
||||
union
|
||||
{
|
||||
FTexture *pic;
|
||||
|
@ -51,7 +56,7 @@ struct vissprite_t
|
|||
// Used by face sprites
|
||||
struct
|
||||
{
|
||||
fixed_t texturemid;
|
||||
double texturemid;
|
||||
fixed_t startfrac; // horizontal position of x1
|
||||
fixed_t xiscale; // negative if flipped
|
||||
};
|
||||
|
@ -63,8 +68,8 @@ struct vissprite_t
|
|||
// Used by voxels
|
||||
struct
|
||||
{
|
||||
fixed_t vx, vy, vz; // view origin
|
||||
angle_t vang; // view angle
|
||||
FVector3 vpos; // view origin
|
||||
FAngle vang; // view angle
|
||||
};
|
||||
};
|
||||
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
|
||||
visstyle_t Style;
|
||||
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;
|
||||
|
@ -101,13 +109,13 @@ extern short screenheightarray[MAXWIDTH];
|
|||
// vars for R_DrawMaskedColumn
|
||||
extern short* mfloorclip;
|
||||
extern short* mceilingclip;
|
||||
extern fixed_t spryscale;
|
||||
extern fixed_t sprtopscreen;
|
||||
extern double spryscale;
|
||||
extern double sprtopscreen;
|
||||
extern bool sprflipvert;
|
||||
|
||||
extern fixed_t pspritexscale;
|
||||
extern fixed_t pspriteyscale;
|
||||
extern fixed_t pspritexiscale;
|
||||
extern double pspritexscale;
|
||||
extern double pspritexiscale;
|
||||
extern double pspriteyscale;
|
||||
|
||||
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 };
|
||||
|
||||
void R_DrawVoxel(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle,
|
||||
fixed_t dasprx, fixed_t daspry, fixed_t dasprz, angle_t dasprang,
|
||||
fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj,
|
||||
void R_DrawVoxel(const FVector3 &viewpos, FAngle viewangle,
|
||||
const FVector3 &sprpos, angle_t dasprang,
|
||||
fixed_t daxscale, fixed_t dayscale, struct FVoxel *voxobj,
|
||||
lighttable_t *colormap, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags);
|
||||
|
||||
void R_ClipVisSprite (vissprite_t *vis, int xl, int xh);
|
||||
|
|
|
@ -123,8 +123,8 @@ int otic;
|
|||
|
||||
sector_t *viewsector;
|
||||
|
||||
fixed_t viewcos, viewtancos;
|
||||
fixed_t viewsin, viewtansin;
|
||||
double ViewCos, ViewTanCos;
|
||||
double ViewSin, ViewTanSin;
|
||||
|
||||
AActor *camera; // [RH] camera to draw from. doesn't have to be a player
|
||||
|
||||
|
@ -142,7 +142,7 @@ int WidescreenRatio;
|
|||
int setblocks;
|
||||
int extralight;
|
||||
bool setsizeneeded;
|
||||
fixed_t FocalTangent;
|
||||
double FocalTangent;
|
||||
|
||||
unsigned int R_OldBlend = ~0;
|
||||
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;
|
||||
|
||||
fixed_t viewx, viewy, viewz;
|
||||
angle_t viewangle;
|
||||
int viewpitch;
|
||||
DVector3a view;
|
||||
DAngle viewpitch;
|
||||
|
||||
|
||||
// CODE --------------------------------------------------------------------
|
||||
|
@ -463,7 +462,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
|||
fov = 170*FINEANGLES/360;
|
||||
}
|
||||
|
||||
FocalTangent = finetangent[FINEANGLES/4+fov/2];
|
||||
FocalTangent = FIXED2FLOAT(finetangent[FINEANGLES/4+fov/2]);
|
||||
Renderer->SetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio);
|
||||
}
|
||||
|
||||
|
@ -737,11 +736,11 @@ void R_ResetViewInterpolation ()
|
|||
|
||||
void R_SetViewAngle ()
|
||||
{
|
||||
viewsin = FLOAT2FIXED(ViewAngle.Sin());
|
||||
viewcos = FLOAT2FIXED(ViewAngle.Cos());
|
||||
ViewSin = ViewAngle.Sin();
|
||||
ViewCos = ViewAngle.Cos();
|
||||
|
||||
viewtansin = FixedMul (FocalTangent, viewsin);
|
||||
viewtancos = FixedMul (FocalTangent, viewcos);
|
||||
ViewTanSin = FocalTangent * ViewSin;
|
||||
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->SetupFrame(player);
|
||||
|
||||
|
|
|
@ -17,18 +17,14 @@ extern DAngle ViewAngle;
|
|||
extern DAngle ViewPitch;
|
||||
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 centery;
|
||||
|
||||
extern int setblocks;
|
||||
|
||||
extern fixed_t viewtancos;
|
||||
extern fixed_t viewtansin;
|
||||
extern fixed_t FocalTangent;
|
||||
extern double ViewTanCos;
|
||||
extern double ViewTanSin;
|
||||
extern double FocalTangent;
|
||||
|
||||
extern bool r_NoInterpolate;
|
||||
extern int validcount;
|
||||
|
@ -43,7 +39,7 @@ extern DWORD r_FrameTime;
|
|||
extern int extralight;
|
||||
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.
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -199,33 +199,26 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
|
|||
unmaskedSpan[1].Length = 0;
|
||||
}
|
||||
|
||||
fixed_t centeryback = centeryfrac;
|
||||
centeryfrac = 0;
|
||||
double centeryback = CenterY;
|
||||
CenterY = 0;
|
||||
|
||||
sprtopscreen = FLOAT2FIXED(y0);
|
||||
// There is not enough precision in the drawing routines to keep the full
|
||||
// precision for y0. :(
|
||||
sprtopscreen &= ~(FRACUNIT - 1);
|
||||
double dummy;
|
||||
sprtopscreen = modf(y0, &dummy);
|
||||
|
||||
double yscale = parms.destheight / img->GetHeight();
|
||||
double iyscale = 1 / yscale;
|
||||
|
||||
spryscale = FLOAT2FIXED(yscale);
|
||||
assert(spryscale > 2);
|
||||
#if 0
|
||||
// Fix precision errors that are noticeable at some resolutions
|
||||
if ((y0 + parms.destheight) > (y0 + yscale * img->GetHeight()))
|
||||
{
|
||||
spryscale++;
|
||||
}
|
||||
#endif
|
||||
spryscale = yscale;
|
||||
assert(spryscale > 0);
|
||||
|
||||
sprflipvert = false;
|
||||
//dc_iscale = FLOAT2FIXED(iyscale);
|
||||
//dc_texturemid = FLOAT2FIXED((-y0) * iyscale);
|
||||
//dc_texturemid = (-y0) * iyscale;
|
||||
//dc_iscale = 0xffffffffu / (unsigned)spryscale;
|
||||
dc_iscale = DivScale32(1, spryscale);
|
||||
dc_texturemid = FixedMul(-sprtopscreen, dc_iscale) + FixedMul(centeryfrac-FRACUNIT, dc_iscale);
|
||||
dc_iscale = FLOAT2FIXED(1 / spryscale);
|
||||
dc_texturemid = (CenterY - 1 - sprtopscreen) * dc_iscale / 65536;
|
||||
fixed_t frac = 0;
|
||||
double xiscale = img->GetWidth() / parms.destwidth;
|
||||
double x2 = x0 + parms.destwidth;
|
||||
|
@ -325,7 +318,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
|
|||
frac += xiscale_i;
|
||||
}
|
||||
}
|
||||
centeryfrac = centeryback;
|
||||
CenterY = centeryback;
|
||||
}
|
||||
R_FinishSetPatchStyle ();
|
||||
|
||||
|
|
|
@ -72,11 +72,11 @@ const char *GetVersionString();
|
|||
// SAVESIG should match SAVEVER.
|
||||
|
||||
// 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
|
||||
// SVN revision ever got.
|
||||
#define SAVEVER 4540
|
||||
#define SAVEVER 4541
|
||||
|
||||
#define SAVEVERSTRINGIFY2(x) #x
|
||||
#define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ include( CheckFunctionExists )
|
|||
include( CheckTypeSize )
|
||||
|
||||
if( MSVC )
|
||||
# Runtime type information is required
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR" )
|
||||
# Runtime type information is required and don't complain about uint32_t to bool conversions
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR /wd4800" )
|
||||
endif()
|
||||
|
||||
set( PACKAGE_NAME re2c )
|
||||
|
|
Loading…
Reference in a new issue