mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-30 07:41:22 +00:00
- improve softpoly 3d floor drawing somewhat
This commit is contained in:
parent
fcfccfe739
commit
2cd1734de3
2 changed files with 40 additions and 14 deletions
|
@ -430,17 +430,15 @@ void Render3DFloorPlane::RenderPlanes(PolyRenderThread *thread, subsector_t *sub
|
|||
for (int i = 0; i < (int)ffloors.Size(); i++)
|
||||
{
|
||||
F3DFloor *fakeFloor = ffloors[i];
|
||||
F3DFloor *prevFloor = i > 0 ? ffloors[i - 1] : nullptr;
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
//if (!(fakeFloor->flags & FF_NOSHADE) || (fakeFloor->flags & (FF_RENDERPLANES | FF_RENDERSIDES)))
|
||||
// R_3D_AddHeight(fakeFloor->top.plane, frontsector);
|
||||
if (!(fakeFloor->flags & FF_RENDERPLANES)) continue;
|
||||
if (fakeFloor->alpha == 0) continue;
|
||||
if (fakeFloor->flags & FF_THISINSIDE && fakeFloor->flags & FF_INVERTSECTOR) continue;
|
||||
//fakeFloor->alpha
|
||||
if (prevFloor && (prevFloor->flags & fakeFloor->flags & FF_SWIMMABLE)) continue;
|
||||
|
||||
double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot);
|
||||
if (fakeFloor->bottom.plane->isSlope() || (fakeHeight < viewpoint.Pos.Z && fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot)))
|
||||
if (fakeFloor->top.plane->isSlope() || (fakeHeight < viewpoint.Pos.Z && fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot)))
|
||||
{
|
||||
Render3DFloorPlane plane;
|
||||
plane.sub = sub;
|
||||
|
@ -470,14 +468,12 @@ void Render3DFloorPlane::RenderPlanes(PolyRenderThread *thread, subsector_t *sub
|
|||
for (int i = 0; i < (int)ffloors.Size(); i++)
|
||||
{
|
||||
F3DFloor *fakeFloor = ffloors[i];
|
||||
F3DFloor *prevFloor = i > 0 ? ffloors[i - 1] : nullptr;
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
//if (!(fakeFloor->flags & FF_NOSHADE) || (fakeFloor->flags & (FF_RENDERPLANES | FF_RENDERSIDES)))
|
||||
// R_3D_AddHeight(fakeFloor->bottom.plane, frontsector);
|
||||
if (!(fakeFloor->flags & FF_RENDERPLANES)) continue;
|
||||
if (fakeFloor->alpha == 0) continue;
|
||||
if (!(fakeFloor->flags & FF_THISINSIDE) && (fakeFloor->flags & (FF_SWIMMABLE | FF_INVERTSECTOR)) == (FF_SWIMMABLE | FF_INVERTSECTOR)) continue;
|
||||
//fakeFloor->alpha
|
||||
if (prevFloor && (prevFloor->flags & fakeFloor->flags & FF_SWIMMABLE)) continue;
|
||||
|
||||
double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot);
|
||||
if (fakeFloor->bottom.plane->isSlope() || (fakeHeight > viewpoint.Pos.Z && fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot)))
|
||||
|
@ -520,7 +516,7 @@ void Render3DFloorPlane::Render(PolyRenderThread *thread)
|
|||
bool foggy = false;
|
||||
if (cameraLight->FixedLightLevel() < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
lightlist_t *light = P_GetPlaneLight(sub->sector, &sub->sector->ceilingplane, false);
|
||||
lightlist_t *light = P_GetPlaneLight(sub->sector, ceiling ? fakeFloor->bottom.plane : fakeFloor->top.plane, ceiling);
|
||||
//basecolormap = light->extra_colormap;
|
||||
lightlevel = *light->p_lightlevel;
|
||||
}
|
||||
|
@ -553,15 +549,17 @@ void Render3DFloorPlane::Render(PolyRenderThread *thread)
|
|||
if (!Masked)
|
||||
{
|
||||
args.SetStyle(TriBlendMode::Opaque);
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
args.SetWriteStencil(true, stencilValue + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
args.SetStyle(Additive ? TriBlendMode::Add : TriBlendMode::Normal, MIN(Alpha, 1.0));
|
||||
args.SetStencilTestValue(stencilValue + 1);
|
||||
args.SetWriteStencil(false);
|
||||
args.SetDepthTest(true);
|
||||
args.SetWriteDepth(true);
|
||||
}
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
args.SetWriteStencil(true, stencilValue + 1);
|
||||
args.SetTexture(tex->GetSoftwareTexture(), DefaultRenderStyle());
|
||||
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, sub->numlines, PolyDrawMode::TriangleFan);
|
||||
}
|
||||
|
|
|
@ -196,7 +196,6 @@ void RenderPolyWall::Render3DFloorLine(PolyRenderThread *thread, seg_t *line, se
|
|||
{
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) return;
|
||||
if (!(fakeFloor->flags & FF_RENDERPLANES)) return;
|
||||
if (fakeFloor->flags & FF_SWIMMABLE) return;
|
||||
if (!fakeFloor->model) return;
|
||||
if (fakeFloor->alpha == 0) return;
|
||||
|
||||
|
@ -210,12 +209,29 @@ void RenderPolyWall::Render3DFloorLine(PolyRenderThread *thread, seg_t *line, se
|
|||
if (frontceilz1 <= frontfloorz1 || frontceilz2 <= frontfloorz2)
|
||||
return;
|
||||
|
||||
if (fakeFloor->flags & FF_SWIMMABLE) // Only draw swimmable boundary if not swimmable on both sides
|
||||
{
|
||||
DVector2 c = (line->v1->fPos() + line->v2->fPos()) * 0.5;
|
||||
double cz = (frontceilz1 + frontceilz2 + frontfloorz1 + frontfloorz2) * 0.25;
|
||||
for (unsigned i = 0; i < frontsector->e->XFloor.ffloors.Size(); i++)
|
||||
{
|
||||
F3DFloor *frontFloor = frontsector->e->XFloor.ffloors[i];
|
||||
if (!(frontFloor->flags & FF_EXISTS)) continue;
|
||||
if (!(frontFloor->flags & FF_RENDERPLANES)) continue;
|
||||
if (!frontFloor->model) continue;
|
||||
if (frontFloor->alpha == 0) continue;
|
||||
if (frontFloor->top.plane->ZatPoint(c) >= cz && frontFloor->bottom.plane->ZatPoint(c) <= cz && (frontFloor->flags & FF_SWIMMABLE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RenderPolyWall wall;
|
||||
wall.LineSeg = line;
|
||||
wall.LineSegLine = line->linedef;
|
||||
wall.Line = fakeFloor->master;
|
||||
wall.Side = fakeFloor->master->sidedef[0];
|
||||
wall.SectorLightLevel = frontsector->lightlevel;
|
||||
wall.Additive = !!(fakeFloor->flags & FF_ADDITIVETRANS);
|
||||
if (!wall.Additive && fakeFloor->alpha == 255)
|
||||
{
|
||||
|
@ -241,6 +257,18 @@ void RenderPolyWall::Render3DFloorLine(PolyRenderThread *thread, seg_t *line, se
|
|||
else
|
||||
wall.Texture = GetTexture(wall.Line, wall.Side, side_t::mid);
|
||||
|
||||
if (frontsector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
lightlist_t *light = P_GetPlaneLight(frontsector, fakeFloor->top.plane, true);
|
||||
wall.Colormap = GetColorTable(light->extra_colormap, wall.Side->GetSpecialColor(wall.Wallpart, side_t::walltop, frontsector));
|
||||
wall.SectorLightLevel = *light->p_lightlevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
wall.SectorLightLevel = frontsector->lightlevel;
|
||||
}
|
||||
|
||||
if (!wall.Masked)
|
||||
wall.Render(thread);
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue