Merge branch 'line_distance_cull' into qzdoom

# Conflicts:
#	src/swrenderer/scene/r_opaque_pass.cpp
This commit is contained in:
Magnus Norddahl 2017-07-12 07:11:43 +02:00
commit c38d0c1637
5 changed files with 280 additions and 2 deletions

View file

@ -47,6 +47,7 @@
#include "swrenderer/things/r_particle.h"
#include "swrenderer/segments/r_clipsegment.h"
#include "swrenderer/line/r_wallsetup.h"
#include "swrenderer/line/r_farclip_line.h"
#include "swrenderer/scene/r_scene.h"
#include "swrenderer/scene/r_light.h"
#include "swrenderer/viewport/r_viewport.h"
@ -72,7 +73,11 @@
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
EXTERN_CVAR(Bool, r_drawvoxels);
namespace { double sprite_distance_cull = 1e16; }
namespace
{
double sprite_distance_cull = 1e16;
double line_distance_cull = 1e16;
}
CUSTOM_CVAR(Float, r_sprite_distance_cull, 5000.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
@ -86,6 +91,18 @@ CUSTOM_CVAR(Float, r_sprite_distance_cull, 5000.0, CVAR_ARCHIVE | CVAR_GLOBALCON
}
}
CUSTOM_CVAR(Float, r_line_distance_cull, 8000.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
if (r_line_distance_cull > 0.0)
{
line_distance_cull = r_line_distance_cull * r_line_distance_cull;
}
else
{
line_distance_cull = 1e16;
}
}
namespace swrenderer
{
RenderOpaquePass::RenderOpaquePass(RenderThread *thread) : renderline(thread)
@ -744,10 +761,19 @@ namespace swrenderer
count = sub->numlines;
line = sub->firstline;
DVector2 viewpointPos = Thread->Viewport->viewpoint.Pos.XY();
basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
while (count--)
{
if (!outersubsector || line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ))
double dist1 = (line->v1->fPos() - viewpointPos).LengthSquared();
double dist2 = (line->v2->fPos() - viewpointPos).LengthSquared();
if (dist1 > line_distance_cull && dist2 > line_distance_cull)
{
FarClipLine farclip(Thread);
farclip.Render(line, InSubsector, floorplane, ceilingplane);
}
else if (!outersubsector || line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ))
{
// kg3D - fake planes bounding calculation
if (r_3dfloors && line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size())