- 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, void DoMidTexture(seg_t * seg, bool drawfogboundary,
sector_t * front, sector_t * back, sector_t * front, sector_t * back,
sector_t * realfront, sector_t * realback, sector_t * realfront, sector_t * realback,
fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, float fch1, float fch2, float ffh1, float ffh2,
fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2); 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, void BuildFFBlock(seg_t * seg, F3DFloor * rover,
fixed_t ff_topleft, fixed_t ff_topright, float ff_topleft, float ff_topright,
fixed_t ff_bottomleft, fixed_t ff_bottomright); float ff_bottomleft, float ff_bottomright);
void InverseFloors(seg_t * seg, sector_t * frontsector, void InverseFloors(seg_t * seg, sector_t * frontsector,
fixed_t topleft, fixed_t topright, float topleft, float topright,
fixed_t bottomleft, fixed_t bottomright); float bottomleft, float bottomright);
void ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector, void ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector,
fixed_t topleft, fixed_t topright, float topleft, float topright,
fixed_t bottomleft, fixed_t bottomright); float bottomleft, float bottomright);
void DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector, void DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector,
fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, float fch1, float fch2, float ffh1, float ffh2,
fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2); float bch1, float bch2, float bfh1, float bfh2);
void DrawDecal(DBaseDecal *actor); void DrawDecal(DBaseDecal *actor);
void DoDrawDecals(); 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, void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
sector_t * front, sector_t * back, sector_t * front, sector_t * back,
sector_t * realfront, sector_t * realback, sector_t * realfront, sector_t * realback,
fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, float fch1, float fch2, float ffh1, float ffh2,
fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2) float bch1, float bch2, float bfh1, float bfh2)
{ {
FTexCoordInfo tci; FTexCoordInfo tci;
fixed_t topleft,bottomleft,topright,bottomright; float topleft,bottomleft,topright,bottomright;
GLSeg glsave=glseg; 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 wrap = (seg->linedef->flags&ML_WRAP_MIDTEX) || (seg->sidedef->Flags&WALLF_WRAP_MIDTEX);
bool mirrory = false; bool mirrory = false;
@ -686,16 +686,16 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
tci.mRenderHeight = -tci.mRenderHeight; tci.mRenderHeight = -tci.mRenderHeight;
tci.mScaleY = -tci.mScaleY; 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) if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0)
{ {
texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor), realback->GetPlaneTexZ(sector_t::floor)) + rowoffset; texturebottom = MAX(realfront->GetPlaneTexZF(sector_t::floor), realback->GetPlaneTexZF(sector_t::floor)) + rowoffset;
texturetop = texturebottom + (tci.mRenderHeight << FRACBITS); texturetop = texturebottom + tci.mRenderHeight;
} }
else else
{ {
texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling)) + rowoffset; texturetop = MIN(realfront->GetPlaneTexZF(sector_t::ceiling), realback->GetPlaneTexZF(sector_t::ceiling)) + rowoffset;
texturebottom = texturetop - (tci.mRenderHeight << FRACBITS); texturebottom = texturetop - tci.mRenderHeight;
} }
} }
else texturetop=texturebottom=0; else texturetop=texturebottom=0;
@ -804,22 +804,30 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
// set up texture coordinate stuff // 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) if (gltexture)
{ {
// First adjust the texture offset so that the left edge of the linedef is inside the range [0..1]. // 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 >= 0)
if (t_ofs<-texwidth) t_ofs+=texwidth; // shift negative results of % into positive range {
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]. // 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 // If so we should use horizontal texture clamping to prevent filtering artifacts
// at the edges. // 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; int righttex=(textureoffset>>FRACBITS)+seg->sidedef->TexelLength;
if ((textureoffset == 0 && righttex <= tci.mRenderWidth) || if ((textureoffset == 0 && righttex <= tci.mRenderWidth) ||
@ -841,7 +849,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
tci.mRenderHeight = -tci.mRenderHeight; tci.mRenderHeight = -tci.mRenderHeight;
tci.mScaleY = -tci.mScaleY; 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,15 +984,15 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
// //
//========================================================================== //==========================================================================
void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
fixed_t ff_topleft, fixed_t ff_topright, float ff_topleft, float ff_topright,
fixed_t ff_bottomleft, fixed_t ff_bottomright) float ff_bottomleft, float ff_bottomright)
{ {
side_t * mastersd = rover->master->sidedef[0]; side_t * mastersd = rover->master->sidedef[0];
float to; float to;
lightlist_t * light; lightlist_t * light;
bool translucent; bool translucent;
int savelight=lightlevel; int savelight = lightlevel;
FColormap savecolor=Colormap; FColormap savecolor = Colormap;
float ul; float ul;
float texlength; float texlength;
FTexCoordInfo tci; FTexCoordInfo tci;
@ -994,13 +1002,13 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
if (!gl_fixedcolormap) if (!gl_fixedcolormap)
{ {
// this may not yet be done // this may not yet be done
light=P_GetPlaneLight(rover->target, rover->top.plane,true); light = P_GetPlaneLight(rover->target, rover->top.plane, true);
Colormap.Clear(); Colormap.Clear();
Colormap.LightColor=(light->extra_colormap)->Fade; Colormap.LightColor = (light->extra_colormap)->Fade;
// the fog plane defines the light level, not the front sector // the fog plane defines the light level, not the front sector
lightlevel = gl_ClampLight(*light->p_lightlevel); lightlevel = gl_ClampLight(*light->p_lightlevel);
gltexture=NULL; gltexture = NULL;
type=RENDERWALL_FFBLOCK; type = RENDERWALL_FFBLOCK;
} }
else return; else return;
} }
@ -1026,10 +1034,10 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid)); gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid));
} }
to=FIXED2FLOAT((rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))? to = FIXED2FLOAT((rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ?
0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid))); 0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid)));
ul=tci.FloatToTexU(to + FIXED2FLOAT(tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid)))); ul = tci.FloatToTexU(to + FIXED2FLOAT(tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid))));
texlength = tci.FloatToTexU(seg->sidedef->TexelLength); texlength = tci.FloatToTexU(seg->sidedef->TexelLength);
@ -1037,47 +1045,47 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
uprgt.u = lorgt.u = ul + texlength * glseg.fracright; uprgt.u = lorgt.u = ul + texlength * glseg.fracright;
fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid));
to= (rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))? to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ?
0.f : FIXED2FLOAT(tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid))); 0.f : FIXED2FLOAT(tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid)));
to += FIXED2FLOAT(rowoffset) + rover->top.model->GetPlaneTexZF(rover->top.isceiling); to += FIXED2FLOAT(rowoffset) + rover->top.model->GetPlaneTexZF(rover->top.isceiling);
uplft.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_topleft)); uplft.v = tci.FloatToTexV(to - ff_topleft);
uprgt.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_topright)); uprgt.v = tci.FloatToTexV(to - ff_topright);
lolft.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_bottomleft)); lolft.v = tci.FloatToTexV(to - ff_bottomleft);
lorgt.v=tci.FloatToTexV(to + FIXED2FLOAT(-ff_bottomright)); lorgt.v = tci.FloatToTexV(to - ff_bottomright);
type=RENDERWALL_FFBLOCK; type = RENDERWALL_FFBLOCK;
CheckTexturePosition(); CheckTexturePosition();
} }
ztop[0]=FIXED2FLOAT(ff_topleft); ztop[0] = ff_topleft;
ztop[1]=FIXED2FLOAT(ff_topright); ztop[1] = ff_topright;
zbottom[0]=FIXED2FLOAT(ff_bottomleft);//-0.001f; zbottom[0] = ff_bottomleft;//-0.001f;
zbottom[1]=FIXED2FLOAT(ff_bottomright); zbottom[1] = ff_bottomright;
if (rover->flags&(FF_TRANSLUCENT|FF_ADDITIVETRANS|FF_FOG)) if (rover->flags&(FF_TRANSLUCENT | FF_ADDITIVETRANS | FF_FOG))
{ {
alpha=rover->alpha/255.0f; alpha = rover->alpha / 255.0f;
RenderStyle = (rover->flags&FF_ADDITIVETRANS)? STYLE_Add : STYLE_Translucent; RenderStyle = (rover->flags&FF_ADDITIVETRANS) ? STYLE_Add : STYLE_Translucent;
translucent=true; translucent = true;
type=gltexture? RENDERWALL_M2S:RENDERWALL_COLOR; type = gltexture ? RENDERWALL_M2S : RENDERWALL_COLOR;
} }
else else
{ {
alpha=1.0f; alpha = 1.0f;
RenderStyle=STYLE_Normal; RenderStyle = STYLE_Normal;
translucent=false; translucent = false;
} }
sector_t * sec = sub? sub->sector : seg->frontsector; sector_t * sec = sub ? sub->sector : seg->frontsector;
if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); if (sec->e->XFloor.lightlist.Size() == 0 || gl_fixedcolormap) PutWall(translucent);
else SplitWall(sec, translucent); else SplitWall(sec, translucent);
alpha=1.0f; alpha = 1.0f;
lightlevel = savelight; lightlevel = savelight;
Colormap = savecolor; Colormap = savecolor;
flags&=~GLT_CLAMPY; flags &= ~GLT_CLAMPY;
} }
@ -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]); left=planeref->plane->ZatPoint(vertexes[0]);
right=planeref->plane->ZatPointFixed(vertexes[1]); right=planeref->plane->ZatPoint(vertexes[1]);
} }
//========================================================================== //==========================================================================
@ -1099,49 +1107,48 @@ __forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &le
// //
//========================================================================== //==========================================================================
void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector, void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector,
fixed_t topleft, fixed_t topright, float topleft, float topright,
fixed_t bottomleft, fixed_t bottomright) float bottomleft, float bottomright)
{ {
TArray<F3DFloor *> & frontffloors=frontsector->e->XFloor.ffloors; TArray<F3DFloor *> & frontffloors = frontsector->e->XFloor.ffloors;
for(unsigned int i=0;i<frontffloors.Size();i++) for (unsigned int i = 0; i < frontffloors.Size(); i++)
{ {
F3DFloor * rover=frontffloors[i]; F3DFloor * rover = frontffloors[i];
if (!(rover->flags&FF_EXISTS)) continue; if (!(rover->flags&FF_EXISTS)) continue;
if (!(rover->flags&FF_RENDERSIDES)) continue; if (!(rover->flags&FF_RENDERSIDES)) continue;
if (!(rover->flags&(FF_INVERTSIDES|FF_ALLSIDES))) continue; if (!(rover->flags&(FF_INVERTSIDES | FF_ALLSIDES))) continue;
fixed_t ff_topleft; float ff_topleft;
fixed_t ff_topright; float ff_topright;
fixed_t ff_bottomleft; float ff_bottomleft;
fixed_t ff_bottomright; float ff_bottomright;
GetPlanePos(&rover->top, ff_topleft, ff_topright); GetPlanePos(&rover->top, ff_topleft, ff_topright);
GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright); GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright);
// above ceiling // above ceiling
if (ff_bottomleft>topleft && ff_bottomright>topright) continue; if (ff_bottomleft > topleft && ff_bottomright > topright) continue;
if (ff_topleft>topleft && ff_topright>topright) if (ff_topleft > topleft && ff_topright > topright)
{ {
// the new section overlaps with the previous one - clip it! // the new section overlaps with the previous one - clip it!
ff_topleft=topleft; ff_topleft = topleft;
ff_topright=topright; ff_topright = topright;
} }
if (ff_bottomleft<bottomleft && ff_bottomright<bottomright) if (ff_bottomleft < bottomleft && ff_bottomright < bottomright)
{ {
ff_bottomleft=bottomleft; ff_bottomleft = bottomleft;
ff_bottomright=bottomright; ff_bottomright = bottomright;
} }
if (ff_topleft<ff_bottomleft || ff_topright<ff_bottomright) continue; if (ff_topleft < ff_bottomleft || ff_topright < ff_bottomright) continue;
BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
topleft=ff_bottomleft; topleft = ff_bottomleft;
topright=ff_bottomright; topright = ff_bottomright;
if (topleft<=bottomleft && topright<=bottomright) return; if (topleft <= bottomleft && topright <= bottomright) return;
} }
} }
//========================================================================== //==========================================================================
@ -1150,45 +1157,45 @@ void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector,
// //
//========================================================================== //==========================================================================
void GLWall::ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector, void GLWall::ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector,
fixed_t topleft, fixed_t topright, float topleft, float topright,
fixed_t bottomleft, fixed_t bottomright) float bottomleft, float bottomright)
{ {
TArray<F3DFloor *> & frontffloors=frontsector->e->XFloor.ffloors; TArray<F3DFloor *> & frontffloors = frontsector->e->XFloor.ffloors;
int flags = ffloor->flags & (FF_SWIMMABLE|FF_TRANSLUCENT); int flags = ffloor->flags & (FF_SWIMMABLE | FF_TRANSLUCENT);
for(unsigned int i=0;i<frontffloors.Size();i++) for (unsigned int i = 0; i < frontffloors.Size(); i++)
{ {
F3DFloor * rover=frontffloors[i]; F3DFloor * rover = frontffloors[i];
if (!(rover->flags&FF_EXISTS)) continue; if (!(rover->flags&FF_EXISTS)) continue;
if (!(rover->flags&FF_RENDERSIDES)) continue; if (!(rover->flags&FF_RENDERSIDES)) continue;
if ((rover->flags&(FF_SWIMMABLE|FF_TRANSLUCENT))!=flags) continue; if ((rover->flags&(FF_SWIMMABLE | FF_TRANSLUCENT)) != flags) continue;
fixed_t ff_topleft; float ff_topleft;
fixed_t ff_topright; float ff_topright;
fixed_t ff_bottomleft; float ff_bottomleft;
fixed_t ff_bottomright; float ff_bottomright;
GetPlanePos(&rover->top, ff_topleft, ff_topright); GetPlanePos(&rover->top, ff_topleft, ff_topright);
// we are completely below the bottom so unless there are some // we are completely below the bottom so unless there are some
// (unsupported) intersections there won't be any more floors that // (unsupported) intersections there won't be any more floors that
// could clip this one. // could clip this one.
if (ff_topleft<bottomleft && ff_topright<bottomright) goto done; if (ff_topleft < bottomleft && ff_topright < bottomright) goto done;
GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright); GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright);
// above top line? // above top line?
if (ff_bottomleft>topleft && ff_bottomright>topright) continue; if (ff_bottomleft > topleft && ff_bottomright > topright) continue;
// overlapping the top line // overlapping the top line
if (ff_topleft>=topleft && ff_topright>=topright) if (ff_topleft >= topleft && ff_topright >= topright)
{ {
// overlapping with the entire range // overlapping with the entire range
if (ff_bottomleft<=bottomleft && ff_bottomright<=bottomright) return; if (ff_bottomleft <= bottomleft && ff_bottomright <= bottomright) return;
else if (ff_bottomleft>bottomleft && ff_bottomright>bottomright) else if (ff_bottomleft > bottomleft && ff_bottomright > bottomright)
{ {
topleft=ff_bottomleft; topleft = ff_bottomleft;
topright=ff_bottomright; topright = ff_bottomright;
} }
else else
{ {
@ -1197,12 +1204,12 @@ void GLWall::ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector,
// I don't need this right now. // I don't need this right now.
} }
} }
else if (ff_topleft<=topleft && ff_topright<=topright) else if (ff_topleft <= topleft && ff_topright <= topright)
{ {
BuildFFBlock(seg, ffloor, topleft, topright, ff_topleft, ff_topright); BuildFFBlock(seg, ffloor, topleft, topright, ff_topleft, ff_topright);
if (ff_bottomleft<=bottomleft && ff_bottomright<=bottomright) return; if (ff_bottomleft <= bottomleft && ff_bottomright <= bottomright) return;
topleft=ff_bottomleft; topleft = ff_bottomleft;
topright=ff_bottomright; topright = ff_bottomright;
} }
else else
{ {
@ -1222,85 +1229,85 @@ done:
// //
// //
//========================================================================== //==========================================================================
void GLWall::DoFFloorBlocks(seg_t * seg,sector_t * frontsector,sector_t * backsector, void GLWall::DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector,
fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, float fch1, float fch2, float ffh1, float ffh2,
fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2) float bch1, float bch2, float bfh1, float bfh2)
{ {
TArray<F3DFloor *> & backffloors=backsector->e->XFloor.ffloors; TArray<F3DFloor *> & backffloors = backsector->e->XFloor.ffloors;
fixed_t topleft, topright, bottomleft, bottomright; float topleft, topright, bottomleft, bottomright;
bool renderedsomething=false; bool renderedsomething = false;
// if the ceilings intersect use the backsector's height because this sector's ceiling will // if the ceilings intersect use the backsector's height because this sector's ceiling will
// obstruct the redundant parts. // obstruct the redundant parts.
if (fch1<bch1 && fch2<bch2) if (fch1 < bch1 && fch2 < bch2)
{ {
topleft=fch1; topleft = fch1;
topright=fch2; topright = fch2;
} }
else else
{ {
topleft=bch1; topleft = bch1;
topright=bch2; topright = bch2;
} }
if (ffh1>bfh1 && ffh2>bfh2) if (ffh1 > bfh1 && ffh2 > bfh2)
{ {
bottomleft=ffh1; bottomleft = ffh1;
bottomright=ffh2; bottomright = ffh2;
} }
else else
{ {
bottomleft=bfh1; bottomleft = bfh1;
bottomright=bfh2; bottomright = bfh2;
} }
for(unsigned int i=0;i<backffloors.Size();i++) for (unsigned int i = 0; i < backffloors.Size(); i++)
{ {
F3DFloor * rover=backffloors[i]; F3DFloor * rover = backffloors[i];
if (!(rover->flags&FF_EXISTS)) continue; if (!(rover->flags&FF_EXISTS)) continue;
if (!(rover->flags&FF_RENDERSIDES) || (rover->flags&FF_INVERTSIDES)) continue; if (!(rover->flags&FF_RENDERSIDES) || (rover->flags&FF_INVERTSIDES)) continue;
fixed_t ff_topleft; float ff_topleft;
fixed_t ff_topright; float ff_topright;
fixed_t ff_bottomleft; float ff_bottomleft;
fixed_t ff_bottomright; float ff_bottomright;
GetPlanePos(&rover->top, ff_topleft, ff_topright); GetPlanePos(&rover->top, ff_topleft, ff_topright);
GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright); GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright);
// completely above ceiling // completely above ceiling
if (ff_bottomleft>topleft && ff_bottomright>topright && !renderedsomething) continue; if (ff_bottomleft > topleft && ff_bottomright > topright && !renderedsomething) continue;
if (ff_topleft>topleft && ff_topright>topright) if (ff_topleft > topleft && ff_topright > topright)
{ {
// the new section overlaps with the previous one - clip it! // the new section overlaps with the previous one - clip it!
ff_topleft=topleft; ff_topleft = topleft;
ff_topright=topright; ff_topright = topright;
} }
// do all inverse floors above the current one it there is a gap between the // do all inverse floors above the current one it there is a gap between the
// last 3D floor and this one. // last 3D floor and this one.
if (topleft>ff_topleft && topright>ff_topright) if (topleft > ff_topleft && topright > ff_topright)
InverseFloors(seg, frontsector, topleft, topright, ff_topleft, ff_topright); InverseFloors(seg, frontsector, topleft, topright, ff_topleft, ff_topright);
// if translucent or liquid clip away adjoining parts of the same type of FFloors on the other side // if translucent or liquid clip away adjoining parts of the same type of FFloors on the other side
if (rover->flags&(FF_SWIMMABLE|FF_TRANSLUCENT)) if (rover->flags&(FF_SWIMMABLE | FF_TRANSLUCENT))
ClipFFloors(seg, rover, frontsector, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); ClipFFloors(seg, rover, frontsector, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
else else
BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
topleft=ff_bottomleft; topleft = ff_bottomleft;
topright=ff_bottomright; topright = ff_bottomright;
renderedsomething=true; renderedsomething = true;
if (topleft<=bottomleft && topright<=bottomright) return; if (topleft <= bottomleft && topright <= bottomright) return;
} }
// draw all inverse floors below the lowest one // draw all inverse floors below the lowest one
if (frontsector->e->XFloor.ffloors.Size() > 0) if (frontsector->e->XFloor.ffloors.Size() > 0)
{ {
if (topleft>bottomleft || topright>bottomright) if (topleft > bottomleft || topright > bottomright)
InverseFloors(seg, frontsector, topleft, topright, bottomleft, bottomright); InverseFloors(seg, frontsector, topleft, topright, bottomleft, bottomright);
} }
} }
@ -1323,7 +1330,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
sector_t * segback; sector_t * segback;
#ifdef _DEBUG #ifdef _DEBUG
if (seg->linedef-lines==904) if (seg->linedef - lines == 904)
{ {
int a = 0; int a = 0;
} }
@ -1540,7 +1547,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
if (gltexture || drawfogboundary) if (gltexture || drawfogboundary)
{ {
DoMidTexture(seg, drawfogboundary, frontsector, backsector, realfront, realback, 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]) 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()) 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 */ /* bottom texture */
@ -1565,7 +1572,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
bfh2 = fch2; bfh2 = fch2;
} }
if (bfh1>ffh1 || bfh2>ffh2) if (bfh1 > ffh1 || bfh2 > ffh2)
{ {
gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true);
if (gltexture) if (gltexture)
@ -1617,8 +1624,8 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
if (frontsector->GetTexture(sector_t::floor) == skyflatnum) return; if (frontsector->GetTexture(sector_t::floor) == skyflatnum) return;
lightlist = NULL; lightlist = NULL;
fixed_t ffh = frontsector->GetPlaneTexZ(sector_t::floor); float ffh = frontsector->GetPlaneTexZF(sector_t::floor);
fixed_t bfh = backsector->GetPlaneTexZ(sector_t::floor); float bfh = backsector->GetPlaneTexZF(sector_t::floor);
if (bfh > ffh) if (bfh > ffh)
{ {
this->seg = seg; this->seg = seg;
@ -1652,7 +1659,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
bottomplane = frontsector->floorplane; bottomplane = frontsector->floorplane;
dynlightindex = UINT_MAX; dynlightindex = UINT_MAX;
zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh); zfloor[0] = zfloor[1] = ffh;
gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true); 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; FTexCoordInfo tci;
type = RENDERWALL_BOTTOM; type = RENDERWALL_BOTTOM;
gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); 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); PutWall(false);
} }
} }

View File

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