Merge remote-tracking branch 'gzdoom/master' into big_beautiful_merge
This commit is contained in:
commit
17dacefc9b
41 changed files with 466 additions and 331 deletions
|
|
@ -1046,7 +1046,7 @@ void DoomLevelMesh::UpdateLightShadows(sector_t* sector)
|
|||
{
|
||||
for (FSection& section : level.sections.SectionsForSector(sector))
|
||||
{
|
||||
auto flatLightList = level.lightlists.flat_dlist.CheckKey(§ion);
|
||||
auto flatLightList = level.lightlists.flat_dlist.SSize() > section.Index() ? &level.lightlists.flat_dlist[section.Index()] : nullptr;
|
||||
if (flatLightList)
|
||||
{
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>::Iterator it(*flatLightList);
|
||||
|
|
@ -1066,18 +1066,18 @@ void DoomLevelMesh::UpdateLightShadows(sector_t* sector)
|
|||
|
||||
void DoomLevelMesh::UpdateLightShadows(FDynamicLight* light)
|
||||
{
|
||||
auto touching_sector = light->touching_sector;
|
||||
while (touching_sector)
|
||||
for (int i = 0; i < light->touchlists.flat_tlist.SSize(); i++)
|
||||
{
|
||||
UpdateFlat(touching_sector->targSection->sector->Index(), SurfaceUpdateType::LightList);
|
||||
touching_sector = touching_sector->nextTarget;
|
||||
auto sec = light->touchlists.flat_tlist[i];
|
||||
if (sec)
|
||||
UpdateFlat(sec->sector->Index(), SurfaceUpdateType::LightList);
|
||||
}
|
||||
|
||||
auto touching_sides = light->touching_sides;
|
||||
while (touching_sides)
|
||||
for (int i = 0; i < light->touchlists.wall_tlist.SSize(); i++)
|
||||
{
|
||||
UpdateSide(touching_sides->targLine->Index(), SurfaceUpdateType::LightList);
|
||||
touching_sides = touching_sides->nextTarget;
|
||||
auto sidedef = light->touchlists.wall_tlist[i];
|
||||
if (sidedef)
|
||||
UpdateSide(sidedef->Index(), SurfaceUpdateType::LightList);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1315,9 +1315,13 @@ void DoomLevelMesh::UpdateFlat(unsigned int sectorIndex, SurfaceUpdateType updat
|
|||
|
||||
LightListAllocInfo DoomLevelMesh::CreateLightList(FSection* section, side_t* side, int portalgroup)
|
||||
{
|
||||
int lightcount = 0;
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>* srcLightList = nullptr;
|
||||
if (section && level.lightlists.flat_dlist.SSize() > section->Index())
|
||||
srcLightList = &level.lightlists.flat_dlist[section->Index()];
|
||||
else if (side && level.lightlists.wall_dlist.SSize() > side->Index())
|
||||
srcLightList = &level.lightlists.wall_dlist[side->Index()];
|
||||
|
||||
auto srcLightList = section ? level.lightlists.flat_dlist.CheckKey(section) : level.lightlists.wall_dlist.CheckKey(side);
|
||||
int lightcount = 0;
|
||||
if (srcLightList)
|
||||
{
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>::Iterator it(*srcLightList);
|
||||
|
|
|
|||
|
|
@ -270,6 +270,8 @@ void HWDrawInfo::UnclipSubsector(subsector_t *sub)
|
|||
|
||||
void HWDrawInfo::AddLine (seg_t *seg, bool portalclip, FRenderState& state)
|
||||
{
|
||||
const bool doOob = Viewpoint.bDoOob;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (seg->linedef && seg->linedef->Index() == 38)
|
||||
{
|
||||
|
|
@ -293,7 +295,7 @@ void HWDrawInfo::AddLine (seg_t *seg, bool portalclip, FRenderState& state)
|
|||
angle_t endAngleR = 0;
|
||||
angle_t paddingR = 0x00200000; // Make radar clipping more aggressive (reveal less)
|
||||
|
||||
if(Viewpoint.IsAllowedOoB() && r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR))
|
||||
if(doOob && r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR))
|
||||
{
|
||||
startAngleR = clipperr.PointToPseudoAngle(seg->v2->fX(), seg->v2->fY());
|
||||
endAngleR = clipperr.PointToPseudoAngle(seg->v1->fX(), seg->v1->fY());
|
||||
|
|
@ -321,11 +323,11 @@ void HWDrawInfo::AddLine (seg_t *seg, bool portalclip, FRenderState& state)
|
|||
{
|
||||
if (!(currentsubsector->flags & SSECMF_DRAWN))
|
||||
{
|
||||
if (clipper.SafeCheckRange(startAngle, endAngle) && !Viewpoint.IsAllowedOoB())
|
||||
if (clipper.SafeCheckRange(startAngle, endAngle) && !doOob)
|
||||
{
|
||||
currentsubsector->flags |= SSECMF_DRAWN;
|
||||
}
|
||||
if (Viewpoint.IsAllowedOoB() && (r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR)) && clipperr.SafeCheckRange(startAngleR, endAngleR))
|
||||
if (doOob && (r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR)) && clipperr.SafeCheckRange(startAngleR, endAngleR))
|
||||
{
|
||||
currentsubsector->flags |= SSECMF_DRAWN;
|
||||
}
|
||||
|
|
@ -338,14 +340,14 @@ void HWDrawInfo::AddLine (seg_t *seg, bool portalclip, FRenderState& state)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Viewpoint.IsAllowedOoB() || (!r_radarclipper || (Level->flags3 & LEVEL3_NOFOGOFWAR) || clipperr.SafeCheckRange(startAngleR, endAngleR)))
|
||||
if (!doOob || (!r_radarclipper || (Level->flags3 & LEVEL3_NOFOGOFWAR) || clipperr.SafeCheckRange(startAngleR, endAngleR)))
|
||||
currentsubsector->flags |= SSECMF_DRAWN;
|
||||
|
||||
uint8_t ispoly = uint8_t(seg->sidedef->Flags & WALLF_POLYOBJ);
|
||||
|
||||
if (!seg->backsector)
|
||||
{
|
||||
if(!Viewpoint.IsAllowedOoB())
|
||||
if(!doOob)
|
||||
if (!(seg->sidedef->Flags & WALLF_DITHERTRANS_MID)) clipper.SafeAddClipRange(startAngle, endAngle);
|
||||
}
|
||||
else if (!ispoly) // Two-sided polyobjects never obstruct the view
|
||||
|
|
@ -373,7 +375,7 @@ void HWDrawInfo::AddLine (seg_t *seg, bool portalclip, FRenderState& state)
|
|||
|
||||
if (hw_CheckClip(seg->sidedef, currentsector, backsector, !outer ? &ClipFrustum : nullptr))
|
||||
{
|
||||
if(!Viewpoint.IsAllowedOoB() && !(seg->sidedef->Flags & WALLF_DITHERTRANS_MID))
|
||||
if(!doOob && !(seg->sidedef->Flags & WALLF_DITHERTRANS_MID))
|
||||
clipper.SafeAddClipRange(startAngle, endAngle);
|
||||
}
|
||||
}
|
||||
|
|
@ -590,7 +592,7 @@ void HWDrawInfo::RenderThings(subsector_t * sub, sector_t * sector, FRenderState
|
|||
if (thing->validcount == validcount) continue;
|
||||
thing->validcount = validcount;
|
||||
|
||||
if(Viewpoint.IsAllowedOoB() && thing->Sector->isSecret() && thing->Sector->wasSecret() && !r_radarclipper) continue; // This covers things that are touching non-secret sectors
|
||||
if(Viewpoint.bDoOob && thing->Sector->isSecret() && thing->Sector->wasSecret() && !r_radarclipper) continue; // This covers things that are touching non-secret sectors
|
||||
FIntCVar *cvar = thing->GetInfo()->distancecheck;
|
||||
if (cvar != nullptr && *cvar >= 0)
|
||||
{
|
||||
|
|
@ -695,6 +697,7 @@ void HWDrawInfo::RenderParticles(subsector_t *sub, sector_t *front, FRenderState
|
|||
|
||||
void HWDrawInfo::DoSubsector(subsector_t * sub, FRenderState& state)
|
||||
{
|
||||
const bool doOob = Viewpoint.bDoOob;
|
||||
sector_t * sector;
|
||||
sector_t * fakesector;
|
||||
|
||||
|
|
@ -723,10 +726,10 @@ void HWDrawInfo::DoSubsector(subsector_t * sub, FRenderState& state)
|
|||
|
||||
fakesector=hw_FakeFlat(drawctx, sector, in_area, false);
|
||||
|
||||
if(Viewpoint.IsAllowedOoB() && sector->isSecret() && sector->wasSecret() && !r_radarclipper) return;
|
||||
if(doOob && sector->isSecret() && sector->wasSecret() && !r_radarclipper) return;
|
||||
|
||||
// cull everything if subsector outside all relevant clippers
|
||||
if (Viewpoint.IsAllowedOoB() && (sub->polys == nullptr))
|
||||
if (doOob && (sub->polys == nullptr))
|
||||
{
|
||||
auto &clipper = *mClipper;
|
||||
auto &clipperv = *vClipper;
|
||||
|
|
@ -734,11 +737,10 @@ void HWDrawInfo::DoSubsector(subsector_t * sub, FRenderState& state)
|
|||
int count = sub->numlines;
|
||||
seg_t * seg = sub->firstline;
|
||||
bool anglevisible = false;
|
||||
bool pitchvisible = !(Viewpoint.IsAllowedOoB()); // No vertical clipping if viewpoint is not allowed out of bounds
|
||||
bool radarvisible = !(Viewpoint.IsAllowedOoB()) || !r_radarclipper || (Level->flags3 & LEVEL3_NOFOGOFWAR) || ((sub->flags & SSECMF_DRAWN) && !deathmatch);
|
||||
bool ceilreflect = (mCurrentPortal && strcmp(mCurrentPortal->GetName(), "Planemirror ceiling"));
|
||||
bool floorreflect = (mCurrentPortal && strcmp(mCurrentPortal->GetName(), "Planemirror floor"));
|
||||
double planez = (ceilreflect ? sector->ceilingplane.ZatPoint(Viewpoint.Pos) : sector->floorplane.ZatPoint(Viewpoint.Pos));
|
||||
bool pitchvisible = false;
|
||||
bool radarvisible = !r_radarclipper || (Level->flags3 & LEVEL3_NOFOGOFWAR) || ((sub->flags & SSECMF_DRAWN) && !deathmatch);
|
||||
const int reflect = mCurrentPortal ? mCurrentPortal->GetMirrorSide() : 0; // -1 = ceiling, 1 = floor, 0 = none
|
||||
const double planez = (reflect < 0 ? sector->ceilingplane.ZatPoint(Viewpoint.Pos) : sector->floorplane.ZatPoint(Viewpoint.Pos));
|
||||
angle_t pitchtemp;
|
||||
angle_t pitchmin = ANGLE_90;
|
||||
angle_t pitchmax = 0;
|
||||
|
|
@ -763,11 +765,11 @@ void HWDrawInfo::DoSubsector(subsector_t * sub, FRenderState& state)
|
|||
if (!pitchvisible)
|
||||
{
|
||||
pitchmin = clipperv.PointToPseudoPitch(seg->v1->fX(), seg->v1->fY(),
|
||||
(ceilreflect || floorreflect) ?
|
||||
(reflect != 0) ?
|
||||
2 * planez - sector->floorplane.ZatPoint(seg->v1) :
|
||||
sector->floorplane.ZatPoint(seg->v1));
|
||||
pitchmax = clipperv.PointToPseudoPitch(seg->v1->fX(), seg->v1->fY(),
|
||||
(ceilreflect || floorreflect) ?
|
||||
(reflect != 0) ?
|
||||
2 * planez - sector->ceilingplane.ZatPoint(seg->v1) :
|
||||
sector->ceilingplane.ZatPoint(seg->v1));
|
||||
pitchvisible |= clipperv.SafeCheckRange(pitchmin, pitchmax);
|
||||
|
|
@ -776,12 +778,12 @@ void HWDrawInfo::DoSubsector(subsector_t * sub, FRenderState& state)
|
|||
if (!pitchvisible)
|
||||
{
|
||||
pitchtemp = clipperv.PointToPseudoPitch(seg->v2->fX(), seg->v2->fY(),
|
||||
(ceilreflect || floorreflect) ?
|
||||
(reflect != 0) ?
|
||||
2 * planez - sector->floorplane.ZatPoint(seg->v2) :
|
||||
sector->floorplane.ZatPoint(seg->v2));
|
||||
if (int(pitchmin) > int(pitchtemp)) pitchmin = pitchtemp;
|
||||
pitchtemp = clipperv.PointToPseudoPitch(seg->v2->fX(), seg->v2->fY(),
|
||||
(ceilreflect || floorreflect) ?
|
||||
(reflect != 0) ?
|
||||
2 * planez - sector->ceilingplane.ZatPoint(seg->v2) :
|
||||
sector->ceilingplane.ZatPoint(seg->v2));
|
||||
if (int(pitchmax) < int(pitchtemp)) pitchmax = pitchtemp;
|
||||
|
|
@ -852,7 +854,7 @@ void HWDrawInfo::DoSubsector(subsector_t * sub, FRenderState& state)
|
|||
SetupSprite.Unclock();
|
||||
}
|
||||
}
|
||||
if (r_dithertransparency && Viewpoint.IsAllowedOoB() && (RTnum < MAXDITHERACTORS) && mCurrentPortal == nullptr)
|
||||
if (r_dithertransparency && doOob && (RTnum < MAXDITHERACTORS) && mCurrentPortal == nullptr)
|
||||
{
|
||||
// [DVR] Not parallelizable due to variables RTnum and RenderedTargets[]
|
||||
for (auto p = sector->touching_renderthings; p != nullptr; p = p->m_snext)
|
||||
|
|
@ -999,7 +1001,7 @@ void HWDrawInfo::RenderBSPNode (void *node, FRenderState& state)
|
|||
if (!(no_renderflags[bsp->Index()] & SSRF_SEEN))
|
||||
return;
|
||||
}
|
||||
if (Viewpoint.IsOrtho())
|
||||
if (Viewpoint.bDoOrtho)
|
||||
{
|
||||
if (!vClipper->CheckBoxOrthoPitch(bsp->bbox[side]))
|
||||
{
|
||||
|
|
@ -1016,7 +1018,7 @@ void HWDrawInfo::RenderBSPNode (void *node, FRenderState& state)
|
|||
// No need for clipping inside frustum if no fog of war (How is this faster!)
|
||||
void HWDrawInfo::RenderOrthoNoFog(FRenderState& state)
|
||||
{
|
||||
if (Viewpoint.IsOrtho() && ((Level->flags3 & LEVEL3_NOFOGOFWAR) || !r_radarclipper))
|
||||
if (Viewpoint.bDoOrtho && ((Level->flags3 & LEVEL3_NOFOGOFWAR) || !r_radarclipper))
|
||||
{
|
||||
double vxdbl = Viewpoint.OffPos.X;
|
||||
double vydbl = Viewpoint.OffPos.Y;
|
||||
|
|
@ -1042,7 +1044,7 @@ void HWDrawInfo::RenderBSP(void *node, bool drawpsprites, FRenderState& state)
|
|||
// Give the DrawInfo the viewpoint in fixed point because that's what the nodes are.
|
||||
viewx = FLOAT2FIXED(Viewpoint.Pos.X);
|
||||
viewy = FLOAT2FIXED(Viewpoint.Pos.Y);
|
||||
if (r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR) && Viewpoint.IsAllowedOoB())
|
||||
if (r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR) && Viewpoint.bDoOob)
|
||||
{
|
||||
viewx = FLOAT2FIXED(Viewpoint.OffPos.X);
|
||||
viewy = FLOAT2FIXED(Viewpoint.OffPos.Y);
|
||||
|
|
@ -1068,7 +1070,7 @@ void HWDrawInfo::RenderBSP(void *node, bool drawpsprites, FRenderState& state)
|
|||
auto future = renderPool.push([&](int id) {
|
||||
WorkerThread();
|
||||
});
|
||||
if (Viewpoint.IsOrtho() && ((Level->flags3 & LEVEL3_NOFOGOFWAR) || !r_radarclipper)) RenderOrthoNoFog(state);
|
||||
if (Viewpoint.bDoOrtho && ((Level->flags3 & LEVEL3_NOFOGOFWAR) || !r_radarclipper)) RenderOrthoNoFog(state);
|
||||
else RenderBSPNode(node, state);
|
||||
|
||||
jobQueue.AddJob(RenderJob::TerminateJob, nullptr, nullptr);
|
||||
|
|
@ -1079,7 +1081,7 @@ void HWDrawInfo::RenderBSP(void *node, bool drawpsprites, FRenderState& state)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (Viewpoint.IsOrtho() && ((Level->flags3 & LEVEL3_NOFOGOFWAR) || !r_radarclipper)) RenderOrthoNoFog(state);
|
||||
if (Viewpoint.bDoOrtho && ((Level->flags3 & LEVEL3_NOFOGOFWAR) || !r_radarclipper)) RenderOrthoNoFog(state);
|
||||
else RenderBSPNode(node, state);
|
||||
Bsp.Unclock();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ angle_t Clipper::PointToPseudoAngle(double x, double y)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
else if (!amRadar && viewpoint->IsOrtho())
|
||||
else if (!amRadar && viewpoint->bDoOrtho)
|
||||
{
|
||||
return PointToPseudoOrthoAngle(x, y);
|
||||
}
|
||||
|
|
@ -424,7 +424,7 @@ angle_t Clipper::PointToPseudoPitch(double x, double y, double z)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
else if (viewpoint->IsOrtho())
|
||||
else if (viewpoint->bDoOrtho)
|
||||
{
|
||||
return PointToPseudoOrthoPitch(x, y, z);
|
||||
}
|
||||
|
|
@ -538,7 +538,7 @@ bool Clipper::CheckBox(const float *bspcoord)
|
|||
angle1 = PointToPseudoAngle (bspcoord[check[0]], bspcoord[check[1]]);
|
||||
angle2 = PointToPseudoAngle (bspcoord[check[2]], bspcoord[check[3]]);
|
||||
|
||||
if (vp->IsOrtho())
|
||||
if (vp->bDoOrtho)
|
||||
{
|
||||
if (angle2 != angle1) return true;
|
||||
switch (boxpos) // Check if the closer corner is poking into the view area
|
||||
|
|
@ -563,7 +563,7 @@ bool Clipper::CheckBoxOrthoPitch(const float *bspcoord)
|
|||
{
|
||||
angle_t pitchmin, pitchmax;
|
||||
auto &vp = viewpoint;
|
||||
if (!vp->IsOrtho()) return true;
|
||||
if (!vp->bDoOrtho) return true;
|
||||
|
||||
angle_t pitchtemp;
|
||||
double padding = 1.0/viewpoint->ScreenProj/viewpoint->PitchCos;
|
||||
|
|
|
|||
|
|
@ -762,7 +762,7 @@ int HWDecalCreateInfo::SetupLights(HWDrawInfo* di, FRenderState& state, FDynLigh
|
|||
p.Set(normal, -normal.X * glseg.x1 - normal.Z * glseg.y1);
|
||||
|
||||
// Iterate through all dynamic lights which touch this wall and render them
|
||||
auto wallLightList = di->Level->lightlists.wall_dlist.CheckKey(side);
|
||||
auto wallLightList = di->Level->lightlists.flat_dlist.SSize() > side->Index() ? &di->Level->lightlists.wall_dlist[side->Index()] : nullptr;
|
||||
|
||||
if (wallLightList)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ void HWDrawInfo::ClearBuffers()
|
|||
void HWDrawInfo::UpdateCurrentMapSection()
|
||||
{
|
||||
int mapsection = Level->PointInRenderSubsector(Viewpoint.Pos)->mapsection;
|
||||
if (Viewpoint.IsAllowedOoB() || Viewpoint.IsOrtho())
|
||||
if (Viewpoint.bDoOob || Viewpoint.bDoOrtho)
|
||||
mapsection = Level->PointInRenderSubsector(Viewpoint.OffPos)->mapsection;
|
||||
CurrentMapSections.Set(mapsection);
|
||||
}
|
||||
|
|
@ -259,8 +259,8 @@ void HWDrawInfo::SetViewArea()
|
|||
auto &vp = Viewpoint;
|
||||
// The render_sector is better suited to represent the current position in GL
|
||||
vp.sector = Level->PointInRenderSubsector(vp.Pos)->render_sector;
|
||||
if (Viewpoint.IsAllowedOoB())
|
||||
vp.sector = Level->PointInRenderSubsector(vp.camera->Pos())->render_sector;
|
||||
if (Viewpoint.bDoOob)
|
||||
vp.sector = Level->PointInRenderSubsector(vp.camera->Pos())->render_sector;
|
||||
|
||||
// Get the heightsec state from the render sector, not the current one!
|
||||
if (vp.sector->GetHeightSec())
|
||||
|
|
@ -359,7 +359,7 @@ angle_t OoBFrustumAngle(FRenderViewpoint* Viewpoint)
|
|||
|
||||
angle_t HWDrawInfo::FrustumAngle()
|
||||
{
|
||||
if (Viewpoint.IsAllowedOoB())
|
||||
if (Viewpoint.bDoOob)
|
||||
{
|
||||
return OoBFrustumAngle(&Viewpoint);
|
||||
}
|
||||
|
|
@ -610,7 +610,7 @@ void HWDrawInfo::CreateScene(bool drawpsprites, FRenderState& state)
|
|||
angle_t a1 = FrustumAngle();
|
||||
mClipper->SafeAddClipRangeRealAngles(vp.Angles.Yaw.BAMs() + a1, vp.Angles.Yaw.BAMs() - a1);
|
||||
Viewpoint.FrustAngle = a1;
|
||||
if (Viewpoint.IsAllowedOoB()) // No need for vertical clipper if viewpoint not allowed out of bounds
|
||||
if (Viewpoint.bDoOob) // No need for vertical clipper if viewpoint not allowed out of bounds
|
||||
{
|
||||
double a2 = 20.0 + 0.5*Viewpoint.FieldOfView.Degrees(); // FrustumPitch for vertical clipping
|
||||
if (a2 > 179.0) a2 = 179.0;
|
||||
|
|
@ -1253,7 +1253,7 @@ void HWDrawInfo::SetDitherTransFlags(AActor* actor)
|
|||
double horiy = Viewpoint.Cos * actor->radius;
|
||||
DVector3 actorpos = actor->Pos();
|
||||
DVector3 vvec = actorpos - Viewpoint.Pos;
|
||||
if (Viewpoint.IsOrtho())
|
||||
if (Viewpoint.bDoOrtho)
|
||||
{
|
||||
vvec = 5.0 * Viewpoint.camera->ViewPos->Offset.Length() * Viewpoint.ViewVector3D; // Should be 4.0? (since zNear is behind screen by 3*dist in VREyeInfo::GetProjection())
|
||||
}
|
||||
|
|
@ -1448,7 +1448,7 @@ void HWDrawInfo::DrawScene(int drawmode, FRenderState& state)
|
|||
{
|
||||
ssao_portals_available = gl_ssao_portals;
|
||||
applySSAO = true;
|
||||
if (r_dithertransparency && vp.IsAllowedOoB())
|
||||
if (r_dithertransparency && vp.bDoOob)
|
||||
{
|
||||
if (vp.camera->tracer)
|
||||
SetDitherTransFlags(vp.camera->tracer);
|
||||
|
|
@ -1526,7 +1526,7 @@ void HWDrawInfo::ProcessScene(bool toscreen, FRenderState& state)
|
|||
drawctx->portalState.BeginScene();
|
||||
|
||||
int mapsection = Level->PointInRenderSubsector(Viewpoint.Pos)->mapsection;
|
||||
if (Viewpoint.IsAllowedOoB() || Viewpoint.IsOrtho())
|
||||
if (Viewpoint.bDoOob || Viewpoint.bDoOrtho)
|
||||
mapsection = Level->PointInRenderSubsector(Viewpoint.OffPos)->mapsection;
|
||||
CurrentMapSections.Set(mapsection);
|
||||
DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN, state);
|
||||
|
|
|
|||
|
|
@ -176,11 +176,9 @@ void HWFlat::SetupLights(HWFlatDispatcher *di, FRenderState& state, FDynLightDat
|
|||
return; // no lights on additively blended surfaces.
|
||||
}
|
||||
|
||||
auto flatLightList = di->Level->lightlists.flat_dlist.CheckKey(section);
|
||||
|
||||
if (flatLightList)
|
||||
if (di->Level->lightlists.flat_dlist.SSize() > section->Index())
|
||||
{
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(*flatLightList);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(di->Level->lightlists.flat_dlist[section->Index()]);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
|
|
@ -579,7 +577,7 @@ void HWFlat::ProcessSector(HWFlatDispatcher *di, FRenderState& state, sector_t *
|
|||
//
|
||||
//
|
||||
//
|
||||
if ((which & SSRF_RENDERFLOOR) && ((di->di && vp->IsOrtho()) ? vp->ViewVector3D.dot(frontsector->floorplane.Normal()) < 0.0 : (!di->di || (frontsector->floorplane.ZatPoint(vp->Pos) <= vp->Pos.Z))) && (!section || !(section->flags & FSection::DONTRENDERFLOOR)))
|
||||
if ((which & SSRF_RENDERFLOOR) && (vp && vp->bDoOrtho ? vp->ViewVector3D.dot(frontsector->floorplane.Normal()) < 0.0 : (!vp || frontsector->floorplane.ZatPoint(vp->Pos) <= vp->Pos.Z)) && (!section || !(section->flags & FSection::DONTRENDERFLOOR)))
|
||||
{
|
||||
// process the original floor first.
|
||||
|
||||
|
|
@ -637,7 +635,7 @@ void HWFlat::ProcessSector(HWFlatDispatcher *di, FRenderState& state, sector_t *
|
|||
//
|
||||
//
|
||||
//
|
||||
if ((which & SSRF_RENDERCEILING) && ((di->di && vp->IsOrtho()) ? vp->ViewVector3D.dot(frontsector->ceilingplane.Normal()) < 0.0 : (!di->di || (frontsector->ceilingplane.ZatPoint(vp->Pos) >= vp->Pos.Z))) && (!section || !(section->flags & FSection::DONTRENDERCEILING)))
|
||||
if ((which & SSRF_RENDERCEILING) && (vp && vp->bDoOrtho ? vp->ViewVector3D.dot(frontsector->ceilingplane.Normal()) < 0.0 : !vp || frontsector->ceilingplane.ZatPoint(vp->Pos) >= vp->Pos.Z) && (!section || !(section->flags & FSection::DONTRENDERCEILING)))
|
||||
{
|
||||
// process the original ceiling first.
|
||||
|
||||
|
|
@ -722,7 +720,7 @@ void HWFlat::ProcessSector(HWFlatDispatcher *di, FRenderState& state, sector_t *
|
|||
double ff_top = rover->top.plane->ZatPoint(sector->centerspot);
|
||||
if (ff_top < lastceilingheight)
|
||||
{
|
||||
if (!di->di || (vp->IsOrtho() ? vp->ViewVector3D.dot(rover->top.plane->Normal()) > 0.0 : vp->Pos.Z <= rover->top.plane->ZatPoint(vp->Pos)))
|
||||
if (!vp || ((vp->bDoOrtho ? vp->ViewVector3D.dot(rover->top.plane->Normal()) > 0.0 : vp->Pos.Z <= rover->top.plane->ZatPoint(vp->Pos))))
|
||||
{
|
||||
SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
|
||||
Colormap.FadeColor = frontsector->Colormap.FadeColor;
|
||||
|
|
@ -736,7 +734,7 @@ void HWFlat::ProcessSector(HWFlatDispatcher *di, FRenderState& state, sector_t *
|
|||
double ff_bottom = rover->bottom.plane->ZatPoint(sector->centerspot);
|
||||
if (ff_bottom < lastceilingheight)
|
||||
{
|
||||
if (!di->di || (vp->IsOrtho() ? vp->ViewVector3D.dot(rover->bottom.plane->Normal()) > 0.0 : vp->Pos.Z <= rover->bottom.plane->ZatPoint(vp->Pos)))
|
||||
if (!vp || (vp->bDoOrtho ? vp->ViewVector3D.dot(rover->bottom.plane->Normal()) > 0.0 : vp->Pos.Z <= rover->bottom.plane->ZatPoint(vp->Pos)))
|
||||
{
|
||||
SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
|
||||
Colormap.FadeColor = frontsector->Colormap.FadeColor;
|
||||
|
|
@ -762,7 +760,7 @@ void HWFlat::ProcessSector(HWFlatDispatcher *di, FRenderState& state, sector_t *
|
|||
double ff_bottom = rover->bottom.plane->ZatPoint(sector->centerspot);
|
||||
if (ff_bottom > lastfloorheight || (rover->flags&FF_FIX))
|
||||
{
|
||||
if (!di->di || (vp->IsOrtho() ? vp->ViewVector3D.dot(rover->bottom.plane->Normal()) > 0.0 : vp->Pos.Z >= rover->bottom.plane->ZatPoint(vp->Pos)))
|
||||
if (!vp || (vp->bDoOrtho ? vp->ViewVector3D.dot(rover->bottom.plane->Normal()) > 0.0 : vp->Pos.Z >= rover->bottom.plane->ZatPoint(vp->Pos)))
|
||||
{
|
||||
SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
|
||||
Colormap.FadeColor = frontsector->Colormap.FadeColor;
|
||||
|
|
@ -783,7 +781,7 @@ void HWFlat::ProcessSector(HWFlatDispatcher *di, FRenderState& state, sector_t *
|
|||
double ff_top = rover->top.plane->ZatPoint(sector->centerspot);
|
||||
if (ff_top > lastfloorheight)
|
||||
{
|
||||
if (!di->di || (vp->IsOrtho() ? vp->ViewVector3D.dot(rover->top.plane->Normal()) > 0.0 : vp->Pos.Z >= rover->top.plane->ZatPoint(vp->Pos)))
|
||||
if (!vp || (vp->bDoOrtho ? vp->ViewVector3D.dot(rover->top.plane->Normal()) > 0.0 : vp->Pos.Z >= rover->top.plane->ZatPoint(vp->Pos)))
|
||||
{
|
||||
SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
|
||||
Colormap.FadeColor = frontsector->Colormap.FadeColor;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ bool FPortalSceneState::RenderFirstSkyPortal(int recursion, HWDrawInfo *outer_di
|
|||
{
|
||||
HWPortal * best = nullptr;
|
||||
unsigned bestindex = 0;
|
||||
bool usestencil = outer_di->Viewpoint.IsAllowedOoB();
|
||||
bool usestencil = outer_di->Viewpoint.bDoOob;
|
||||
|
||||
// Find the one with the highest amount of lines.
|
||||
// Normally this is also the one that saves the largest amount
|
||||
|
|
@ -504,7 +504,7 @@ bool HWMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe
|
|||
}
|
||||
|
||||
auto &vp = di->Viewpoint;
|
||||
state->vpIsAllowedOoB = vp.IsAllowedOoB();
|
||||
state->vpIsAllowedOoB = vp.bDoOob;
|
||||
di->UpdateCurrentMapSection();
|
||||
|
||||
di->mClipPortal = this;
|
||||
|
|
@ -573,7 +573,7 @@ bool HWMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe
|
|||
angle_t af = di->FrustumAngle();
|
||||
if (af < ANGLE_180) clipper->SafeAddClipRangeRealAngles(vp.Angles.Yaw.BAMs() + af, vp.Angles.Yaw.BAMs() - af);
|
||||
|
||||
if (!di->Viewpoint.IsAllowedOoB())
|
||||
if(!di->Viewpoint.bDoOob)
|
||||
clipper->SafeAddClipRange(linedef->v1, linedef->v2);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -609,7 +609,7 @@ bool HWLineToLinePortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *cl
|
|||
return false;
|
||||
}
|
||||
auto &vp = di->Viewpoint;
|
||||
state->vpIsAllowedOoB = vp.IsAllowedOoB();
|
||||
state->vpIsAllowedOoB = vp.bDoOob;
|
||||
di->mClipPortal = this;
|
||||
|
||||
line_t *origin = glport->lines[0]->mOrigin;
|
||||
|
|
@ -689,7 +689,7 @@ bool HWSkyboxPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe
|
|||
return false;
|
||||
}
|
||||
auto &vp = di->Viewpoint;
|
||||
state->vpIsAllowedOoB = vp.IsAllowedOoB();
|
||||
state->vpIsAllowedOoB = vp.bDoOob;
|
||||
|
||||
state->skyboxrecursion++;
|
||||
state->PlaneMirrorMode = 0;
|
||||
|
|
@ -801,7 +801,7 @@ bool HWSectorStackPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *c
|
|||
|
||||
FSectorPortalGroup *portal = origin;
|
||||
auto &vp = di->Viewpoint;
|
||||
state->vpIsAllowedOoB = vp.IsAllowedOoB();
|
||||
state->vpIsAllowedOoB = vp.bDoOob;
|
||||
|
||||
vp.Pos += origin->mDisplacement;
|
||||
vp.ActorPos += origin->mDisplacement;
|
||||
|
|
@ -810,7 +810,7 @@ bool HWSectorStackPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *c
|
|||
|
||||
// avoid recursions!
|
||||
if (origin->plane != -1) screen->instack[origin->plane]++;
|
||||
if (vp.IsAllowedOoB() && lines.Size() > 0)
|
||||
if (vp.bDoOob && lines.Size() > 0)
|
||||
{
|
||||
flat.plane.GetFromSector(lines[0].sub->sector, origin->plane);
|
||||
di->SetClipHeight(flat.plane.plane.ZatPoint(vp.Pos),
|
||||
|
|
@ -823,7 +823,7 @@ bool HWSectorStackPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *c
|
|||
// If the viewpoint is not within the portal, we need to invalidate the entire clip area.
|
||||
// The portal will re-validate the necessary parts when its subsectors get traversed.
|
||||
subsector_t *sub = di->Level->PointInRenderSubsector(vp.Pos);
|
||||
if (vp.IsAllowedOoB()) sub = di->Level->PointInRenderSubsector(vp.OffPos);
|
||||
if (vp.bDoOob) sub = di->Level->PointInRenderSubsector(vp.OffPos);
|
||||
if (!(di->ss_renderflags[sub->Index()] & SSRF_SEEN))
|
||||
{
|
||||
clipper->SafeAddClipRange(0, ANGLE_MAX);
|
||||
|
|
@ -891,7 +891,7 @@ bool HWPlaneMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *c
|
|||
std::swap(screen->instack[sector_t::floor], screen->instack[sector_t::ceiling]);
|
||||
|
||||
auto &vp = di->Viewpoint;
|
||||
state->vpIsAllowedOoB = vp.IsAllowedOoB();
|
||||
state->vpIsAllowedOoB = vp.bDoOob;
|
||||
old_pm = state->PlaneMirrorMode;
|
||||
|
||||
// the player is always visible in a mirror.
|
||||
|
|
@ -947,6 +947,8 @@ void HWPlaneMirrorPortal::Shutdown(HWDrawInfo *di, FRenderState &rstate)
|
|||
|
||||
const char *HWPlaneMirrorPortal::GetName() { return origin->fC() < 0? "Planemirror ceiling" : "Planemirror floor"; }
|
||||
|
||||
int HWPlaneMirrorPortal::GetMirrorSide() const { return origin->fC() < 0 ? -1 : 1; };
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ public:
|
|||
{
|
||||
}
|
||||
virtual ~HWPortal() {}
|
||||
virtual int GetMirrorSide() const { return 0; };
|
||||
virtual int ClipSeg(seg_t *seg, const DVector3 &viewpos) { return PClip_Inside; }
|
||||
virtual int ClipSubsector(subsector_t *sub) { return PClip_Inside; }
|
||||
virtual int ClipPoint(const DVector2 &pos) { return PClip_Inside; }
|
||||
|
|
@ -148,7 +149,7 @@ public:
|
|||
virtual bool NeedDepthBuffer() { return true; }
|
||||
virtual void DrawContents(HWDrawInfo *di, FRenderState &state)
|
||||
{
|
||||
if (Setup(di, state, (di->Viewpoint.IsAllowedOoB() ? di->rClipper : di->mClipper)))
|
||||
if (Setup(di, state, (di->Viewpoint.bDoOob ? di->rClipper : di->mClipper)))
|
||||
{
|
||||
di->DrawScene(DM_PORTAL, state);
|
||||
Shutdown(di, state);
|
||||
|
|
@ -304,6 +305,8 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
int GetMirrorSide() const override;
|
||||
|
||||
HWPlaneMirrorPortal(FPortalSceneState *state, secplane_t * pt) : HWScenePortalBase(state)
|
||||
{
|
||||
origin = pt;
|
||||
|
|
|
|||
|
|
@ -121,11 +121,9 @@ int HWDrawInfo::SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &light
|
|||
|
||||
lightdata.Clear();
|
||||
|
||||
auto flatLightList = Level->lightlists.flat_dlist.CheckKey(sub->section);
|
||||
|
||||
if (flatLightList)
|
||||
if (Level->lightlists.flat_dlist.SSize() > sub->section->Index())
|
||||
{
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(*flatLightList);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(Level->lightlists.flat_dlist[sub->section->Index()]);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -157,10 +157,10 @@ void HWWall::SkyPlane(HWWallDispatcher *di, FRenderState& state, sector_t *secto
|
|||
case PORTS_PORTAL:
|
||||
case PORTS_LINKEDPORTAL:
|
||||
{
|
||||
if (di->di && di->di->Viewpoint.IsAllowedOoB())
|
||||
if (di->di && di->di->Viewpoint.bDoOob)
|
||||
{
|
||||
secplane_t myplane = plane ? sector->ceilingplane : sector->floorplane;
|
||||
if (di->di->Viewpoint.IsOrtho() && di->di->Viewpoint.ViewVector3D.dot(myplane.Normal()) > 0.0) return;
|
||||
if (di->di->Viewpoint.bDoOrtho && di->di->Viewpoint.ViewVector3D.dot(myplane.Normal()) > 0.0) return;
|
||||
else if (plane==1 && di->di->Viewpoint.Pos.Z >= myplane.ZatPoint(di->di->Viewpoint.Pos)) return;
|
||||
else if (plane==0 && di->di->Viewpoint.Pos.Z <= myplane.ZatPoint(di->di->Viewpoint.Pos)) return;
|
||||
}
|
||||
|
|
@ -323,7 +323,7 @@ void HWWall::SkyTop(HWWallDispatcher *di, FRenderState& state, seg_t * seg,secto
|
|||
// if (backreflect > 0 && bs->ceilingplane.fD() == fs->ceilingplane.fD() && !bs->isClosed())
|
||||
// {
|
||||
// Don't add intra-portal line to the portal.
|
||||
// if (!(di->di && di->di->Viewpoint.IsAllowedOoB()))
|
||||
// if (!(di->di && di->di->Viewpoint.bDoOob))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
|
@ -406,7 +406,7 @@ void HWWall::SkyBottom(HWWallDispatcher *di, FRenderState& state, seg_t * seg,se
|
|||
// if (backreflect > 0 && bs->floorplane.fD() == fs->floorplane.fD() && !bs->isClosed())
|
||||
// {
|
||||
// // Don't add intra-portal line to the portal.
|
||||
// if (!(di->di && di->di->Viewpoint.IsAllowedOoB()))
|
||||
// if (!(di->di && di->di->Viewpoint.bDoOob))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -158,12 +158,10 @@ void HWDrawInfo::GetDynSpriteLight(AActor* self, sun_trace_cache_t* traceCache,
|
|||
}
|
||||
|
||||
// Go through both light lists
|
||||
auto flatLightList = Level->lightlists.flat_dlist.CheckKey(sec);
|
||||
|
||||
if (flatLightList)
|
||||
if (Level->lightlists.flat_dlist.SSize() > sec->Index())
|
||||
{
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>::Iterator it(*flatLightList);
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>::Pair* pair;
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(Level->lightlists.flat_dlist[sec->Index()]);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
auto node = pair->Value.get();
|
||||
|
|
@ -312,11 +310,10 @@ void HWDrawInfo::GetDynSpriteLightList(AActor *self, double x, double y, double
|
|||
auto section = subsector->section;
|
||||
if (section->validcount == dl_validcount) return; // already done from a previous subsector.
|
||||
|
||||
auto flatLightList = level.lightlists.flat_dlist.CheckKey(subsector->section);
|
||||
if (flatLightList)
|
||||
if (level.lightlists.flat_dlist.SSize() > subsector->section->Index())
|
||||
{
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>::Iterator it(*flatLightList);
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>::Pair* pair;
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(level.lightlists.flat_dlist[subsector->section->Index()]);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{ // check all lights touching a subsector
|
||||
auto node = pair->Value.get();
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp)
|
|||
mat.Translate(-center.X, -center.Z, -center.Y);
|
||||
}
|
||||
|
||||
if (actor && (actor->renderflags2 & RF2_ISOMETRICSPRITES) && di->Viewpoint.IsOrtho())
|
||||
if (actor && (actor->renderflags2 & RF2_ISOMETRICSPRITES) && di->Viewpoint.bDoOrtho)
|
||||
{
|
||||
float angleRad = (FAngle::fromDeg(270.) - HWAngles.Yaw).Radians();
|
||||
mat.Translate(center.X, center.Z, center.Y);
|
||||
|
|
@ -1063,7 +1063,7 @@ void HWSprite::Process(HWDrawInfo *di, FRenderState& state, AActor* thing, secto
|
|||
bool mirror = false;
|
||||
bool backfaced = false;
|
||||
DAngle ang = (thingpos - vp.Pos).Angle();
|
||||
if (di->Viewpoint.IsOrtho()) ang = vp.Angles.Yaw;
|
||||
if (di->Viewpoint.bDoOrtho) ang = vp.Angles.Yaw;
|
||||
else if (actor && thing->renderflags2 & RF2_ANGLEDROLL)
|
||||
{
|
||||
Matrix3x4 rolltilt;
|
||||
|
|
|
|||
|
|
@ -430,11 +430,9 @@ void HWWall::SetupLights(HWDrawInfo*di, FRenderState& state, FDynLightData &ligh
|
|||
if ((seg->sidedef->Flags & WALLF_POLYOBJ) && sub)
|
||||
{
|
||||
// Polobject segs cannot be checked per sidedef so use the subsector instead.
|
||||
auto flatLightList = di->Level->lightlists.flat_dlist.CheckKey(sub->section);
|
||||
|
||||
if (flatLightList)
|
||||
if (di->Level->lightlists.flat_dlist.SSize() > sub->section->Index())
|
||||
{
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(*flatLightList);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(di->Level->lightlists.flat_dlist[sub->section->Index()]);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
|
|
@ -495,11 +493,9 @@ void HWWall::SetupLights(HWDrawInfo*di, FRenderState& state, FDynLightData &ligh
|
|||
}
|
||||
else
|
||||
{
|
||||
auto wallLightList = di->Level->lightlists.wall_dlist.CheckKey(seg->sidedef);
|
||||
|
||||
if (wallLightList)
|
||||
if (di->Level->lightlists.wall_dlist.SSize() > seg->sidedef->Index())
|
||||
{
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(*wallLightList);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(di->Level->lightlists.wall_dlist[seg->sidedef->Index()]);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
|
|
@ -694,7 +690,7 @@ void HWWall::PutPortal(HWWallDispatcher *di, FRenderState& state, int ptype, int
|
|||
break;
|
||||
|
||||
case PORTALTYPE_PLANEMIRROR:
|
||||
if (ddi->Viewpoint.IsOrtho() ? (ddi->Viewpoint.ViewVector3D.dot(planemirror->Normal()) < 0)
|
||||
if (ddi->Viewpoint.bDoOrtho ? (ddi->Viewpoint.ViewVector3D.dot(planemirror->Normal()) < 0)
|
||||
: (ddi->drawctx->portalState.PlaneMirrorMode * planemirror->fC() <= 0))
|
||||
{
|
||||
planemirror = ddi->drawctx->portalState.UniquePlaneMirrors.Get(planemirror);
|
||||
|
|
|
|||
|
|
@ -550,7 +550,7 @@ void R_InterpolateView(FRenderViewpoint& viewPoint, const player_t* const player
|
|||
const int prevPortalGroup = viewLvl->PointInRenderSubsector(iView->Old.Pos)->sector->PortalGroup;
|
||||
const int curPortalGroup = viewLvl->PointInRenderSubsector(iView->New.Pos)->sector->PortalGroup;
|
||||
|
||||
if (viewPoint.IsAllowedOoB() && prevPortalGroup != curPortalGroup) viewPoint.Pos = iView->New.Pos;
|
||||
if (viewPoint.bDoOob && prevPortalGroup != curPortalGroup) viewPoint.Pos = iView->New.Pos;
|
||||
else
|
||||
{
|
||||
const DVector2 portalOffset = viewLvl->Displacements.getOffset(prevPortalGroup, curPortalGroup);
|
||||
|
|
@ -567,7 +567,7 @@ void R_InterpolateView(FRenderViewpoint& viewPoint, const player_t* const player
|
|||
|
||||
// Due to interpolation this is not necessarily the same as the sector the camera is in.
|
||||
viewPoint.sector = viewLvl->PointInRenderSubsector(viewPoint.Pos)->sector;
|
||||
if (!viewPoint.IsAllowedOoB() || !V_IsHardwareRenderer())
|
||||
if (!viewPoint.bDoOob || !V_IsHardwareRenderer())
|
||||
{
|
||||
bool moved = false;
|
||||
while (!viewPoint.sector->PortalBlocksMovement(sector_t::ceiling))
|
||||
|
|
@ -712,7 +712,7 @@ void FRenderViewpoint::SetViewAngle(const FViewWindow& viewWindow)
|
|||
ViewVector3D.Y = v.Y * PitchCos;
|
||||
ViewVector3D.Z = -PitchSin;
|
||||
|
||||
if (IsOrtho() || IsAllowedOoB()) // These auto-ensure that camera and camera->ViewPos exist
|
||||
if (bDoOrtho || bDoOob) // These auto-ensure that camera and camera->ViewPos exist
|
||||
{
|
||||
if (camera->tracer != NULL)
|
||||
{
|
||||
|
|
@ -724,7 +724,7 @@ void FRenderViewpoint::SetViewAngle(const FViewWindow& viewWindow)
|
|||
}
|
||||
}
|
||||
|
||||
if (IsOrtho() && (camera->ViewPos->Offset.XY().Length() > 0.0))
|
||||
if (bDoOrtho && (camera->ViewPos->Offset.XY().Length() > 0.0))
|
||||
{
|
||||
ScreenProj = 1.34396 / camera->ViewPos->Offset.Length() / tan (FieldOfView.Radians()*0.5); // [DVR] Estimated. +/-1 should be top/bottom of screen.
|
||||
ScreenProjX = ScreenProj * 0.5 / viewWindow.WidescreenRatio;
|
||||
|
|
@ -953,6 +953,9 @@ void R_SetupFrame(FRenderViewpoint& viewPoint, const FViewWindow& viewWindow, AA
|
|||
if (viewPoint.camera == nullptr)
|
||||
I_Error("You lost your body. Bad dehacked work is likely to blame.");
|
||||
|
||||
viewPoint.bDoOob = viewPoint.IsAllowedOoB();
|
||||
viewPoint.bDoOrtho = viewPoint.IsOrtho();
|
||||
|
||||
InterpolationViewer* const iView = FindPastViewer(viewPoint.camera);
|
||||
// Always reset these back to zero.
|
||||
iView->ViewOffset.Zero();
|
||||
|
|
@ -1136,14 +1139,14 @@ void R_SetupFrame(FRenderViewpoint& viewPoint, const FViewWindow& viewWindow, AA
|
|||
|
||||
// Keep the view within the sector's floor and ceiling
|
||||
// But allow VPSF_ALLOWOUTOFBOUNDS camera viewpoints to go out of bounds when using hardware renderer
|
||||
if (viewPoint.sector->PortalBlocksMovement(sector_t::ceiling) && (!viewPoint.IsAllowedOoB() || !V_IsHardwareRenderer()))
|
||||
if (viewPoint.sector->PortalBlocksMovement(sector_t::ceiling) && (!viewPoint.bDoOob || !V_IsHardwareRenderer()))
|
||||
{
|
||||
const double z = viewPoint.sector->ceilingplane.ZatPoint(viewPoint.Pos) - 4.0;
|
||||
if (viewPoint.Pos.Z > z)
|
||||
viewPoint.Pos.Z = z;
|
||||
}
|
||||
|
||||
if (viewPoint.sector->PortalBlocksMovement(sector_t::floor) && (!viewPoint.IsAllowedOoB() || !V_IsHardwareRenderer()))
|
||||
if (viewPoint.sector->PortalBlocksMovement(sector_t::floor) && (!viewPoint.bDoOob || !V_IsHardwareRenderer()))
|
||||
{
|
||||
const double z = viewPoint.sector->floorplane.ZatPoint(viewPoint.Pos) + 4.0;
|
||||
if (viewPoint.Pos.Z < z)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ struct FRenderViewpoint
|
|||
int extralight; // extralight to be added to this viewpoint
|
||||
bool showviewer; // show the camera actor?
|
||||
bool bForceNoViewer; // Never show the camera Actor.
|
||||
bool bDoOob;
|
||||
bool bDoOrtho;
|
||||
void SetViewAngle(const FViewWindow& viewWindow);
|
||||
bool IsAllowedOoB(); // Checks if camera actor exists, has viewpos, and viewpos has VPSF_ALLOWOUTOFBOUNDS flag set
|
||||
bool IsOrtho(); // Checks if camera actor exists, has viewpos, and viewpos has VPSF_ORTHOGRAPHIC flag set
|
||||
|
|
|
|||
|
|
@ -241,46 +241,48 @@ namespace swrenderer
|
|||
|
||||
drawerargs.dc_num_lights = 0;
|
||||
|
||||
// Setup lights for column
|
||||
FLightNode* cur_node = drawerargs.LightList();
|
||||
while (cur_node)
|
||||
if(drawerargs.LightList())
|
||||
{
|
||||
if (cur_node->lightsource->IsActive())
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(*drawerargs.LightList());
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
double lightX = cur_node->lightsource->X() - wallargs.ViewpointPos.X;
|
||||
double lightY = cur_node->lightsource->Y() - wallargs.ViewpointPos.Y;
|
||||
double lightZ = cur_node->lightsource->Z() - wallargs.ViewpointPos.Z;
|
||||
|
||||
float lx = (float)(lightX * wallargs.Sin - lightY * wallargs.Cos) - drawerargs.dc_viewpos.X;
|
||||
float ly = (float)(lightX * wallargs.TanCos + lightY * wallargs.TanSin) - drawerargs.dc_viewpos.Y;
|
||||
float lz = (float)lightZ;
|
||||
|
||||
// Precalculate the constant part of the dot here so the drawer doesn't have to.
|
||||
bool is_point_light = cur_node->lightsource->IsAttenuated();
|
||||
float lconstant = lx * lx + ly * ly;
|
||||
float nlconstant = is_point_light ? lx * drawerargs.dc_normal.X + ly * drawerargs.dc_normal.Y : 0.0f;
|
||||
|
||||
// Include light only if it touches this column
|
||||
float radius = cur_node->lightsource->GetRadius();
|
||||
if (radius * radius >= lconstant && nlconstant >= 0.0f)
|
||||
auto cur_node = pair->Value.get();
|
||||
if (cur_node->lightsource->IsActive())
|
||||
{
|
||||
uint32_t red = cur_node->lightsource->GetRed();
|
||||
uint32_t green = cur_node->lightsource->GetGreen();
|
||||
uint32_t blue = cur_node->lightsource->GetBlue();
|
||||
double lightX = cur_node->lightsource->X() - wallargs.ViewpointPos.X;
|
||||
double lightY = cur_node->lightsource->Y() - wallargs.ViewpointPos.Y;
|
||||
double lightZ = cur_node->lightsource->Z() - wallargs.ViewpointPos.Z;
|
||||
|
||||
auto& light = drawerargs.dc_lights[drawerargs.dc_num_lights++];
|
||||
light.x = lconstant;
|
||||
light.y = nlconstant;
|
||||
light.z = lz;
|
||||
light.radius = 256.0f / cur_node->lightsource->GetRadius();
|
||||
light.color = (red << 16) | (green << 8) | blue;
|
||||
float lx = (float)(lightX * wallargs.Sin - lightY * wallargs.Cos) - drawerargs.dc_viewpos.X;
|
||||
float ly = (float)(lightX * wallargs.TanCos + lightY * wallargs.TanSin) - drawerargs.dc_viewpos.Y;
|
||||
float lz = (float)lightZ;
|
||||
|
||||
if (drawerargs.dc_num_lights == WallColumnDrawerArgs::MAX_DRAWER_LIGHTS)
|
||||
break;
|
||||
// Precalculate the constant part of the dot here so the drawer doesn't have to.
|
||||
bool is_point_light = cur_node->lightsource->IsAttenuated();
|
||||
float lconstant = lx * lx + ly * ly;
|
||||
float nlconstant = is_point_light ? lx * drawerargs.dc_normal.X + ly * drawerargs.dc_normal.Y : 0.0f;
|
||||
|
||||
// Include light only if it touches this column
|
||||
float radius = cur_node->lightsource->GetRadius();
|
||||
if (radius * radius >= lconstant && nlconstant >= 0.0f)
|
||||
{
|
||||
uint32_t red = cur_node->lightsource->GetRed();
|
||||
uint32_t green = cur_node->lightsource->GetGreen();
|
||||
uint32_t blue = cur_node->lightsource->GetBlue();
|
||||
|
||||
auto& light = drawerargs.dc_lights[drawerargs.dc_num_lights++];
|
||||
light.x = lconstant;
|
||||
light.y = nlconstant;
|
||||
light.z = lz;
|
||||
light.radius = 256.0f / cur_node->lightsource->GetRadius();
|
||||
light.color = (red << 16) | (green << 8) | blue;
|
||||
|
||||
if (drawerargs.dc_num_lights == WallColumnDrawerArgs::MAX_DRAWER_LIGHTS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_node = cur_node->nextLight;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace swrenderer
|
|||
ShadeConstants ColormapConstants() const { return wallargs->ColormapConstants(); }
|
||||
fixed_t Light() const { return LIGHTSCALE(mLight, mShade); }
|
||||
|
||||
FLightNode* LightList() const { return wallargs->lightlist; }
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>* LightList() const { return wallargs->lightlist; }
|
||||
|
||||
const WallDrawerArgs* wallargs;
|
||||
|
||||
|
|
|
|||
|
|
@ -207,60 +207,23 @@ namespace swrenderer
|
|||
drawerargs.DrawWall(Thread);
|
||||
}
|
||||
|
||||
FLightNode* RenderWallPart::GetLightList()
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>* RenderWallPart::GetLightList()
|
||||
{
|
||||
while (light_list)
|
||||
{
|
||||
// Clear out the wall part light list
|
||||
FLightNode *next = nullptr;
|
||||
if (light_list->nextLight) next = light_list->nextLight;
|
||||
delete light_list;
|
||||
if (next) light_list = next;
|
||||
}
|
||||
|
||||
CameraLight* cameraLight = CameraLight::Instance();
|
||||
if ((cameraLight->FixedLightLevel() >= 0) || cameraLight->FixedColormap())
|
||||
{
|
||||
return nullptr; // [SP] Don't draw dynlights if invul/lightamp active
|
||||
}
|
||||
else if (curline && curline->sidedef)
|
||||
{
|
||||
auto Level = curline->Subsector->sector->Level;
|
||||
auto wallLightList = Level->lightlists.wall_dlist.CheckKey(curline->sidedef);
|
||||
if (wallLightList)
|
||||
|
||||
if (Level->lightlists.wall_dlist.SSize() > curline->sidedef->Index())
|
||||
{
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(*wallLightList);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
auto node = pair->Value.get();
|
||||
if (!node) continue;
|
||||
|
||||
if (node->lightsource->IsActive())
|
||||
{
|
||||
bool found = false;
|
||||
FLightNode *light_node = light_list;
|
||||
while (light_node)
|
||||
{
|
||||
if (light_node->lightsource == node->lightsource)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
light_node = light_node->nextLight;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
FLightNode *newlight = new FLightNode;
|
||||
newlight->nextLight = light_list;
|
||||
newlight->lightsource = node->lightsource;
|
||||
light_list = newlight;
|
||||
}
|
||||
}
|
||||
}
|
||||
return &Level->lightlists.wall_dlist[curline->sidedef->Index()];
|
||||
}
|
||||
|
||||
return light_list;
|
||||
}
|
||||
else
|
||||
return nullptr;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace swrenderer
|
|||
private:
|
||||
void ProcessStripedWall(const short *uwal, const short *dwal, const ProjectedWallTexcoords& texcoords);
|
||||
void ProcessNormalWall(const short *uwal, const short *dwal, const ProjectedWallTexcoords& texcoords);
|
||||
FLightNode* GetLightList();
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>* GetLightList();
|
||||
|
||||
RenderThread* Thread = nullptr;
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ namespace swrenderer
|
|||
|
||||
ProjectedWallLight mLight;
|
||||
|
||||
FLightNode *light_list = nullptr;
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>> *light_list = nullptr;
|
||||
bool mask = false;
|
||||
bool additive = false;
|
||||
fixed_t alpha = 0;
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ namespace swrenderer
|
|||
return; // [SP] no dynlights if invul or lightamp
|
||||
|
||||
auto Level = sec->sector->Level;
|
||||
auto flatLightList = Level->lightlists.flat_dlist.CheckKey(sec);
|
||||
if (flatLightList)
|
||||
|
||||
if (Level->lightlists.flat_dlist.SSize() > sec->Index())
|
||||
{
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(*flatLightList);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(Level->lightlists.flat_dlist[sec->Index()]);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -209,10 +209,10 @@ namespace swrenderer
|
|||
float lit_green = 0;
|
||||
float lit_blue = 0;
|
||||
auto Level = vis->sector->Level;
|
||||
auto flatLightList = Level->lightlists.flat_dlist.CheckKey(vis->section);
|
||||
if (flatLightList)
|
||||
|
||||
if (Level->lightlists.flat_dlist.SSize() > vis->section->Index())
|
||||
{
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(*flatLightList);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Iterator it(Level->lightlists.flat_dlist[vis->section->Index()]);
|
||||
TMap<FDynamicLight *, std::unique_ptr<FLightNode>>::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace swrenderer
|
|||
short* dwal;
|
||||
FWallCoords WallC;
|
||||
ProjectedWallTexcoords texcoords;
|
||||
FLightNode* lightlist = nullptr;
|
||||
TMap<FDynamicLight*, std::unique_ptr<FLightNode>>* lightlist = nullptr;
|
||||
|
||||
float lightpos;
|
||||
float lightstep;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue