- floatified the remaining parts of gl_walls.cpp.

This commit is contained in:
Christoph Oelckers 2016-04-08 00:19:51 +02:00
parent 4ac3734375
commit eaf055dff4
6 changed files with 50 additions and 50 deletions

View File

@ -191,13 +191,13 @@ private:
bool DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2);
bool SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float ceilingrefheight,
float topleft, float topright, float bottomleft, float bottomright, fixed_t t_ofs);
float topleft, float topright, float bottomleft, float bottomright, float t_ofs);
void DoTexture(int type,seg_t * seg,int peg,
fixed_t ceilingrefheight,fixed_t floorrefheight,
float ceilingrefheight, float floorrefheight,
float CeilingHeightstart,float CeilingHeightend,
float FloorHeightstart,float FloorHeightend,
fixed_t v_offset);
float v_offset);
void DoMidTexture(seg_t * seg, bool drawfogboundary,
sector_t * front, sector_t * back,

View File

@ -428,7 +428,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2)
//
//==========================================================================
bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float texturetop,
float topleft, float topright, float bottomleft, float bottomright, fixed_t t_ofs)
float topleft, float topright, float bottomleft, float bottomright, float t_ofs)
{
//
//
@ -442,7 +442,7 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto
{
float length = seg->sidedef ? seg->sidedef->TexelLength : Dist2(glseg.x1, glseg.y1, glseg.x2, glseg.y2);
l_ul = tci->FloatToTexU(FIXED2FLOAT(tci->TextureOffset(t_ofs)));
l_ul = tci->FloatToTexU(tci->TextureOffset(t_ofs));
texlength = tci->FloatToTexU(length);
}
else
@ -593,16 +593,16 @@ void GLWall::CheckTexturePosition()
//
//==========================================================================
void GLWall::DoTexture(int _type,seg_t * seg, int peg,
fixed_t ceilingrefheight,fixed_t floorrefheight,
float ceilingrefheight,float floorrefheight,
float topleft,float topright,
float bottomleft,float bottomright,
fixed_t v_offset)
float v_offset)
{
if (topleft<=bottomleft && topright<=bottomright) return;
// The Vertex values can be destroyed in this function and must be restored aferward!
GLSeg glsave=glseg;
int lh=ceilingrefheight-floorrefheight;
float flh=ceilingrefheight-floorrefheight;
int texpos;
switch (_type)
@ -624,11 +624,11 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg,
type = _type;
float floatceilingref = FIXED2FLOAT(ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos)));
if (peg) floatceilingref += tci.mRenderHeight - FIXED2FLOAT(lh + v_offset);
float floatceilingref = ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffsetF(texpos));
if (peg) floatceilingref += tci.mRenderHeight - flh - v_offset;
if (!SetWallCoordinates(seg, &tci, floatceilingref, topleft, topright, bottomleft, bottomright,
seg->sidedef->GetTextureXOffset(texpos))) return;
seg->sidedef->GetTextureXOffsetF(texpos))) return;
if (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors)
{
@ -686,7 +686,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
tci.mRenderHeight = -tci.mRenderHeight;
tci.mScaleY = -tci.mScaleY;
}
float rowoffset = FIXED2FLOAT(tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)));
float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid));
if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0)
{
texturebottom = MAX(realfront->GetPlaneTexZF(sector_t::floor), realback->GetPlaneTexZF(sector_t::floor)) + rowoffset;
@ -827,8 +827,8 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
// If so we should use horizontal texture clamping to prevent filtering artifacts
// at the edges.
fixed_t textureoffset = tci.TextureOffset(FLOAT2FIXED(t_ofs));
int righttex=(textureoffset>>FRACBITS)+seg->sidedef->TexelLength;
float textureoffset = tci.TextureOffset(t_ofs);
int righttex = int(textureoffset) + seg->sidedef->TexelLength;
if ((textureoffset == 0 && righttex <= tci.mRenderWidth) ||
(textureoffset >= 0 && righttex == tci.mRenderWidth))
@ -849,7 +849,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
tci.mRenderHeight = -tci.mRenderHeight;
tci.mScaleY = -tci.mScaleY;
}
SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, FLOAT2FIXED(t_ofs));
SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, t_ofs);
//
//
@ -1034,21 +1034,20 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid));
}
to = FIXED2FLOAT((rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ?
0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid)));
to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffsetF(side_t::mid));
ul = tci.FloatToTexU(to + FIXED2FLOAT(tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid))));
ul = tci.FloatToTexU(to + tci.TextureOffset(seg->sidedef->GetTextureXOffsetF(side_t::mid)));
texlength = tci.FloatToTexU(seg->sidedef->TexelLength);
uplft.u = lolft.u = ul + texlength * glseg.fracleft;
uprgt.u = lorgt.u = ul + texlength * glseg.fracright;
fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid));
float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid));
to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ?
0.f : FIXED2FLOAT(tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid)));
0.f : tci.RowOffset(mastersd->GetTextureYOffsetF(side_t::mid));
to += FIXED2FLOAT(rowoffset) + rover->top.model->GetPlaneTexZF(rover->top.isceiling);
to += rowoffset + rover->top.model->GetPlaneTexZF(rover->top.isceiling);
uplft.v = tci.FloatToTexV(to - ff_topleft);
uprgt.v = tci.FloatToTexV(to - ff_topright);
@ -1324,6 +1323,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
float ffh1;
float fch2;
float ffh2;
float frefz, crefz;
sector_t * realfront;
sector_t * realback;
sector_t * segfront;
@ -1354,6 +1354,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
segfront = frontsector;
segback = backsector;
}
frefz = realfront->GetPlaneTexZF(sector_t::floor);
crefz = realfront->GetPlaneTexZF(sector_t::ceiling);
if (seg->sidedef == seg->linedef->sidedef[0])
{
@ -1466,7 +1468,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
if (gltexture)
{
DoTexture(RENDERWALL_M1S, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0,
realfront->GetPlaneTexZ(sector_t::ceiling), realfront->GetPlaneTexZ(sector_t::floor), // must come from the original!
crefz, frefz, // must come from the original!
fch1, fch2, ffh1, ffh2, 0);
}
}
@ -1501,7 +1503,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
if (gltexture)
{
DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0,
realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling),
frefz, crefz,
fch1, fch2, bch1a, bch2a, 0);
}
else if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
@ -1514,7 +1516,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
if (gltexture)
{
DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0,
realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling),
frefz, crefz,
fch1, fch2, bch1a, bch2a, 0);
}
}
@ -1523,7 +1525,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
// skip processing if the back is a malformed subsector
if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4))
{
gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a);
gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, FLOAT2FIXED(bch1a));
}
}
}
@ -1578,11 +1580,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
if (gltexture)
{
DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0,
realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor),
frefz, crefz,
bfh1, bfh2, ffh1, ffh2,
frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum ?
realfront->GetPlaneTexZ(sector_t::floor) - realback->GetPlaneTexZ(sector_t::ceiling) :
realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling));
frefz - realback->GetPlaneTexZF(sector_t::ceiling) :
frefz - crefz);
}
else if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
{
@ -1597,8 +1599,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
if (gltexture)
{
DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0,
realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor),
bfh1, bfh2, ffh1, ffh2, realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling));
realback->GetPlaneTexZF(sector_t::floor), frefz,
bfh1, bfh2, ffh1, ffh2, frefz - crefz);
}
}
else if (backsector->GetTexture(sector_t::floor) != skyflatnum)
@ -1606,7 +1608,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
// skip processing if the back is a malformed subsector
if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4))
{
gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1);
gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, FLOAT2FIXED(bfh1));
}
}
}

View File

@ -327,17 +327,17 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
//
//===========================================================================
fixed_t FTexCoordInfo::RowOffset(fixed_t rowoffset) const
float FTexCoordInfo::RowOffset(float rowoffset) const
{
if (mTempScaleY == FRACUNIT)
{
if (mScaleY==FRACUNIT || mWorldPanning) return rowoffset;
else return FixedDiv(rowoffset, mScaleY);
else return rowoffset * FIXED2FLOAT(mScaleY);
}
else
{
if (mWorldPanning) return FixedDiv(rowoffset, mTempScaleY);
else return FixedDiv(rowoffset, mScaleY);
if (mWorldPanning) return rowoffset * FIXED2FLOAT(mTempScaleY);
else return rowoffset * FIXED2FLOAT(mScaleY);
}
}
@ -347,17 +347,17 @@ fixed_t FTexCoordInfo::RowOffset(fixed_t rowoffset) const
//
//===========================================================================
fixed_t FTexCoordInfo::TextureOffset(fixed_t textureoffset) const
float FTexCoordInfo::TextureOffset(float textureoffset) const
{
if (mTempScaleX == FRACUNIT)
{
if (mScaleX==FRACUNIT || mWorldPanning) return textureoffset;
else return FixedDiv(textureoffset, mScaleX);
else return textureoffset * FIXED2FLOAT(mScaleX);
}
else
{
if (mWorldPanning) return FixedDiv(textureoffset, mTempScaleX);
else return FixedDiv(textureoffset, mScaleX);
if (mWorldPanning) return textureoffset * FIXED2FLOAT(mTempScaleX);
else return textureoffset * FIXED2FLOAT(mScaleX);
}
}

View File

@ -39,8 +39,8 @@ struct FTexCoordInfo
float FloatToTexU(float v) const { return v / mRenderWidth; }
float FloatToTexV(float v) const { return v / mRenderHeight; }
fixed_t RowOffset(fixed_t ofs) const;
fixed_t TextureOffset(fixed_t ofs) const;
float RowOffset(float ofs) const;
float TextureOffset(float ofs) const;
fixed_t TextureAdjustWidth() const;
};

View File

@ -177,7 +177,7 @@ void gl_GenerateGlobalBrightmapFromColormap()
// component becomes one.
//
//===========================================================================
PalEntry averageColor(const DWORD *data, int size, fixed_t maxout_factor)
PalEntry averageColor(const DWORD *data, int size, int maxout)
{
int i;
unsigned int r, g, b;
@ -203,12 +203,11 @@ PalEntry averageColor(const DWORD *data, int size, fixed_t maxout_factor)
int maxv=MAX(MAX(r,g),b);
if(maxv && maxout_factor)
if(maxv && maxout)
{
maxout_factor = FixedMul(maxout_factor, 255);
r = Scale(r, maxout_factor, maxv);
g = Scale(g, maxout_factor, maxv);
b = Scale(b, maxout_factor, maxv);
r = Scale(r, maxout, maxv);
g = Scale(g, maxout, maxv);
b = Scale(b, maxout, maxv);
}
return PalEntry(255,r,g,b);
}
@ -366,7 +365,7 @@ void FTexture::GetGlowColor(float *data)
if (buffer)
{
gl_info.GlowColor = averageColor((DWORD *) buffer, w*h, 6*FRACUNIT/10);
gl_info.GlowColor = averageColor((DWORD *) buffer, w*h, 153);
delete[] buffer;
}

View File

@ -58,14 +58,13 @@ protected:
void gl_GenerateGlobalBrightmapFromColormap();
PalEntry averageColor(const DWORD *data, int size, fixed_t maxout);
PalEntry averageColor(const DWORD *data, int size, int maxout);
unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha );
int CheckDDPK3(FTexture *tex);
int CheckExternalFile(FTexture *tex, bool & hascolorkey);
PalEntry averageColor(const DWORD *data, int size, fixed_t maxout);
#endif // __GL_HQRESIZE_H__