- floatified more of gl_wall.cpp.

This commit is contained in:
Christoph Oelckers 2016-04-07 23:19:37 +02:00
parent ddbb8d79c1
commit 4ac3734375
3 changed files with 173 additions and 166 deletions

View file

@ -202,23 +202,23 @@ private:
void DoMidTexture(seg_t * seg, bool drawfogboundary,
sector_t * front, sector_t * back,
sector_t * realfront, sector_t * realback,
fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2,
fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2);
float fch1, float fch2, float ffh1, float ffh2,
float bch1, float bch2, float bfh1, float bfh2);
void GetPlanePos(F3DFloor::planeref *planeref, fixed_t &left, fixed_t &right);
void GetPlanePos(F3DFloor::planeref * planeref, float & left, float & right);
void BuildFFBlock(seg_t * seg, F3DFloor * rover,
fixed_t ff_topleft, fixed_t ff_topright,
fixed_t ff_bottomleft, fixed_t ff_bottomright);
float ff_topleft, float ff_topright,
float ff_bottomleft, float ff_bottomright);
void InverseFloors(seg_t * seg, sector_t * frontsector,
fixed_t topleft, fixed_t topright,
fixed_t bottomleft, fixed_t bottomright);
float topleft, float topright,
float bottomleft, float bottomright);
void ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector,
fixed_t topleft, fixed_t topright,
fixed_t bottomleft, fixed_t bottomright);
float topleft, float topright,
float bottomleft, float bottomright);
void DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector,
fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2,
fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2);
float fch1, float fch2, float ffh1, float ffh2,
float bch1, float bch2, float bfh1, float bfh2);
void DrawDecal(DBaseDecal *actor);
void DoDrawDecals();

View file

@ -658,14 +658,14 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg,
void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
sector_t * front, sector_t * back,
sector_t * realfront, sector_t * realback,
fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2,
fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2)
float fch1, float fch2, float ffh1, float ffh2,
float bch1, float bch2, float bfh1, float bfh2)
{
FTexCoordInfo tci;
fixed_t topleft,bottomleft,topright,bottomright;
float topleft,bottomleft,topright,bottomright;
GLSeg glsave=glseg;
fixed_t texturetop, texturebottom;
float texturetop, texturebottom;
bool wrap = (seg->linedef->flags&ML_WRAP_MIDTEX) || (seg->sidedef->Flags&WALLF_WRAP_MIDTEX);
bool mirrory = false;
@ -686,16 +686,16 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
tci.mRenderHeight = -tci.mRenderHeight;
tci.mScaleY = -tci.mScaleY;
}
fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid));
float rowoffset = FIXED2FLOAT(tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)));
if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0)
{
texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor), realback->GetPlaneTexZ(sector_t::floor)) + rowoffset;
texturetop = texturebottom + (tci.mRenderHeight << FRACBITS);
texturebottom = MAX(realfront->GetPlaneTexZF(sector_t::floor), realback->GetPlaneTexZF(sector_t::floor)) + rowoffset;
texturetop = texturebottom + tci.mRenderHeight;
}
else
{
texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling)) + rowoffset;
texturebottom = texturetop - (tci.mRenderHeight << FRACBITS);
texturetop = MIN(realfront->GetPlaneTexZF(sector_t::ceiling), realback->GetPlaneTexZF(sector_t::ceiling)) + rowoffset;
texturebottom = texturetop - tci.mRenderHeight;
}
}
else texturetop=texturebottom=0;
@ -804,22 +804,30 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
// set up texture coordinate stuff
//
//
fixed_t t_ofs = seg->sidedef->GetTextureXOffset(side_t::mid);
float t_ofs = seg->sidedef->GetTextureXOffsetF(side_t::mid);
if (gltexture)
{
// First adjust the texture offset so that the left edge of the linedef is inside the range [0..1].
fixed_t texwidth = tci.TextureAdjustWidth()<<FRACBITS;
float texwidth = tci.TextureAdjustWidth();
t_ofs%=texwidth;
if (t_ofs<-texwidth) t_ofs+=texwidth; // shift negative results of % into positive range
if (t_ofs >= 0)
{
float div = t_ofs / texwidth;
t_ofs = (div - xs_FloorToInt(div)) * texwidth;
}
else
{
float div = (-t_ofs) / texwidth;
t_ofs = texwidth - (div - xs_FloorToInt(div)) * texwidth;
}
// Now check whether the linedef is completely within the texture range of [0..1].
// If so we should use horizontal texture clamping to prevent filtering artifacts
// at the edges.
fixed_t textureoffset = tci.TextureOffset(t_ofs);
fixed_t textureoffset = tci.TextureOffset(FLOAT2FIXED(t_ofs));
int righttex=(textureoffset>>FRACBITS)+seg->sidedef->TexelLength;
if ((textureoffset == 0 && righttex <= tci.mRenderWidth) ||
@ -841,7 +849,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
tci.mRenderHeight = -tci.mRenderHeight;
tci.mScaleY = -tci.mScaleY;
}
SetWallCoordinates(seg, &tci, FIXED2FLOAT(texturetop), FIXED2FLOAT(topleft), FIXED2FLOAT(topright), FIXED2FLOAT(bottomleft), FIXED2FLOAT(bottomright), t_ofs);
SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, FLOAT2FIXED(t_ofs));
//
//
@ -976,8 +984,8 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
//
//==========================================================================
void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
fixed_t ff_topleft, fixed_t ff_topright,
fixed_t ff_bottomleft, fixed_t ff_bottomright)
float ff_topleft, float ff_topright,
float ff_bottomleft, float ff_bottomright)
{
side_t * mastersd = rover->master->sidedef[0];
float to;
@ -1042,18 +1050,18 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
to += FIXED2FLOAT(rowoffset) + rover->top.model->GetPlaneTexZF(rover->top.isceiling);
uplft.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_topleft));
uprgt.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_topright));
lolft.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_bottomleft));
lorgt.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_bottomright));
uplft.v = tci.FloatToTexV(to - ff_topleft);
uprgt.v = tci.FloatToTexV(to - ff_topright);
lolft.v = tci.FloatToTexV(to - ff_bottomleft);
lorgt.v = tci.FloatToTexV(to - ff_bottomright);
type = RENDERWALL_FFBLOCK;
CheckTexturePosition();
}
ztop[0]=FIXED2FLOAT(ff_topleft);
ztop[1]=FIXED2FLOAT(ff_topright);
zbottom[0]=FIXED2FLOAT(ff_bottomleft);//-0.001f;
zbottom[1]=FIXED2FLOAT(ff_bottomright);
ztop[0] = ff_topleft;
ztop[1] = ff_topright;
zbottom[0] = ff_bottomleft;//-0.001f;
zbottom[1] = ff_bottomright;
if (rover->flags&(FF_TRANSLUCENT | FF_ADDITIVETRANS | FF_FOG))
{
@ -1087,10 +1095,10 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
//
//==========================================================================
__forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &left, fixed_t &right)
__forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, float &left, float &right)
{
left=planeref->plane->ZatPointFixed(vertexes[0]);
right=planeref->plane->ZatPointFixed(vertexes[1]);
left=planeref->plane->ZatPoint(vertexes[0]);
right=planeref->plane->ZatPoint(vertexes[1]);
}
//==========================================================================
@ -1099,8 +1107,8 @@ __forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &le
//
//==========================================================================
void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector,
fixed_t topleft, fixed_t topright,
fixed_t bottomleft, fixed_t bottomright)
float topleft, float topright,
float bottomleft, float bottomright)
{
TArray<F3DFloor *> & frontffloors = frontsector->e->XFloor.ffloors;
@ -1111,10 +1119,10 @@ void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector,
if (!(rover->flags&FF_RENDERSIDES)) continue;
if (!(rover->flags&(FF_INVERTSIDES | FF_ALLSIDES))) continue;
fixed_t ff_topleft;
fixed_t ff_topright;
fixed_t ff_bottomleft;
fixed_t ff_bottomright;
float ff_topleft;
float ff_topright;
float ff_bottomleft;
float ff_bottomright;
GetPlanePos(&rover->top, ff_topleft, ff_topright);
GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright);
@ -1141,7 +1149,6 @@ void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector,
if (topleft <= bottomleft && topright <= bottomright) return;
}
}
//==========================================================================
@ -1150,8 +1157,8 @@ void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector,
//
//==========================================================================
void GLWall::ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector,
fixed_t topleft, fixed_t topright,
fixed_t bottomleft, fixed_t bottomright)
float topleft, float topright,
float bottomleft, float bottomright)
{
TArray<F3DFloor *> & frontffloors = frontsector->e->XFloor.ffloors;
@ -1164,10 +1171,10 @@ void GLWall::ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector,
if (!(rover->flags&FF_RENDERSIDES)) continue;
if ((rover->flags&(FF_SWIMMABLE | FF_TRANSLUCENT)) != flags) continue;
fixed_t ff_topleft;
fixed_t ff_topright;
fixed_t ff_bottomleft;
fixed_t ff_bottomright;
float ff_topleft;
float ff_topright;
float ff_bottomleft;
float ff_bottomright;
GetPlanePos(&rover->top, ff_topleft, ff_topright);
@ -1223,12 +1230,12 @@ done:
//
//==========================================================================
void GLWall::DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector,
fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2,
fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2)
float fch1, float fch2, float ffh1, float ffh2,
float bch1, float bch2, float bfh1, float bfh2)
{
TArray<F3DFloor *> & backffloors = backsector->e->XFloor.ffloors;
fixed_t topleft, topright, bottomleft, bottomright;
float topleft, topright, bottomleft, bottomright;
bool renderedsomething = false;
// if the ceilings intersect use the backsector's height because this sector's ceiling will
@ -1262,10 +1269,10 @@ void GLWall::DoFFloorBlocks(seg_t * seg,sector_t * frontsector,sector_t * backse
if (!(rover->flags&FF_EXISTS)) continue;
if (!(rover->flags&FF_RENDERSIDES) || (rover->flags&FF_INVERTSIDES)) continue;
fixed_t ff_topleft;
fixed_t ff_topright;
fixed_t ff_bottomleft;
fixed_t ff_bottomright;
float ff_topleft;
float ff_topright;
float ff_bottomleft;
float ff_bottomright;
GetPlanePos(&rover->top, ff_topleft, ff_topright);
GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright);
@ -1540,7 +1547,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
if (gltexture || drawfogboundary)
{
DoMidTexture(seg, drawfogboundary, frontsector, backsector, realfront, realback,
FLOAT2FIXED(fch1), FLOAT2FIXED(fch2), FLOAT2FIXED(ffh1), FLOAT2FIXED(ffh2), FLOAT2FIXED(bch1), FLOAT2FIXED(bch2), FLOAT2FIXED(bfh1), FLOAT2FIXED(bfh2));
fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2);
}
if (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0])
@ -1554,7 +1561,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
}
else if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size())
{
DoFFloorBlocks(seg, frontsector, backsector, FLOAT2FIXED(fch1), FLOAT2FIXED(fch2), FLOAT2FIXED(ffh1), FLOAT2FIXED(ffh2), FLOAT2FIXED(bch1), FLOAT2FIXED(bch2), FLOAT2FIXED(bfh1), FLOAT2FIXED(bfh2));
DoFFloorBlocks(seg, frontsector, backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2);
}
/* bottom texture */
@ -1617,8 +1624,8 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
if (frontsector->GetTexture(sector_t::floor) == skyflatnum) return;
lightlist = NULL;
fixed_t ffh = frontsector->GetPlaneTexZ(sector_t::floor);
fixed_t bfh = backsector->GetPlaneTexZ(sector_t::floor);
float ffh = frontsector->GetPlaneTexZF(sector_t::floor);
float bfh = backsector->GetPlaneTexZF(sector_t::floor);
if (bfh > ffh)
{
this->seg = seg;
@ -1652,7 +1659,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
bottomplane = frontsector->floorplane;
dynlightindex = UINT_MAX;
zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh);
zfloor[0] = zfloor[1] = ffh;
gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true);
@ -1661,7 +1668,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
FTexCoordInfo tci;
type = RENDERWALL_BOTTOM;
gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT);
SetWallCoordinates(seg, &tci, FIXED2FLOAT(bfh), FIXED2FLOAT(bfh), FIXED2FLOAT(bfh), FIXED2FLOAT(ffh), FIXED2FLOAT(ffh), 0);
SetWallCoordinates(seg, &tci, bfh, bfh, bfh, ffh, ffh, 0);
PutWall(false);
}
}

View file

@ -735,12 +735,12 @@ void DumpSection(int no, FGLSection *sect)
{
vertex_t *v1 = V1(ln->sidedef);
vertex_t *v2 = V2(ln->sidedef);
double dx = FIXED2FLOAT(v2->x-v1->x);
double dy = FIXED2FLOAT(v2->y-v1->y);
double dx1 = FIXED2FLOAT(ln->start->x-v1->x);
double dy1 = FIXED2FLOAT(ln->start->y-v1->y);
double dx2 = FIXED2FLOAT(ln->end->x-v1->x);
double dy2 = FIXED2FLOAT(ln->end->y-v1->y);
double dx = FIXED2DBL(v2->x-v1->x);
double dy = FIXED2DBL(v2->y-v1->y);
double dx1 = FIXED2DBL(ln->start->x-v1->x);
double dy1 = FIXED2DBL(ln->start->y-v1->y);
double dx2 = FIXED2DBL(ln->end->x-v1->x);
double dy2 = FIXED2DBL(ln->end->y-v1->y);
double d = sqrt(dx*dx+dy*dy);
double d1 = sqrt(dx1*dx1+dy1*dy1);
double d2 = sqrt(dx2*dx2+dy2*dy2);