Render other sector portal types

This commit is contained in:
Magnus Norddahl 2016-11-25 20:19:35 +01:00
parent 864358389e
commit eaa15f2b74
3 changed files with 36 additions and 8 deletions

View File

@ -85,6 +85,12 @@ void PolyCull::CullSubsector(subsector_t *sub)
seg_t *line = &sub->firstline[i];
if ((line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) && line->backsector == nullptr)
{
// Skip lines not facing viewer
DVector2 pt1 = line->v1->fPos() - ViewPos;
DVector2 pt2 = line->v2->fPos() - ViewPos;
if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0)
continue;
int sx1, sx2;
if (GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2))
{

View File

@ -150,6 +150,8 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin
{
FSectorPortal *portal = sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor);
PolyDrawSectorPortal *polyportal = nullptr;
if (portal && (portal->mFlags & PORTSF_INSKYBOX) == PORTSF_INSKYBOX) // Do not recurse into portals we already recursed into
portal = nullptr;
if (portal)
{
for (auto &p : sectorPortals)

View File

@ -271,7 +271,7 @@ PolyDrawSectorPortal::PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling)
void PolyDrawSectorPortal::Render(int portalDepth)
{
if (Portal->mType != PORTS_SKYVIEWPOINT)
if (Portal->mType == PORTS_HORIZON || Portal->mType == PORTS_PLANE)
return;
SaveGlobals();
@ -302,10 +302,14 @@ void PolyDrawSectorPortal::Render(int portalDepth)
void PolyDrawSectorPortal::RenderTranslucent(int portalDepth)
{
if (Portal->mType != PORTS_SKYVIEWPOINT)
if (Portal->mType == PORTS_HORIZON || Portal->mType == PORTS_PLANE)
return;
SaveGlobals();
RenderPortal.RenderTranslucent(portalDepth);
RestoreGlobals();
}
void PolyDrawSectorPortal::SaveGlobals()
@ -317,20 +321,36 @@ void PolyDrawSectorPortal::SaveGlobals()
savedcamera = camera;
savedsector = viewsector;
// Don't let gun flashes brighten the sky box
ASkyViewpoint *sky = barrier_cast<ASkyViewpoint*>(Portal->mSkybox);
extralight = 0;
R_SetVisibility(sky->args[0] * 0.25f);
ViewPos = sky->InterpolatedPosition(r_TicFracF);
ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF);
if (Portal->mType == PORTS_SKYVIEWPOINT)
{
// Don't let gun flashes brighten the sky box
ASkyViewpoint *sky = barrier_cast<ASkyViewpoint*>(Portal->mSkybox);
extralight = 0;
R_SetVisibility(sky->args[0] * 0.25f);
ViewPos = sky->InterpolatedPosition(r_TicFracF);
ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF);
}
else //if (Portal->mType == PORTS_STACKEDSECTORTHING || Portal->mType == PORTS_PORTAL || Portal->mType == PORTS_LINKEDPORTAL)
{
//extralight = pl->extralight;
//R_SetVisibility(pl->visibility);
ViewPos.X += Portal->mDisplacement.X;
ViewPos.Y += Portal->mDisplacement.Y;
}
camera = nullptr;
viewsector = Portal->mDestination;
R_SetViewAngle();
Portal->mFlags |= PORTSF_INSKYBOX;
if (Portal->mPartner > 0) sectorPortals[Portal->mPartner].mFlags |= PORTSF_INSKYBOX;
}
void PolyDrawSectorPortal::RestoreGlobals()
{
Portal->mFlags &= ~PORTSF_INSKYBOX;
if (Portal->mPartner > 0) sectorPortals[Portal->mPartner].mFlags &= ~PORTSF_INSKYBOX;
camera = savedcamera;
viewsector = savedsector;
ViewPos = savedpos;