in doom_py/src/vizdoom/src/r_segs.cpp [694:1096]
void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2)
{
FTexture *const DONT_DRAW = ((FTexture*)(intptr_t)-1);
int i,j;
F3DFloor *rover, *fover = NULL;
int passed, last;
fixed_t floorheight;
fixed_t ceilingheight;
sprflipvert = false;
curline = ds->curline;
frontsector = curline->frontsector;
backsector = curline->backsector;
if (backsector == NULL)
{
return;
}
if ((ds->bFakeBoundary & 3) == 2)
{
sector_t *sec = backsector;
backsector = frontsector;
frontsector = sec;
}
floorheight = backsector->CenterFloor();
ceilingheight = backsector->CenterCeiling();
// maybe fix clipheights
if (!(fake3D & FAKE3D_CLIPBOTTOM)) sclipBottom = floorheight;
if (!(fake3D & FAKE3D_CLIPTOP)) sclipTop = ceilingheight;
// maybe not visible
if (sclipBottom >= frontsector->CenterCeiling()) return;
if (sclipTop <= frontsector->CenterFloor()) return;
if (fake3D & FAKE3D_DOWN2UP)
{ // bottom to viewz
last = 0;
for (i = backsector->e->XFloor.ffloors.Size() - 1; i >= 0; i--)
{
rover = backsector->e->XFloor.ffloors[i];
if (!(rover->flags & FF_EXISTS)) continue;
// visible?
passed = 0;
if (!(rover->flags & FF_RENDERSIDES) ||
rover->top.plane->a || rover->top.plane->b ||
rover->bottom.plane->a || rover->bottom.plane->b ||
rover->top.plane->Zat0() <= sclipBottom ||
rover->bottom.plane->Zat0() >= ceilingheight ||
rover->top.plane->Zat0() <= floorheight)
{
if (!i)
{
passed = 1;
}
else
{
continue;
}
}
rw_pic = NULL;
if (rover->bottom.plane->Zat0() >= sclipTop || passed)
{
if (last)
{
break;
}
// maybe wall from inside rendering?
fover = NULL;
for (j = frontsector->e->XFloor.ffloors.Size() - 1; j >= 0; j--)
{
fover = frontsector->e->XFloor.ffloors[j];
if (fover->model == rover->model)
{ // never
fover = NULL;
break;
}
if (!(fover->flags & FF_EXISTS)) continue;
if (!(fover->flags & FF_RENDERSIDES)) continue;
// no sloped walls, it's bugged
if (fover->top.plane->a || fover->top.plane->b || fover->bottom.plane->a || fover->bottom.plane->b) continue;
// visible?
if (fover->top.plane->Zat0() <= sclipBottom) continue; // no
if (fover->bottom.plane->Zat0() >= sclipTop)
{ // no, last possible
fover = NULL;
break;
}
// it is, render inside?
if (!(fover->flags & (FF_BOTHPLANES|FF_INVERTPLANES)))
{ // no
fover = NULL;
}
break;
}
// nothing
if (!fover || j == -1)
{
break;
}
// correct texture
if (fover->flags & rover->flags & FF_SWIMMABLE)
{ // don't ever draw (but treat as something has been found)
rw_pic = DONT_DRAW;
}
else if(fover->flags & FF_UPPERTEXTURE)
{
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true);
}
else if(fover->flags & FF_LOWERTEXTURE)
{
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true);
}
else
{
rw_pic = TexMan(fover->master->sidedef[0]->GetTexture(side_t::mid), true);
}
}
else if (frontsector->e->XFloor.ffloors.Size())
{
// maybe not visible?
fover = NULL;
for (j = frontsector->e->XFloor.ffloors.Size() - 1; j >= 0; j--)
{
fover = frontsector->e->XFloor.ffloors[j];
if (fover->model == rover->model) // never
{
break;
}
if (!(fover->flags & FF_EXISTS)) continue;
if (!(fover->flags & FF_RENDERSIDES)) continue;
// no sloped walls, it's bugged
if (fover->top.plane->a || fover->top.plane->b || fover->bottom.plane->a || fover->bottom.plane->b) continue;
// visible?
if (fover->top.plane->Zat0() <= sclipBottom) continue; // no
if (fover->bottom.plane->Zat0() >= sclipTop)
{ // visible, last possible
fover = NULL;
break;
}
if ((fover->flags & FF_SOLID) == (rover->flags & FF_SOLID) &&
!(!(fover->flags & FF_SOLID) && (fover->alpha == 255 || rover->alpha == 255))
)
{
break;
}
if (fover->flags & rover->flags & FF_SWIMMABLE)
{ // don't ever draw (but treat as something has been found)
rw_pic = DONT_DRAW;
}
fover = NULL; // visible
break;
}
if (fover && j != -1)
{
fover = NULL;
last = 1;
continue; // not visible
}
}
if (!rw_pic)
{
fover = NULL;
if (rover->flags & FF_UPPERTEXTURE)
{
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true);
}
else if(rover->flags & FF_LOWERTEXTURE)
{
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true);
}
else
{
rw_pic = TexMan(rover->master->sidedef[0]->GetTexture(side_t::mid), true);
}
}
// correct colors now
basecolormap = frontsector->ColorMap;
wallshade = ds->shade;
if (fixedlightlev < 0)
{
if ((ds->bFakeBoundary & 3) == 2)
{
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
{
if (sclipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
{
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
basecolormap = lit->extra_colormap;
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight);
break;
}
}
}
else
{
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
{
if (sclipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
{
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
basecolormap = lit->extra_colormap;
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight);
break;
}
}
}
}
if (rw_pic != DONT_DRAW)
{
R_RenderFakeWall(ds, x1, x2, fover ? fover : rover);
}
else rw_pic = NULL;
break;
}
}
else
{ // top to viewz
for (i = 0; i < (int)backsector->e->XFloor.ffloors.Size(); i++)
{
rover = backsector->e->XFloor.ffloors[i];
if (!(rover->flags & FF_EXISTS)) continue;
// visible?
passed = 0;
if (!(rover->flags & FF_RENDERSIDES) ||
rover->top.plane->a || rover->top.plane->b ||
rover->bottom.plane->a || rover->bottom.plane->b ||
rover->bottom.plane->Zat0() >= sclipTop ||
rover->top.plane->Zat0() <= floorheight ||
rover->bottom.plane->Zat0() >= ceilingheight)
{
if ((unsigned)i == backsector->e->XFloor.ffloors.Size() - 1)
{
passed = 1;
}
else
{
continue;
}
}
rw_pic = NULL;
if (rover->top.plane->Zat0() <= sclipBottom || passed)
{ // maybe wall from inside rendering?
fover = NULL;
for (j = 0; j < (int)frontsector->e->XFloor.ffloors.Size(); j++)
{
fover = frontsector->e->XFloor.ffloors[j];
if (fover->model == rover->model)
{ // never
fover = NULL;
break;
}
if (!(fover->flags & FF_EXISTS)) continue;
if (!(fover->flags & FF_RENDERSIDES)) continue;
// no sloped walls, it's bugged
if (fover->top.plane->a || fover->top.plane->b || fover->bottom.plane->a || fover->bottom.plane->b) continue;
// visible?
if (fover->bottom.plane->Zat0() >= sclipTop) continue; // no
if (fover->top.plane->Zat0() <= sclipBottom)
{ // no, last possible
fover = NULL;
break;
}
// it is, render inside?
if (!(fover->flags & (FF_BOTHPLANES|FF_INVERTPLANES)))
{ // no
fover = NULL;
}
break;
}
// nothing
if (!fover || (unsigned)j == frontsector->e->XFloor.ffloors.Size())
{
break;
}
// correct texture
if (fover->flags & rover->flags & FF_SWIMMABLE)
{
rw_pic = DONT_DRAW; // don't ever draw (but treat as something has been found)
}
else if (fover->flags & FF_UPPERTEXTURE)
{
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true);
}
else if (fover->flags & FF_LOWERTEXTURE)
{
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true);
}
else
{
rw_pic = TexMan(fover->master->sidedef[0]->GetTexture(side_t::mid), true);
}
}
else if (frontsector->e->XFloor.ffloors.Size())
{ // maybe not visible?
fover = NULL;
for (j = 0; j < (int)frontsector->e->XFloor.ffloors.Size(); j++)
{
fover = frontsector->e->XFloor.ffloors[j];
if (fover->model == rover->model)
{ // never
break;
}
if (!(fover->flags & FF_EXISTS)) continue;
if (!(fover->flags & FF_RENDERSIDES)) continue;
// no sloped walls, its bugged
if(fover->top.plane->a || fover->top.plane->b || fover->bottom.plane->a || fover->bottom.plane->b) continue;
// visible?
if (fover->bottom.plane->Zat0() >= sclipTop) continue; // no
if (fover->top.plane->Zat0() <= sclipBottom)
{ // visible, last possible
fover = NULL;
break;
}
if ((fover->flags & FF_SOLID) == (rover->flags & FF_SOLID) &&
!(!(rover->flags & FF_SOLID) && (fover->alpha == 255 || rover->alpha == 255))
)
{
break;
}
if (fover->flags & rover->flags & FF_SWIMMABLE)
{ // don't ever draw (but treat as something has been found)
rw_pic = DONT_DRAW;
}
fover = NULL; // visible
break;
}
if (fover && (unsigned)j != frontsector->e->XFloor.ffloors.Size())
{ // not visible
break;
}
}
if (rw_pic == NULL)
{
fover = NULL;
if (rover->flags & FF_UPPERTEXTURE)
{
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true);
}
else if (rover->flags & FF_LOWERTEXTURE)
{
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true);
}
else
{
rw_pic = TexMan(rover->master->sidedef[0]->GetTexture(side_t::mid), true);
}
}
// correct colors now
basecolormap = frontsector->ColorMap;
wallshade = ds->shade;
if (fixedlightlev < 0)
{
if ((ds->bFakeBoundary & 3) == 2)
{
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
{
if (sclipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
{
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
basecolormap = lit->extra_colormap;
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight);
break;
}
}
}
else
{
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
{
if(sclipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
{
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
basecolormap = lit->extra_colormap;
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight);
break;
}
}
}
}
if (rw_pic != DONT_DRAW)
{
R_RenderFakeWall(ds, x1, x2, fover ? fover : rover);
}
else
{
rw_pic = NULL;
}
break;
}
}
return;
}