Skip to content

Commit

Permalink
Merge branch 'master' into hardpoly
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Sep 12, 2017
2 parents 7b640fa + d0fbdd1 commit cf0849a
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 93 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -56,15 +56,15 @@ matrix:
- os: linux
compiler: clang
env:
- CLANG_VERSION=4.0
- CLANG_VERSION=5.0
- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=MinSizeRel -DDYN_OPENAL=NO -DDYN_SNDFILE=NO -DDYN_MPG123=NO -DDYN_FLUIDSYNTH=NO"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- llvm-toolchain-trusty-5.0
packages:
- clang-4.0
- clang-5.0
- libstdc++-5-dev
- libsdl2-dev
- libgme-dev
Expand Down
4 changes: 1 addition & 3 deletions src/gl/dynlights/gl_shadowmap.cpp
Expand Up @@ -82,12 +82,10 @@ ADD_STAT(shadowmap)
return out;
}

CUSTOM_CVAR(Int, gl_shadowmap_quality, 128, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Int, gl_shadowmap_quality, 512, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
switch (self)
{
case 32:
case 64:
case 128:
case 256:
case 512:
Expand Down
2 changes: 1 addition & 1 deletion src/p_acs.cpp
Expand Up @@ -10041,7 +10041,7 @@ int DLevelScript::RunScript ()
}
else
{
FCanvasTextureInfo::Add (camera, picnum, ACSToDouble(STACK(1)));
FCanvasTextureInfo::Add (camera, picnum, STACK(1));
}
}
sp -= 3;
Expand Down
94 changes: 47 additions & 47 deletions src/polyrenderer/scene/poly_plane.cpp
Expand Up @@ -187,18 +187,40 @@ void RenderPolyPlane::Render(PolyRenderThread *thread, const TriMatrix &worldToC

if (ceiling)
{
for (uint32_t i = 0; i < sub->numlines; i++)
if (!isSky)
{
seg_t *line = &sub->firstline[i];
vertices[sub->numlines - 1 - i] = transform.GetVertex(line->v1, isSky ? skyHeight : frontsector->ceilingplane.ZatPoint(line->v1));
for (uint32_t i = 0; i < sub->numlines; i++)
{
seg_t *line = &sub->firstline[i];
vertices[sub->numlines - 1 - i] = transform.GetVertex(line->v1, frontsector->ceilingplane.ZatPoint(line->v1));
}
}
else
{
for (uint32_t i = 0; i < sub->numlines; i++)
{
seg_t *line = &sub->firstline[i];
vertices[sub->numlines - 1 - i] = transform.GetVertex(line->v1, skyHeight);
}
}
}
else
{
for (uint32_t i = 0; i < sub->numlines; i++)
if (!isSky)
{
seg_t *line = &sub->firstline[i];
vertices[i] = transform.GetVertex(line->v1, isSky ? skyHeight : frontsector->floorplane.ZatPoint(line->v1));
for (uint32_t i = 0; i < sub->numlines; i++)
{
seg_t *line = &sub->firstline[i];
vertices[i] = transform.GetVertex(line->v1, frontsector->floorplane.ZatPoint(line->v1));
}
}
else
{
for (uint32_t i = 0; i < sub->numlines; i++)
{
seg_t *line = &sub->firstline[i];
vertices[i] = transform.GetVertex(line->v1, skyHeight);
}
}
}

Expand Down Expand Up @@ -259,42 +281,40 @@ void RenderPolyPlane::RenderSkyWalls(PolyRenderThread *thread, PolyDrawArgs &arg
{
for (uint32_t i = 0; i < sub->numlines; i++)
{
TriVertex *wallvert = thread->FrameMemory->AllocMemory<TriVertex>(4);

seg_t *line = &sub->firstline[i];

double skyBottomz1 = frontsector->ceilingplane.ZatPoint(line->v1);
double skyBottomz2 = frontsector->ceilingplane.ZatPoint(line->v2);
if (line->backsector)
{
sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector;

double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1);
double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1);
double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2);
double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2);
sector_t *backsector = line->backsector;

double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1);
double backfloorz1 = backsector->floorplane.ZatPoint(line->v1);
double backceilz2 = backsector->ceilingplane.ZatPoint(line->v2);
double backfloorz2 = backsector->floorplane.ZatPoint(line->v2);

double topceilz1 = frontceilz1;
double topceilz2 = frontceilz2;
double topfloorz1 = MIN(backceilz1, frontceilz1);
double topfloorz2 = MIN(backceilz2, frontceilz2);
double bottomceilz1 = MAX(frontfloorz1, backfloorz1);
double bottomceilz2 = MAX(frontfloorz2, backfloorz2);
double middleceilz1 = topfloorz1;
double middleceilz2 = topfloorz2;
double middlefloorz1 = MIN(bottomceilz1, middleceilz1);
double middlefloorz2 = MIN(bottomceilz2, middleceilz2);

bool bothSkyCeiling = frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum;

bool closedSector = backceilz1 == backfloorz1 && backceilz2 == backfloorz2;
if (ceiling && bothSkyCeiling && closedSector)
{
double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1);
double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1);
double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2);
double frontfloorz2 = frontsector->floorplane.ZatPoint(line->v2);

double topceilz1 = frontceilz1;
double topceilz2 = frontceilz2;
double topfloorz1 = MIN(backceilz1, frontceilz1);
double topfloorz2 = MIN(backceilz2, frontceilz2);
double bottomceilz1 = MAX(frontfloorz1, backfloorz1);
double bottomceilz2 = MAX(frontfloorz2, backfloorz2);
double middleceilz1 = topfloorz1;
double middleceilz2 = topfloorz2;
double middlefloorz1 = MIN(bottomceilz1, middleceilz1);
double middlefloorz2 = MIN(bottomceilz2, middleceilz2);

skyBottomz1 = middlefloorz1;
skyBottomz2 = middlefloorz2;
}
Expand All @@ -310,6 +330,8 @@ void RenderPolyPlane::RenderSkyWalls(PolyRenderThread *thread, PolyDrawArgs &arg
skyBottomz2 = frontsector->floorplane.ZatPoint(line->v2);
}

TriVertex *wallvert = thread->FrameMemory->AllocMemory<TriVertex>(4);

if (ceiling)
{
wallvert[0] = transform.GetVertex(line->v1, skyHeight);
Expand Down Expand Up @@ -361,28 +383,6 @@ PolyPlaneUVTransform::PolyPlaneUVTransform(const FTransform &transform, FTexture
}
}

TriVertex PolyPlaneUVTransform::GetVertex(vertex_t *v1, double height) const
{
TriVertex v;
v.x = (float)v1->fPos().X;
v.y = (float)v1->fPos().Y;
v.z = (float)height;
v.w = 1.0f;
v.u = GetU(v.x, v.y);
v.v = GetV(v.x, v.y);
return v;
}

float PolyPlaneUVTransform::GetU(float x, float y) const
{
return (xOffs + x * cosine - y * sine) * xscale;
}

float PolyPlaneUVTransform::GetV(float x, float y) const
{
return (yOffs - x * sine - y * cosine) * yscale;
}

/////////////////////////////////////////////////////////////////////////////

void Render3DFloorPlane::RenderPlanes(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t stencilValue, uint32_t subsectorDepth, std::vector<PolyTranslucentObject *> &translucentObjects)
Expand Down
16 changes: 13 additions & 3 deletions src/polyrenderer/scene/poly_plane.h
Expand Up @@ -31,11 +31,21 @@ class PolyPlaneUVTransform
public:
PolyPlaneUVTransform(const FTransform &transform, FTexture *tex);

TriVertex GetVertex(vertex_t *v1, double height) const;
TriVertex GetVertex(vertex_t *v1, double height) const
{
TriVertex v;
v.x = (float)v1->fX();
v.y = (float)v1->fY();
v.z = (float)height;
v.w = 1.0f;
v.u = GetU(v.x, v.y);
v.v = GetV(v.x, v.y);
return v;
}

private:
float GetU(float x, float y) const;
float GetV(float x, float y) const;
float GetU(float x, float y) const { return (xOffs + x * cosine - y * sine) * xscale; }
float GetV(float x, float y) const { return (yOffs - x * sine - y * cosine) * yscale; }

float xscale;
float yscale;
Expand Down
2 changes: 1 addition & 1 deletion src/polyrenderer/scene/poly_wall.cpp
Expand Up @@ -112,7 +112,7 @@ bool RenderPolyWall::RenderLine(PolyRenderThread *thread, const TriMatrix &world
}
else
{
sector_t *backsector = (line->backsector != line->frontsector) ? line->backsector : line->frontsector;
sector_t *backsector = line->backsector;

double backceilz1 = backsector->ceilingplane.ZatPoint(line->v1);
double backfloorz1 = backsector->floorplane.ZatPoint(line->v1);
Expand Down
29 changes: 15 additions & 14 deletions src/r_videoscale.cpp
Expand Up @@ -25,7 +25,7 @@
#include "c_dispatch.h"
#include "c_cvars.h"

#define NUMSCALEMODES 11
#define NUMSCALEMODES 5

namespace
{
Expand All @@ -41,19 +41,19 @@ namespace
{
// isValid, isLinear, GetScaledWidth(), GetScaledHeight(), isScaled43
{ true, false, [](uint32_t Width)->uint32_t { return Width; }, [](uint32_t Height)->uint32_t { return Height; }, false }, // 0 - Native
{ true, false, [](uint32_t Width)->uint32_t { return 320; }, [](uint32_t Height)->uint32_t { return 200; }, true }, // 1 - 320x200
{ true, true, [](uint32_t Width)->uint32_t { return 640; }, [](uint32_t Height)->uint32_t { return 400; }, true }, // 2 - 640x400
{ true, true, [](uint32_t Width)->uint32_t { return 1280; }, [](uint32_t Height)->uint32_t { return 800; }, true }, // 3 - 1280x800
{ false, false, nullptr, nullptr, false }, // 4
{ false, false, nullptr, nullptr, false }, // 5
{ false, false, nullptr, nullptr, false }, // 6
{ false, false, nullptr, nullptr, false }, // 7
{ true, false, [](uint32_t Width)->uint32_t { return Width / 2; }, [](uint32_t Height)->uint32_t { return Height / 2; }, false }, // 8 - Half-Res
{ true, true, [](uint32_t Width)->uint32_t { return Width * 0.75; }, [](uint32_t Height)->uint32_t { return Height * 0.75; }, false }, // 9 - Res * 0.75
{ true, true, [](uint32_t Width)->uint32_t { return Width * 2; }, [](uint32_t Height)->uint32_t { return Height * 2; }, false }, // 10 - SSAAx2
{ true, true, [](uint32_t Width)->uint32_t { return Width; }, [](uint32_t Height)->uint32_t { return Height; }, false }, // 1 - Native (Linear)
{ true, false, [](uint32_t Width)->uint32_t { return 320; }, [](uint32_t Height)->uint32_t { return 200; }, true }, // 2 - 320x200
{ true, false, [](uint32_t Width)->uint32_t { return 640; }, [](uint32_t Height)->uint32_t { return 400; }, true }, // 3 - 640x400
{ true, true, [](uint32_t Width)->uint32_t { return 1280; }, [](uint32_t Height)->uint32_t { return 800; }, true }, // 4 - 1280x800
};
}

CUSTOM_CVAR(Float, vid_scalefactor, 1.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
if (self <= 0.0 || self > 2.0)
self = 1.0;
}

CUSTOM_CVAR(Int, vid_scalemode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
if (self < 0 || self >= NUMSCALEMODES || vScaleTable[self].isValid == false)
Expand All @@ -64,17 +64,18 @@ CUSTOM_CVAR(Int, vid_scalemode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)

bool ViewportLinearScale()
{
return vScaleTable[vid_scalemode].isLinear;
// vid_scalefactor > 1 == forced linear scale
return (vid_scalefactor > 1.0) ? true : vScaleTable[vid_scalemode].isLinear;
}

int ViewportScaledWidth(int width)
{
return vScaleTable[vid_scalemode].GetScaledWidth(width);
return vScaleTable[vid_scalemode].GetScaledWidth((int)((float)width * vid_scalefactor));
}

int ViewportScaledHeight(int height)
{
return vScaleTable[vid_scalemode].GetScaledHeight(height);
return vScaleTable[vid_scalemode].GetScaledHeight((int)((float)height * vid_scalefactor));
}

bool ViewportIsScaled43()
Expand Down
18 changes: 11 additions & 7 deletions wadsrc/static/language.enu
Expand Up @@ -2193,6 +2193,7 @@ VIDMNU_ASPECTRATIO = "Aspect ratio";
VIDMNU_FORCEASPECT = "Force aspect ratio";
VIDMNU_5X4ASPECTRATIO = "Enable 5:4 aspect ratio";
VIDMNU_SCALEMODE = "Resolution scale";
VIDMNU_SCALEFACTOR = "Scale Factor";
VIDMNU_ENTERTEXT = "Press ENTER to set mode";
VIDMNU_TESTTEXT1 = "T to test mode for 5 seconds";
VIDMNU_TESTTEXT2 = "Please wait 5 seconds...";
Expand Down Expand Up @@ -2378,6 +2379,8 @@ OPTVAL_VTFZDOOM = "ZDoom (Forced)";
OPTVAL_VTFVANILLA = "Vanilla (Forced)";
OPTVAL_VTAZDOOM = "Auto (ZDoom Preferred)";
OPTVAL_VTAVANILLA = "Auto (Vanilla Preferred)";
OPTVAL_SCALENEAREST = "Scaled (Nearest)";
OPTVAL_SCALELINEAR = "Scaled (Linear)";

// Colors
C_BRICK = "\cabrick";
Expand Down Expand Up @@ -2685,13 +2688,14 @@ GLTEXMNU_TRIMSPREDGE = "Trim sprite edges";
GLTEXMNU_SORTDRAWLIST = "Sort draw lists by texture";

// Dynamic Light Options
GLLIGHTMNU_TITLE = "DYNAMIC LIGHTS";
GLLIGHTMNU_LIGHTSENABLED = "Dynamic Lights (OpenGL)";
GLLIGHTMNU_LIGHTDEFS = "Enable light definitions";
GLLIGHTMNU_CLIPLIGHTS = "Clip lights";
GLLIGHTMNU_LIGHTSPRITES = "Lights affect sprites";
GLLIGHTMNU_LIGHTPARTICLES = "Lights affect particles";
GLLIGHTMNU_LIGHTSHADOWMAP = "Light shadowmaps";
GLLIGHTMNU_TITLE = "DYNAMIC LIGHTS";
GLLIGHTMNU_LIGHTSENABLED = "Dynamic Lights (OpenGL)";
GLLIGHTMNU_LIGHTDEFS = "Enable light definitions";
GLLIGHTMNU_CLIPLIGHTS = "Clip lights";
GLLIGHTMNU_LIGHTSPRITES = "Lights affect sprites";
GLLIGHTMNU_LIGHTPARTICLES = "Lights affect particles";
GLLIGHTMNU_LIGHTSHADOWMAP = "Light shadowmaps";
GLLIGHTMNU_LIGHTSHADOWMAPQUALITY = "Shadowmap quality";

// OpenGL Preferences
GLPREFMNU_TITLE = "OPENGL PREFERENCES";
Expand Down
36 changes: 22 additions & 14 deletions wadsrc/static/menudef.txt
Expand Up @@ -1858,13 +1858,11 @@ OptionValue RatiosTFT
}
OptionValue ScaleModes
{
0, "$OPTVAL_OFF"
1, "320x200"
2, "640x400"
3, "1280x800"
8, "0.5x"
9, "0.75x"
10, "2x SSAA"
0, "$OPTVAL_SCALENEAREST"
1, "$OPTVAL_SCALELINEAR"
2, "320x200"
3, "640x400"
4, "1280x800"
}

OptionMenu VideoModeMenu protected
Expand All @@ -1880,6 +1878,7 @@ OptionMenu VideoModeMenu protected
Option "$VIDMNU_FORCEASPECT", "vid_aspect", "ForceRatios"
Option "$VIDMNU_5X4ASPECTRATIO", "vid_tft", "YesNo"
Option "$VIDMNU_SCALEMODE", "vid_scalemode", "ScaleModes"
Slider "$VIDMNU_SCALEFACTOR", "vid_scalefactor", 0.25, 2.0, 0.25, 2
StaticText " "
ScreenResolution "res_0"
ScreenResolution "res_1"
Expand Down Expand Up @@ -2128,6 +2127,14 @@ OptionValue VRMode
7, "$OPTVAL_QUADBUFFERED"
}

OptionValue ShadowMapQuality
{
128, "128"
256, "256"
512, "512"
1024, "1024"
}

OptionMenu "GLTextureGLOptions" protected
{
Title "$GLTEXMNU_TITLE"
Expand All @@ -2148,13 +2155,14 @@ OptionMenu "GLTextureGLOptions" protected
OptionMenu "GLLightOptions" protected
{
Title "$GLLIGHTMNU_TITLE"
Option "$TCMNU_DYNLIGHTS", "r_dynlights", "OnOff"
Option "$GLLIGHTMNU_LIGHTSENABLED", gl_lights, "OnOff"
Option "$GLLIGHTMNU_LIGHTDEFS", gl_attachedlights, "YesNo"
Option "$GLLIGHTMNU_CLIPLIGHTS", gl_lights_checkside, "YesNo"
Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo"
Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo"
Option "$GLLIGHTMNU_LIGHTSHADOWMAP", gl_light_shadowmap, "YesNo"
Option "$TCMNU_DYNLIGHTS", "r_dynlights", "OnOff"
Option "$GLLIGHTMNU_LIGHTSENABLED", gl_lights, "OnOff"
Option "$GLLIGHTMNU_LIGHTDEFS", gl_attachedlights, "YesNo"
Option "$GLLIGHTMNU_CLIPLIGHTS", gl_lights_checkside, "YesNo"
Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo"
Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo"
Option "$GLLIGHTMNU_LIGHTSHADOWMAP", gl_light_shadowmap, "YesNo"
Option "$GLLIGHTMNU_LIGHTSHADOWMAPQUALITY", gl_shadowmap_quality, "ShadowMapQuality"
}

OptionMenu "OpenGLOptions" protected
Expand Down

0 comments on commit cf0849a

Please sign in to comment.