mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
- Improve 3d floor and underwater rendering
This commit is contained in:
parent
7993ad987c
commit
c2fa360bbc
3 changed files with 61 additions and 51 deletions
|
@ -33,60 +33,67 @@
|
|||
|
||||
EXTERN_CVAR(Int, r_3dfloors)
|
||||
|
||||
void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
||||
void RenderPolyPlane::Render3DPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t stencilValue)
|
||||
{
|
||||
RenderPolyPlane plane;
|
||||
if (!r_3dfloors || sub->sector->CenterFloor() == sub->sector->CenterCeiling())
|
||||
return;
|
||||
|
||||
if (r_3dfloors)
|
||||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
|
||||
auto frontsector = sub->sector;
|
||||
auto &ffloors = frontsector->e->XFloor.ffloors;
|
||||
|
||||
// 3D floor floors
|
||||
for (int i = 0; i < (int)ffloors.Size(); i++)
|
||||
{
|
||||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
F3DFloor *fakeFloor = ffloors[i];
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
if (fakeFloor->bottom.plane->isSlope()) 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
|
||||
|
||||
auto frontsector = sub->sector;
|
||||
auto &ffloors = frontsector->e->XFloor.ffloors;
|
||||
|
||||
// 3D floor floors
|
||||
for (int i = 0; i < (int)ffloors.Size(); i++)
|
||||
double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot);
|
||||
if (fakeHeight < viewpoint.Pos.Z && fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot))
|
||||
{
|
||||
F3DFloor *fakeFloor = ffloors[i];
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
if (fakeFloor->bottom.plane->isSlope()) 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
|
||||
|
||||
double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot);
|
||||
if (fakeHeight < viewpoint.Pos.Z && fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot))
|
||||
{
|
||||
plane.Render3DFloor(worldToClip, clipPlane, sub, stencilValue, false, fakeFloor);
|
||||
}
|
||||
}
|
||||
|
||||
// 3D floor ceilings
|
||||
for (int i = 0; i < (int)ffloors.Size(); i++)
|
||||
{
|
||||
F3DFloor *fakeFloor = ffloors[i];
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
if (fakeFloor->top.plane->isSlope()) 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
|
||||
|
||||
double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot);
|
||||
if (fakeHeight > viewpoint.Pos.Z && fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot))
|
||||
{
|
||||
plane.Render3DFloor(worldToClip, clipPlane, sub, stencilValue, true, fakeFloor);
|
||||
}
|
||||
RenderPolyPlane plane;
|
||||
plane.Render3DFloor(worldToClip, clipPlane, sub, stencilValue, false, fakeFloor);
|
||||
}
|
||||
}
|
||||
|
||||
// 3D floor ceilings
|
||||
for (int i = 0; i < (int)ffloors.Size(); i++)
|
||||
{
|
||||
F3DFloor *fakeFloor = ffloors[i];
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
if (fakeFloor->top.plane->isSlope()) 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
|
||||
|
||||
double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot);
|
||||
if (fakeHeight > viewpoint.Pos.Z && fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot))
|
||||
{
|
||||
RenderPolyPlane plane;
|
||||
plane.Render3DFloor(worldToClip, clipPlane, sub, stencilValue, true, fakeFloor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
||||
{
|
||||
if (sub->sector->CenterFloor() == sub->sector->CenterCeiling())
|
||||
return;
|
||||
|
||||
RenderPolyPlane plane;
|
||||
plane.Render(worldToClip, clipPlane, cull, sub, stencilValue, true, skyCeilingHeight, sectorPortals);
|
||||
plane.Render(worldToClip, clipPlane, cull, sub, stencilValue, false, skyFloorHeight, sectorPortals);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ class RenderPolyPlane
|
|||
{
|
||||
public:
|
||||
static void RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals);
|
||||
static void Render3DPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t stencilValue);
|
||||
|
||||
private:
|
||||
struct UVTransform
|
||||
|
|
|
@ -167,9 +167,15 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub, uint32_t ceilingSubsecto
|
|||
{
|
||||
RenderPolyNode(&sub->BSP->Nodes.Last(), subsectorDepth, frontsector);
|
||||
}
|
||||
|
||||
RenderPolyPlane::Render3DPlanes(WorldToClip, PortalPlane, sub, StencilValue);
|
||||
RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, Cull, sub, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderPolyPlane::Render3DPlanes(WorldToClip, PortalPlane, sub, StencilValue);
|
||||
RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, Cull, sub, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals);
|
||||
|
||||
for (uint32_t i = 0; i < sub->numlines; i++)
|
||||
{
|
||||
seg_t *line = &sub->firstline[i];
|
||||
|
@ -177,11 +183,6 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub, uint32_t ceilingSubsecto
|
|||
}
|
||||
}
|
||||
|
||||
if (sub->sector->CenterFloor() != sub->sector->CenterCeiling())
|
||||
{
|
||||
RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, Cull, sub, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals);
|
||||
}
|
||||
|
||||
if (mainBSP)
|
||||
{
|
||||
RenderMemory &memory = PolyRenderer::Instance()->FrameMemory;
|
||||
|
@ -345,6 +346,7 @@ void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *fronts
|
|||
F3DFloor *fakeFloor = line->backsector->e->XFloor.ffloors[i];
|
||||
if (!(fakeFloor->flags & FF_EXISTS)) continue;
|
||||
if (!(fakeFloor->flags & FF_RENDERPLANES)) continue;
|
||||
if (fakeFloor->flags & FF_SWIMMABLE) continue;
|
||||
if (!fakeFloor->model) continue;
|
||||
RenderPolyWall::Render3DFloorLine(WorldToClip, PortalPlane, Cull, line, frontsector, subsectorDepth, StencilValue, fakeFloor, TranslucentObjects);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue