in doom_py/src/vizdoom/src/r_segs.cpp [2131:2458]
void R_NewWall (bool needlights)
{
fixed_t rowoffset, yrepeat;
rw_markmirror = false;
sidedef = curline->sidedef;
linedef = curline->linedef;
// mark the segment as visible for auto map
if (!r_dontmaplines) linedef->flags |= ML_MAPPED;
midtexture = toptexture = bottomtexture = 0;
if (backsector == NULL)
{
// single sided line
// a single sided line is terminal, so it must mark ends
markfloor = markceiling = true;
// [RH] Render mirrors later, but mark them now.
if (linedef->special != Line_Mirror || !r_drawmirrors)
{
// [RH] Horizon lines do not need to be textured
if (linedef->special != Line_Horizon)
{
midtexture = TexMan(sidedef->GetTexture(side_t::mid), true);
rw_offset_mid = sidedef->GetTextureXOffset(side_t::mid);
rowoffset = sidedef->GetTextureYOffset(side_t::mid);
rw_midtexturescalex = sidedef->GetTextureXScale(side_t::mid);
rw_midtexturescaley = sidedef->GetTextureYScale(side_t::mid);
yrepeat = FixedMul(midtexture->yScale, rw_midtexturescaley);
if (yrepeat >= 0)
{ // normal orientation
if (linedef->flags & ML_DONTPEGBOTTOM)
{ // bottom of texture at bottom
rw_midtexturemid = MulScale16(frontsector->GetPlaneTexZ(sector_t::floor) - viewz, yrepeat) + (midtexture->GetHeight() << FRACBITS);
}
else
{ // top of texture at top
rw_midtexturemid = MulScale16(frontsector->GetPlaneTexZ(sector_t::ceiling) - viewz, yrepeat);
if (rowoffset < 0 && midtexture != NULL)
{
rowoffset += midtexture->GetHeight() << FRACBITS;
}
}
}
else
{ // upside down
rowoffset = -rowoffset;
if (linedef->flags & ML_DONTPEGBOTTOM)
{ // top of texture at bottom
rw_midtexturemid = MulScale16(frontsector->GetPlaneTexZ(sector_t::floor) - viewz, yrepeat);
}
else
{ // bottom of texture at top
rw_midtexturemid = MulScale16(frontsector->GetPlaneTexZ(sector_t::ceiling) - viewz, yrepeat) + (midtexture->GetHeight() << FRACBITS);
}
}
if (midtexture->bWorldPanning)
{
rw_midtexturemid += MulScale16(rowoffset, yrepeat);
}
else
{
// rowoffset is added outside the multiply so that it positions the texture
// by texels instead of world units.
rw_midtexturemid += rowoffset;
}
}
}
else
{
rw_markmirror = true;
}
}
else
{ // two-sided line
// hack to allow height changes in outdoor areas
rw_frontlowertop = frontsector->GetPlaneTexZ(sector_t::ceiling);
if (frontsector->GetTexture(sector_t::ceiling) == skyflatnum &&
backsector->GetTexture(sector_t::ceiling) == skyflatnum)
{
if (rw_havehigh)
{ // front ceiling is above back ceiling
memcpy (&walltop[WallC.sx1], &wallupper[WallC.sx1], (WallC.sx2 - WallC.sx1)*sizeof(walltop[0]));
rw_havehigh = false;
}
else if (rw_havelow && frontsector->ceilingplane != backsector->ceilingplane)
{ // back ceiling is above front ceiling
// The check for rw_havelow is not Doom-compliant, but it avoids HoM that
// would otherwise occur because there is space made available for this
// wall but nothing to draw for it.
// Recalculate walltop so that the wall is clipped by the back sector's
// ceiling instead of the front sector's ceiling.
WallMost (walltop, backsector->ceilingplane, &WallC);
}
// Putting sky ceilings on the front and back of a line alters the way unpegged
// positioning works.
rw_frontlowertop = backsector->GetPlaneTexZ(sector_t::ceiling);
}
if ((rw_backcz1 <= rw_frontfz1 && rw_backcz2 <= rw_frontfz2) ||
(rw_backfz1 >= rw_frontcz1 && rw_backfz2 >= rw_frontcz2))
{
// closed door
markceiling = markfloor = true;
}
else
{
markfloor = rw_mustmarkfloor
|| backsector->floorplane != frontsector->floorplane
|| backsector->lightlevel != frontsector->lightlevel
|| backsector->GetTexture(sector_t::floor) != frontsector->GetTexture(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->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)
// [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())
|| (backsector->e && backsector->e->XFloor.lightlist.Size())
|| (sidedef->GetTexture(side_t::mid).isValid() &&
((linedef->flags & (ML_CLIP_MIDTEX|ML_WRAP_MIDTEX)) ||
(sidedef->Flags & (WALLF_CLIP_MIDTEX|WALLF_WRAP_MIDTEX))))
;
markceiling = (frontsector->GetTexture(sector_t::ceiling) != skyflatnum ||
backsector->GetTexture(sector_t::ceiling) != skyflatnum) &&
(rw_mustmarkceiling
|| backsector->ceilingplane != frontsector->ceilingplane
|| backsector->lightlevel != frontsector->lightlevel
|| 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->GetAlpha(sector_t::ceiling) != frontsector->GetAlpha(sector_t::ceiling)
// killough 4/15/98: prevent 2s normals
// from bleeding through fake ceilings
|| (frontsector->heightsec && frontsector->GetTexture(sector_t::ceiling) != skyflatnum)
|| backsector->GetPlaneLight(sector_t::ceiling) != frontsector->GetPlaneLight(sector_t::ceiling)
|| backsector->GetFlags(sector_t::ceiling) != frontsector->GetFlags(sector_t::ceiling)
// [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())
|| (sidedef->GetTexture(side_t::mid).isValid() &&
((linedef->flags & (ML_CLIP_MIDTEX|ML_WRAP_MIDTEX)) ||
(sidedef->Flags & (WALLF_CLIP_MIDTEX|WALLF_WRAP_MIDTEX))))
);
}
if (rw_havehigh)
{ // top texture
toptexture = TexMan(sidedef->GetTexture(side_t::top), true);
rw_offset_top = sidedef->GetTextureXOffset(side_t::top);
rowoffset = sidedef->GetTextureYOffset(side_t::top);
rw_toptexturescalex = sidedef->GetTextureXScale(side_t::top);
rw_toptexturescaley = sidedef->GetTextureYScale(side_t::top);
yrepeat = FixedMul(toptexture->yScale, rw_toptexturescaley);
if (yrepeat >= 0)
{ // normal orientation
if (linedef->flags & ML_DONTPEGTOP)
{ // top of texture at top
rw_toptexturemid = MulScale16(frontsector->GetPlaneTexZ(sector_t::ceiling) - viewz, yrepeat);
if (rowoffset < 0 && toptexture != NULL)
{
rowoffset += toptexture->GetHeight() << FRACBITS;
}
}
else
{ // bottom of texture at bottom
rw_toptexturemid = MulScale16(backsector->GetPlaneTexZ(sector_t::ceiling) - viewz, yrepeat) + (toptexture->GetHeight() << FRACBITS);
}
}
else
{ // upside down
rowoffset = -rowoffset;
if (linedef->flags & ML_DONTPEGTOP)
{ // bottom of texture at top
rw_toptexturemid = MulScale16(frontsector->GetPlaneTexZ(sector_t::ceiling) - viewz, yrepeat) + (toptexture->GetHeight() << FRACBITS);
}
else
{ // top of texture at bottom
rw_toptexturemid = MulScale16(backsector->GetPlaneTexZ(sector_t::ceiling) - viewz, yrepeat);
}
}
if (toptexture->bWorldPanning)
{
rw_toptexturemid += MulScale16(rowoffset, yrepeat);
}
else
{
rw_toptexturemid += rowoffset;
}
}
if (rw_havelow)
{ // bottom texture
bottomtexture = TexMan(sidedef->GetTexture(side_t::bottom), true);
rw_offset_bottom = sidedef->GetTextureXOffset(side_t::bottom);
rowoffset = sidedef->GetTextureYOffset(side_t::bottom);
rw_bottomtexturescalex = sidedef->GetTextureXScale(side_t::bottom);
rw_bottomtexturescaley = sidedef->GetTextureYScale(side_t::bottom);
yrepeat = FixedMul(bottomtexture->yScale, rw_bottomtexturescaley);
if (yrepeat >= 0)
{ // normal orientation
if (linedef->flags & ML_DONTPEGBOTTOM)
{ // bottom of texture at bottom
rw_bottomtexturemid = MulScale16(rw_frontlowertop - viewz, yrepeat);
}
else
{ // top of texture at top
rw_bottomtexturemid = MulScale16(backsector->GetPlaneTexZ(sector_t::floor) - viewz, yrepeat);
if (rowoffset < 0 && bottomtexture != NULL)
{
rowoffset += bottomtexture->GetHeight() << FRACBITS;
}
}
}
else
{ // upside down
rowoffset = -rowoffset;
if (linedef->flags & ML_DONTPEGBOTTOM)
{ // top of texture at bottom
rw_bottomtexturemid = MulScale16(rw_frontlowertop - viewz, yrepeat);
}
else
{ // bottom of texture at top
rw_bottomtexturemid = MulScale16(backsector->GetPlaneTexZ(sector_t::floor) - viewz, yrepeat) + (bottomtexture->GetHeight() << FRACBITS);
}
}
if (bottomtexture->bWorldPanning)
{
rw_bottomtexturemid += MulScale16(rowoffset, yrepeat);
}
else
{
rw_bottomtexturemid += rowoffset;
}
}
}
// if a floor / ceiling plane is on the wrong side of the view plane,
// it is definitely invisible and doesn't need to be marked.
// killough 3/7/98: add deep water check
if (frontsector->GetHeightSec() == NULL)
{
int planeside;
planeside = frontsector->floorplane.PointOnSide(viewx, viewy, viewz);
if (frontsector->floorplane.c < 0) // 3D floors have the floor backwards
planeside = -planeside;
if (planeside <= 0) // above view plane
markfloor = false;
if (frontsector->GetTexture(sector_t::ceiling) != skyflatnum)
{
planeside = frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz);
if (frontsector->ceilingplane.c > 0) // 3D floors have the ceiling backwards
planeside = -planeside;
if (planeside <= 0) // below view plane
markceiling = false;
}
}
FTexture *midtex = TexMan(sidedef->GetTexture(side_t::mid), true);
segtextured = midtex != NULL || toptexture != NULL || bottomtexture != NULL;
// calculate light table
if (needlights && (segtextured || (backsector && IsFogBoundary(frontsector, backsector))))
{
lwallscale =
midtex ? FixedMul(midtex->xScale, sidedef->GetTextureXScale(side_t::mid)) :
toptexture ? FixedMul(toptexture->xScale, sidedef->GetTextureXScale(side_t::top)) :
bottomtexture ? FixedMul(bottomtexture->xScale, sidedef->GetTextureXScale(side_t::bottom)) :
FRACUNIT;
PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.sx1, WallC.sx2);
if (fixedcolormap == NULL && fixedlightlev < 0)
{
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel)
+ r_actualextralight);
GlobVis = r_WallVisibility;
rw_lightleft = SafeDivScale12 (GlobVis, WallC.sz1);
rw_lightstep = (SafeDivScale12 (GlobVis, WallC.sz2) - rw_lightleft) / (WallC.sx2 - WallC.sx1);
}
else
{
rw_lightleft = FRACUNIT;
rw_lightstep = 0;
}
}
}