- removed some fixed point functions that are no longer needed.

- fixed: Visplane checks should only compare the plane flags that are relevant for rendering and mask out the rest.
- floatified FTransform and made the visplane checks a bit less verbose by moving the comparison as an operator into FTransform.

Note that this operator needs forceinline on Visual Studio so that it won't get called as a function.
This commit is contained in:
Christoph Oelckers 2016-04-23 12:42:07 +02:00
parent 35a6994d0a
commit 04e614daec
6 changed files with 57 additions and 140 deletions

View file

@ -487,8 +487,8 @@ FArchive &operator<< (FArchive &arc, side_t::part &p)
FArchive &operator<< (FArchive &arc, sector_t::splane &p)
{
arc << p.xform.xoffs << p.xform.yoffs << p.xform.xscale << p.xform.yscale
<< p.xform.angle << p.xform.base_yoffs << p.xform.base_angle
arc << p.xform.xOffs << p.xform.yOffs << p.xform.xScale << p.xform.yScale
<< p.xform.Angle << p.xform.baseyOffs << p.xform.baseAngle
<< p.Flags << p.Light << p.Texture << p.TexZ << p.alpha;
return arc;
}

View file

@ -680,28 +680,18 @@ void R_AddLine (seg_t *line)
|| curline->sidedef->GetTexture(side_t::mid).isValid()
// killough 3/7/98: Take flats offsets into account:
|| backsector->GetXOffset(sector_t::floor) != frontsector->GetXOffset(sector_t::floor)
|| backsector->GetYOffset(sector_t::floor) != frontsector->GetYOffset(sector_t::floor)
|| backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling)
|| backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling)
|| backsector->planes[sector_t::floor].xform != frontsector->planes[sector_t::floor].xform
|| backsector->planes[sector_t::ceiling].xform != frontsector->planes[sector_t::ceiling].xform
|| backsector->GetPlaneLight(sector_t::floor) != frontsector->GetPlaneLight(sector_t::floor)
|| backsector->GetPlaneLight(sector_t::ceiling) != frontsector->GetPlaneLight(sector_t::ceiling)
|| backsector->GetFlags(sector_t::floor) != frontsector->GetFlags(sector_t::floor)
|| backsector->GetFlags(sector_t::ceiling) != frontsector->GetFlags(sector_t::ceiling)
|| backsector->GetVisFlags(sector_t::floor) != frontsector->GetVisFlags(sector_t::floor)
|| backsector->GetVisFlags(sector_t::ceiling) != frontsector->GetVisFlags(sector_t::ceiling)
// [RH] Also consider colormaps
|| backsector->ColorMap != frontsector->ColorMap
// [RH] and scaling
|| backsector->GetXScale(sector_t::floor) != frontsector->GetXScale(sector_t::floor)
|| backsector->GetYScale(sector_t::floor) != frontsector->GetYScale(sector_t::floor)
|| backsector->GetXScale(sector_t::ceiling) != frontsector->GetXScale(sector_t::ceiling)
|| backsector->GetYScale(sector_t::ceiling) != frontsector->GetYScale(sector_t::ceiling)
// [RH] and rotation
|| backsector->GetAngle(sector_t::floor) != frontsector->GetAngle(sector_t::floor)
|| backsector->GetAngle(sector_t::ceiling) != frontsector->GetAngle(sector_t::ceiling)
// kg3D - and fake lights
|| (frontsector->e && frontsector->e->XFloor.lightlist.Size())
@ -1118,11 +1108,7 @@ void R_Subsector (subsector_t *sub)
ceilinglightlevel + r_actualextralight, // killough 4/11/98
frontsector->GetAlpha(sector_t::ceiling),
!!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE),
frontsector->GetXOffset(sector_t::ceiling), // killough 3/7/98
frontsector->GetYOffset(sector_t::ceiling), // killough 3/7/98
frontsector->GetXScale(sector_t::ceiling),
frontsector->GetYScale(sector_t::ceiling),
frontsector->GetAngle(sector_t::ceiling),
frontsector->planes[sector_t::ceiling].xform,
frontsector->sky,
portal
) : NULL;
@ -1159,11 +1145,7 @@ void R_Subsector (subsector_t *sub)
floorlightlevel + r_actualextralight, // killough 3/16/98
frontsector->GetAlpha(sector_t::floor),
!!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE),
frontsector->GetXOffset(sector_t::floor), // killough 3/7/98
frontsector->GetYOffset(sector_t::floor), // killough 3/7/98
frontsector->GetXScale(sector_t::floor),
frontsector->GetYScale(sector_t::floor),
frontsector->GetAngle(sector_t::floor),
frontsector->planes[sector_t::floor].xform,
frontsector->sky,
portal
) : NULL;
@ -1221,11 +1203,7 @@ void R_Subsector (subsector_t *sub)
floorlightlevel + r_actualextralight, // killough 3/16/98
frontsector->GetAlpha(sector_t::floor),
!!(fakeFloor->flags & FF_ADDITIVETRANS),
frontsector->GetXOffset(position), // killough 3/7/98
frontsector->GetYOffset(position), // killough 3/7/98
frontsector->GetXScale(position),
frontsector->GetYScale(position),
frontsector->GetAngle(position),
frontsector->planes[position].xform,
frontsector->sky,
NULL);
@ -1286,11 +1264,7 @@ void R_Subsector (subsector_t *sub)
ceilinglightlevel + r_actualextralight, // killough 4/11/98
frontsector->GetAlpha(sector_t::ceiling),
!!(fakeFloor->flags & FF_ADDITIVETRANS),
frontsector->GetXOffset(position), // killough 3/7/98
frontsector->GetYOffset(position), // killough 3/7/98
frontsector->GetXScale(position),
frontsector->GetYScale(position),
frontsector->GetAngle(position),
frontsector->planes[position].xform,
frontsector->sky,
NULL);

View file

@ -314,11 +314,6 @@ public:
}
// Returns < 0 : behind; == 0 : on; > 0 : in front
int PointOnSide (fixed_t x, fixed_t y, fixed_t z) const
{
return PointOnSide(DVector3(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)));
}
int PointOnSide(const DVector3 &pos) const
{
double v = (normal | pos) + D;
@ -334,23 +329,6 @@ public:
// Returns the value of z at (x,y)
fixed_t ZatPoint(fixed_t x, fixed_t y) const = delete; // it is not allowed to call this.
fixed_t ZatPointFixed(fixed_t x, fixed_t y) const
{
return FLOAT2FIXED(ZatPoint(FIXED2DBL(x), FIXED2DBL(y)));
}
// This is for the software renderer
fixed_t ZatPointFixed(const DVector2 &pos) const
{
return FLOAT2FIXED(ZatPoint(pos));
}
fixed_t ZatPointFixed(const vertex_t *v) const
{
return FLOAT2FIXED(ZatPoint(v));
}
// Returns the value of z at (x,y) as a double
double ZatPoint (double x, double y) const
{
@ -572,16 +550,24 @@ struct extsector_t
struct FTransform
{
// killough 3/7/98: floor and ceiling texture offsets
fixed_t xoffs, yoffs;
double xOffs, yOffs, baseyOffs;
// [RH] floor and ceiling texture scales
fixed_t xscale, yscale;
double xScale, yScale;
// [RH] floor and ceiling texture rotation
angle_t angle;
DAngle Angle, baseAngle;
finline bool operator == (const FTransform &other) const
{
return xOffs == other.xOffs && yOffs + baseyOffs == other.yOffs + other.baseyOffs &&
xScale == other.xScale && yScale == other.yScale && Angle + baseAngle == other.Angle + other.baseAngle;
}
finline bool operator != (const FTransform &other) const
{
return !(*this == other);
}
// base values
fixed_t base_angle, base_yoffs;
};
struct secspecial_t
@ -681,121 +667,82 @@ public:
void SetXOffset(int pos, double o)
{
planes[pos].xform.xoffs = FLOAT2FIXED(o);
planes[pos].xform.xOffs = o;
}
void AddXOffset(int pos, double o)
{
planes[pos].xform.xoffs += FLOAT2FIXED(o);
}
fixed_t GetXOffset(int pos) const
{
return planes[pos].xform.xoffs;
planes[pos].xform.xOffs += o;
}
double GetXOffsetF(int pos) const
{
return FIXED2DBL(planes[pos].xform.xoffs);
return planes[pos].xform.xOffs;
}
void SetYOffset(int pos, double o)
{
planes[pos].xform.yoffs = FLOAT2FIXED(o);
planes[pos].xform.yOffs = o;
}
void AddYOffset(int pos, double o)
{
planes[pos].xform.yoffs += FLOAT2FIXED(o);
}
fixed_t GetYOffset(int pos, bool addbase = true) const
{
if (!addbase)
{
return planes[pos].xform.yoffs;
}
else
{
return planes[pos].xform.yoffs + planes[pos].xform.base_yoffs;
}
planes[pos].xform.yOffs += o;
}
double GetYOffsetF(int pos, bool addbase = true) const
{
if (!addbase)
{
return FIXED2DBL(planes[pos].xform.yoffs);
return planes[pos].xform.yOffs;
}
else
{
return FIXED2DBL(planes[pos].xform.yoffs + planes[pos].xform.base_yoffs);
return planes[pos].xform.yOffs + planes[pos].xform.baseyOffs;
}
}
void SetXScale(int pos, double o)
{
planes[pos].xform.xscale = FLOAT2FIXED(o);
}
fixed_t GetXScale(int pos) const
{
return planes[pos].xform.xscale;
planes[pos].xform.xScale = o;
}
double GetXScaleF(int pos) const
{
return FIXED2DBL(planes[pos].xform.xscale);
return planes[pos].xform.xScale;
}
void SetYScale(int pos, double o)
{
planes[pos].xform.yscale = FLOAT2FIXED(o);
}
fixed_t GetYScale(int pos) const
{
return planes[pos].xform.yscale;
planes[pos].xform.yScale = o;
}
double GetYScaleF(int pos) const
{
return FIXED2DBL(planes[pos].xform.yscale);
return planes[pos].xform.yScale;
}
void SetAngle(int pos, DAngle o)
{
planes[pos].xform.angle = o.BAMs();
}
angle_t GetAngle(int pos, bool addbase = true) const
{
if (!addbase)
{
return planes[pos].xform.angle;
}
else
{
return planes[pos].xform.angle + planes[pos].xform.base_angle;
}
planes[pos].xform.Angle = o;
}
DAngle GetAngleF(int pos, bool addbase = true) const
{
if (!addbase)
{
return ANGLE2DBL(planes[pos].xform.angle);
return planes[pos].xform.Angle;
}
else
{
return ANGLE2DBL(planes[pos].xform.angle + planes[pos].xform.base_angle);
return planes[pos].xform.Angle + planes[pos].xform.baseAngle;
}
}
void SetBase(int pos, double y, DAngle o)
{
planes[pos].xform.base_yoffs = FLOAT2FIXED(y);
planes[pos].xform.base_angle = o.BAMs();
planes[pos].xform.baseyOffs = y;
planes[pos].xform.baseAngle = o;
}
void SetAlpha(int pos, double o)
@ -818,6 +765,12 @@ public:
return planes[pos].Flags;
}
// like the previous one but masks out all flags which are not relevant for rendering.
int GetVisFlags(int pos) const
{
return planes[pos].Flags & ~(PLANEF_BLOCKED | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_LINKED);
}
void ChangeFlags(int pos, int And, int Or)
{
planes[pos].Flags &= ~And;

View file

@ -582,14 +582,18 @@ static visplane_t *new_visplane (unsigned hash)
//==========================================================================
visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightlevel, fixed_t alpha, bool additive,
fixed_t xoffs, fixed_t yoffs,
fixed_t xscale, fixed_t yscale, angle_t angle,
const FTransform &xform,
int sky, FSectorPortal *portal)
{
secplane_t plane;
visplane_t *check;
unsigned hash; // killough
bool isskybox;
fixed_t xoffs = FLOAT2FIXED(xform.xOffs);
fixed_t yoffs = FLOAT2FIXED(xform.yOffs + xform.baseyOffs);
fixed_t xscale = FLOAT2FIXED(xform.xScale);
fixed_t yscale = FLOAT2FIXED(xform.yScale);
angle_t angle = (xform.Angle + xform.baseAngle).BAMs();
if (picnum == skyflatnum) // killough 10/98
{ // most skies map together
@ -651,6 +655,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
(plane == check->height &&
picnum == check->picnum &&
lightlevel == check->lightlevel &&
xoffs == check->xoffs && // killough 2/28/98: Add offset checks
yoffs == check->yoffs &&
basecolormap == check->colormap && // [RH] Add more checks

View file

@ -100,11 +100,7 @@ visplane_t *R_FindPlane
int lightlevel,
fixed_t alpha,
bool additive,
fixed_t xoffs, // killough 2/28/98: add x-y offsets
fixed_t yoffs,
fixed_t xscale,
fixed_t yscale,
angle_t angle,
const FTransform &xform,
int sky,
FSectorPortal *portal);

View file

@ -2110,26 +2110,21 @@ void R_NewWall (bool needlights)
|| backsector->floorplane != frontsector->floorplane
|| backsector->lightlevel != frontsector->lightlevel
|| backsector->GetTexture(sector_t::floor) != frontsector->GetTexture(sector_t::floor)
|| backsector->GetPlaneLight(sector_t::floor) != frontsector->GetPlaneLight(sector_t::floor)
// killough 3/7/98: Add checks for (x,y) offsets
|| backsector->GetXOffset(sector_t::floor) != frontsector->GetXOffset(sector_t::floor)
|| backsector->GetYOffset(sector_t::floor) != frontsector->GetYOffset(sector_t::floor)
|| backsector->planes[sector_t::floor].xform != frontsector->planes[sector_t::floor].xform
|| backsector->GetAlpha(sector_t::floor) != frontsector->GetAlpha(sector_t::floor)
// killough 4/15/98: prevent 2s normals
// from bleeding through deep water
|| frontsector->heightsec
|| backsector->GetPlaneLight(sector_t::floor) != frontsector->GetPlaneLight(sector_t::floor)
|| backsector->GetFlags(sector_t::floor) != frontsector->GetFlags(sector_t::floor)
|| backsector->GetVisFlags(sector_t::floor) != frontsector->GetVisFlags(sector_t::floor)
// [RH] Add checks for colormaps
|| backsector->ColorMap != frontsector->ColorMap
|| backsector->GetXScale(sector_t::floor) != frontsector->GetXScale(sector_t::floor)
|| backsector->GetYScale(sector_t::floor) != frontsector->GetYScale(sector_t::floor)
|| backsector->GetAngle(sector_t::floor) != frontsector->GetAngle(sector_t::floor)
// kg3D - add fake lights
|| (frontsector->e && frontsector->e->XFloor.lightlist.Size())
@ -2148,8 +2143,7 @@ void R_NewWall (bool needlights)
|| backsector->GetTexture(sector_t::ceiling) != frontsector->GetTexture(sector_t::ceiling)
// killough 3/7/98: Add checks for (x,y) offsets
|| backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling)
|| backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling)
|| backsector->planes[sector_t::ceiling].xform != frontsector->planes[sector_t::ceiling].xform
|| backsector->GetAlpha(sector_t::ceiling) != frontsector->GetAlpha(sector_t::ceiling)
// killough 4/15/98: prevent 2s normals
@ -2162,11 +2156,6 @@ void R_NewWall (bool needlights)
// [RH] Add check for colormaps
|| backsector->ColorMap != frontsector->ColorMap
|| backsector->GetXScale(sector_t::ceiling) != frontsector->GetXScale(sector_t::ceiling)
|| backsector->GetYScale(sector_t::ceiling) != frontsector->GetYScale(sector_t::ceiling)
|| backsector->GetAngle(sector_t::ceiling) != frontsector->GetAngle(sector_t::ceiling)
// kg3D - add fake lights
|| (frontsector->e && frontsector->e->XFloor.lightlist.Size())
|| (backsector->e && backsector->e->XFloor.lightlist.Size())