diff --git a/src/rendering/hwrenderer/scene/hw_bsp.cpp b/src/rendering/hwrenderer/scene/hw_bsp.cpp index 3f834fcf6d..a927872f60 100644 --- a/src/rendering/hwrenderer/scene/hw_bsp.cpp +++ b/src/rendering/hwrenderer/scene/hw_bsp.cpp @@ -285,19 +285,25 @@ void HWDrawInfo::AddLine (seg_t *seg, bool portalclip) angle_t startAngle = clipper.GetClipAngle(seg->v2); angle_t endAngle = clipper.GetClipAngle(seg->v1); auto &clipperr = *rClipper; - angle_t startAngleR = clipperr.PointToPseudoAngle(seg->v2->fX(), seg->v2->fY()); - angle_t endAngleR = clipperr.PointToPseudoAngle(seg->v1->fX(), seg->v1->fY()); + angle_t startAngleR = 0; + angle_t endAngleR = 0; angle_t paddingR = 0x00200000; // Make radar clipping more aggressive (reveal less) - if(Viewpoint.IsAllowedOoB() && r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR) && (startAngleR - endAngleR >= ANGLE_180)) + if(Viewpoint.IsAllowedOoB() && r_radarclipper && !(Level->flags3 & LEVEL3_NOFOGOFWAR)) { - if (!seg->backsector) clipperr.SafeAddClipRange(startAngleR - paddingR, endAngleR + paddingR); - else if((seg->sidedef != nullptr) && !uint8_t(seg->sidedef->Flags & WALLF_POLYOBJ) && (currentsector->sectornum != seg->backsector->sectornum)) + startAngleR = clipperr.PointToPseudoAngle(seg->v2->fX(), seg->v2->fY()); + endAngleR = clipperr.PointToPseudoAngle(seg->v1->fX(), seg->v1->fY()); + + if (startAngleR - endAngleR >= ANGLE_180) { - if (in_area == area_default) in_area = hw_CheckViewArea(seg->v1, seg->v2, seg->frontsector, seg->backsector); - backsector = hw_FakeFlat(seg->backsector, in_area, true); - if (hw_CheckClip(seg->sidedef, currentsector, backsector)) clipperr.SafeAddClipRange(startAngleR - paddingR, endAngleR + paddingR); - backsector = nullptr; + if (!seg->backsector) clipperr.SafeAddClipRange(startAngleR - paddingR, endAngleR + paddingR); + else if((seg->sidedef != nullptr) && !uint8_t(seg->sidedef->Flags & WALLF_POLYOBJ) && (currentsector->sectornum != seg->backsector->sectornum)) + { + if (in_area == area_default) in_area = hw_CheckViewArea(seg->v1, seg->v2, seg->frontsector, seg->backsector); + backsector = hw_FakeFlat(seg->backsector, in_area, true); + if (hw_CheckClip(seg->sidedef, currentsector, backsector)) clipperr.SafeAddClipRange(startAngleR - paddingR, endAngleR + paddingR); + backsector = nullptr; + } } } @@ -708,7 +714,7 @@ void HWDrawInfo::DoSubsector(subsector_t * sub) if(Viewpoint.IsAllowedOoB() && sector->isSecret() && sector->wasSecret() && !r_radarclipper) return; // cull everything if subsector outside all relevant clippers - if ((sub->polys == nullptr)) + if (Viewpoint.IsAllowedOoB() && (sub->polys == nullptr)) { auto &clipper = *mClipper; auto &clipperv = *vClipper; diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp index 4042039336..0e647e307e 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp @@ -268,8 +268,8 @@ void HWDrawInfo::ClearBuffers() void HWDrawInfo::UpdateCurrentMapSection() { int mapsection = Level->PointInRenderSubsector(Viewpoint.Pos)->mapsection; - if (Viewpoint.IsAllowedOoB()) - mapsection = Level->PointInRenderSubsector(Viewpoint.camera->Pos())->mapsection; + if (Viewpoint.IsAllowedOoB() || Viewpoint.IsOrtho()) + mapsection = Level->PointInRenderSubsector(Viewpoint.OffPos)->mapsection; CurrentMapSections.Set(mapsection); } @@ -363,20 +363,19 @@ int HWDrawInfo::SetFullbrightFlags(player_t *player) // //----------------------------------------------------------------------------- -angle_t HWDrawInfo::FrustumAngle() +angle_t OoBFrustumAngle(FRenderViewpoint* Viewpoint) { // If pitch is larger than this you can look all around at an FOV of 90 degrees - if (fabs(Viewpoint.HWAngles.Pitch.Degrees()) > 89.0) return 0xffffffff; - else if (fabs(Viewpoint.HWAngles.Pitch.Degrees()) > 46.0 && !Viewpoint.IsAllowedOoB()) return 0xffffffff; // Just like 4.12.2 and older did + if (fabs(Viewpoint->HWAngles.Pitch.Degrees()) > 89.0) return 0xffffffff; int aspMult = AspectMultiplier(r_viewwindow.WidescreenRatio); // 48 == square window - double absPitch = fabs(Viewpoint.HWAngles.Pitch.Degrees()); + double absPitch = fabs(Viewpoint->HWAngles.Pitch.Degrees()); // Smaller aspect ratios still clip too much. Need a better solution if (aspMult > 36 && absPitch > 30.0) return 0xffffffff; else if (aspMult > 40 && absPitch > 25.0) return 0xffffffff; else if (aspMult > 45 && absPitch > 20.0) return 0xffffffff; else if (aspMult > 47 && absPitch > 10.0) return 0xffffffff; - double xratio = r_viewwindow.FocalTangent / Viewpoint.PitchCos; + double xratio = r_viewwindow.FocalTangent / Viewpoint->PitchCos; double floatangle = 0.05 + atan ( xratio ) * 48.0 / aspMult; // this is radians angle_t a1 = DAngle::fromRad(floatangle).BAMs(); @@ -384,6 +383,28 @@ angle_t HWDrawInfo::FrustumAngle() return a1; } +angle_t HWDrawInfo::FrustumAngle() +{ + if (Viewpoint.IsAllowedOoB()) + { + return OoBFrustumAngle(&Viewpoint); + } + else + { + float tilt = fabs(Viewpoint.HWAngles.Pitch.Degrees()); + + // If the pitch is larger than this you can look all around at a FOV of 90° + if (tilt > 46.0f) return 0xffffffff; + + // ok, this is a gross hack that barely works... + // but at least it doesn't overestimate too much... + double floatangle = 2.0 + (45.0 + ((tilt / 1.9)))*Viewpoint.FieldOfView.Degrees() * 48.0 / AspectMultiplier(r_viewwindow.WidescreenRatio) / 90.0; + angle_t a1 = DAngle::fromDeg(floatangle).BAMs(); + if (a1 >= ANGLE_180) return 0xffffffff; + return a1; + } +} + //----------------------------------------------------------------------------- // // Setup the modelview matrix @@ -1043,8 +1064,8 @@ void HWDrawInfo::ProcessScene(bool toscreen) portalState.BeginScene(); int mapsection = Level->PointInRenderSubsector(Viewpoint.Pos)->mapsection; - if (Viewpoint.IsAllowedOoB()) - mapsection = Level->PointInRenderSubsector(Viewpoint.camera->Pos())->mapsection; + if (Viewpoint.IsAllowedOoB() || Viewpoint.IsOrtho()) + mapsection = Level->PointInRenderSubsector(Viewpoint.OffPos)->mapsection; CurrentMapSections.Set(mapsection); DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN);