Skip to content

Commit c7d25f1

Browse files
dileepvrRicardoLuis0
authored andcommitted
Addressing some small regression by conditioning a few calculations on OoB viewpoints. Branching Frustum calculation to old method.
1 parent 5ba6bd2 commit c7d25f1

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

src/rendering/hwrenderer/scene/hw_bsp.cpp

+16-10
Original file line numberDiff line numberDiff line change
@@ -285,19 +285,25 @@ void HWDrawInfo::AddLine (seg_t *seg, bool portalclip)
285285
angle_t startAngle = clipper.GetClipAngle(seg->v2);
286286
angle_t endAngle = clipper.GetClipAngle(seg->v1);
287287
auto &clipperr = *rClipper;
288-
angle_t startAngleR = clipperr.PointToPseudoAngle(seg->v2->fX(), seg->v2->fY());
289-
angle_t endAngleR = clipperr.PointToPseudoAngle(seg->v1->fX(), seg->v1->fY());
288+
angle_t startAngleR = 0;
289+
angle_t endAngleR = 0;
290290
angle_t paddingR = 0x00200000; // Make radar clipping more aggressive (reveal less)
291291

292-
if(Viewpoint.IsAllowedOoB() && r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR) && (startAngleR - endAngleR >= ANGLE_180))
292+
if(Viewpoint.IsAllowedOoB() && r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR))
293293
{
294-
if (!seg->backsector) clipperr.SafeAddClipRange(startAngleR - paddingR, endAngleR + paddingR);
295-
else if((seg->sidedef != nullptr) && !uint8_t(seg->sidedef->Flags & WALLF_POLYOBJ) && (currentsector->sectornum != seg->backsector->sectornum))
294+
startAngleR = clipperr.PointToPseudoAngle(seg->v2->fX(), seg->v2->fY());
295+
endAngleR = clipperr.PointToPseudoAngle(seg->v1->fX(), seg->v1->fY());
296+
297+
if (startAngleR - endAngleR >= ANGLE_180)
296298
{
297-
if (in_area == area_default) in_area = hw_CheckViewArea(seg->v1, seg->v2, seg->frontsector, seg->backsector);
298-
backsector = hw_FakeFlat(seg->backsector, in_area, true);
299-
if (hw_CheckClip(seg->sidedef, currentsector, backsector)) clipperr.SafeAddClipRange(startAngleR - paddingR, endAngleR + paddingR);
300-
backsector = nullptr;
299+
if (!seg->backsector) clipperr.SafeAddClipRange(startAngleR - paddingR, endAngleR + paddingR);
300+
else if((seg->sidedef != nullptr) && !uint8_t(seg->sidedef->Flags & WALLF_POLYOBJ) && (currentsector->sectornum != seg->backsector->sectornum))
301+
{
302+
if (in_area == area_default) in_area = hw_CheckViewArea(seg->v1, seg->v2, seg->frontsector, seg->backsector);
303+
backsector = hw_FakeFlat(seg->backsector, in_area, true);
304+
if (hw_CheckClip(seg->sidedef, currentsector, backsector)) clipperr.SafeAddClipRange(startAngleR - paddingR, endAngleR + paddingR);
305+
backsector = nullptr;
306+
}
301307
}
302308
}
303309

@@ -708,7 +714,7 @@ void HWDrawInfo::DoSubsector(subsector_t * sub)
708714
if(Viewpoint.IsAllowedOoB() && sector->isSecret() && sector->wasSecret() && !r_radarclipper) return;
709715

710716
// cull everything if subsector outside all relevant clippers
711-
if ((sub->polys == nullptr))
717+
if (Viewpoint.IsAllowedOoB() && (sub->polys == nullptr))
712718
{
713719
auto &clipper = *mClipper;
714720
auto &clipperv = *vClipper;

src/rendering/hwrenderer/scene/hw_drawinfo.cpp

+30-9
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ void HWDrawInfo::ClearBuffers()
268268
void HWDrawInfo::UpdateCurrentMapSection()
269269
{
270270
int mapsection = Level->PointInRenderSubsector(Viewpoint.Pos)->mapsection;
271-
if (Viewpoint.IsAllowedOoB())
272-
mapsection = Level->PointInRenderSubsector(Viewpoint.camera->Pos())->mapsection;
271+
if (Viewpoint.IsAllowedOoB() || Viewpoint.IsOrtho())
272+
mapsection = Level->PointInRenderSubsector(Viewpoint.OffPos)->mapsection;
273273
CurrentMapSections.Set(mapsection);
274274
}
275275

@@ -363,27 +363,48 @@ int HWDrawInfo::SetFullbrightFlags(player_t *player)
363363
//
364364
//-----------------------------------------------------------------------------
365365

366-
angle_t HWDrawInfo::FrustumAngle()
366+
angle_t OoBFrustumAngle(FRenderViewpoint* Viewpoint)
367367
{
368368
// If pitch is larger than this you can look all around at an FOV of 90 degrees
369-
if (fabs(Viewpoint.HWAngles.Pitch.Degrees()) > 89.0) return 0xffffffff;
370-
else if (fabs(Viewpoint.HWAngles.Pitch.Degrees()) > 46.0 && !Viewpoint.IsAllowedOoB()) return 0xffffffff; // Just like 4.12.2 and older did
369+
if (fabs(Viewpoint->HWAngles.Pitch.Degrees()) > 89.0) return 0xffffffff;
371370
int aspMult = AspectMultiplier(r_viewwindow.WidescreenRatio); // 48 == square window
372-
double absPitch = fabs(Viewpoint.HWAngles.Pitch.Degrees());
371+
double absPitch = fabs(Viewpoint->HWAngles.Pitch.Degrees());
373372
// Smaller aspect ratios still clip too much. Need a better solution
374373
if (aspMult > 36 && absPitch > 30.0) return 0xffffffff;
375374
else if (aspMult > 40 && absPitch > 25.0) return 0xffffffff;
376375
else if (aspMult > 45 && absPitch > 20.0) return 0xffffffff;
377376
else if (aspMult > 47 && absPitch > 10.0) return 0xffffffff;
378377

379-
double xratio = r_viewwindow.FocalTangent / Viewpoint.PitchCos;
378+
double xratio = r_viewwindow.FocalTangent / Viewpoint->PitchCos;
380379
double floatangle = 0.05 + atan ( xratio ) * 48.0 / aspMult; // this is radians
381380
angle_t a1 = DAngle::fromRad(floatangle).BAMs();
382381

383382
if (a1 >= ANGLE_90) return 0xffffffff;
384383
return a1;
385384
}
386385

386+
angle_t HWDrawInfo::FrustumAngle()
387+
{
388+
if (Viewpoint.IsAllowedOoB())
389+
{
390+
return OoBFrustumAngle(&Viewpoint);
391+
}
392+
else
393+
{
394+
float tilt = fabs(Viewpoint.HWAngles.Pitch.Degrees());
395+
396+
// If the pitch is larger than this you can look all around at a FOV of 90°
397+
if (tilt > 46.0f) return 0xffffffff;
398+
399+
// ok, this is a gross hack that barely works...
400+
// but at least it doesn't overestimate too much...
401+
double floatangle = 2.0 + (45.0 + ((tilt / 1.9)))*Viewpoint.FieldOfView.Degrees() * 48.0 / AspectMultiplier(r_viewwindow.WidescreenRatio) / 90.0;
402+
angle_t a1 = DAngle::fromDeg(floatangle).BAMs();
403+
if (a1 >= ANGLE_180) return 0xffffffff;
404+
return a1;
405+
}
406+
}
407+
387408
//-----------------------------------------------------------------------------
388409
//
389410
// Setup the modelview matrix
@@ -1043,8 +1064,8 @@ void HWDrawInfo::ProcessScene(bool toscreen)
10431064
portalState.BeginScene();
10441065

10451066
int mapsection = Level->PointInRenderSubsector(Viewpoint.Pos)->mapsection;
1046-
if (Viewpoint.IsAllowedOoB())
1047-
mapsection = Level->PointInRenderSubsector(Viewpoint.camera->Pos())->mapsection;
1067+
if (Viewpoint.IsAllowedOoB() || Viewpoint.IsOrtho())
1068+
mapsection = Level->PointInRenderSubsector(Viewpoint.OffPos)->mapsection;
10481069
CurrentMapSections.Set(mapsection);
10491070
DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN);
10501071

0 commit comments

Comments
 (0)