From d86bd470e5741027c77312f3b454735fafafc5fe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Mar 2017 18:31:11 +0100 Subject: [PATCH] - moved two MAPINFO settings that are not exclusively used by the OpenGL renderer to the common code. --- src/g_level.h | 22 +++++++++-------- src/g_mapinfo.cpp | 13 ++++++++++ src/gl/data/gl_data.cpp | 34 -------------------------- src/gl/data/gl_data.h | 4 --- src/gl/models/gl_models.cpp | 2 +- src/gl/models/gl_voxels.cpp | 3 ++- src/gl/renderer/gl_lightdata.cpp | 2 +- src/gl/scene/gl_scene.cpp | 5 ++-- src/gl/system/gl_framebuffer.h | 1 - src/polyrenderer/poly_renderer.cpp | 5 ++-- src/polyrenderer/scene/poly_portal.cpp | 8 +++--- src/swrenderer/scene/r_light.cpp | 4 +-- 12 files changed, 40 insertions(+), 63 deletions(-) diff --git a/src/g_level.h b/src/g_level.h index 306ed3fa8..641cecd4f 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -239,6 +239,7 @@ enum ELevelFlags : unsigned int LEVEL3_FORCEFAKECONTRAST = 0x00000001, // forces fake contrast even with fog enabled LEVEL3_REMOVEITEMS = 0x00000002, // kills all INVBAR items on map change. LEVEL3_ATTENUATE = 0x00000004, // attenuate lights? + LEVEL3_NOLIGHTFADE = 0x00000008, // no light fading to black. }; @@ -303,9 +304,9 @@ struct level_info_t int cluster; int partime; int sucktime; - uint32_t flags; - uint32_t flags2; - uint32_t flags3; + int32_t flags; + uint32_t flags2; + uint32_t flags3; FString Music; FString LevelName; @@ -315,27 +316,28 @@ struct level_info_t TArray deferred; float skyspeed1; float skyspeed2; - uint32_t fadeto; - uint32_t outsidefog; + uint32_t fadeto; + uint32_t outsidefog; int cdtrack; unsigned int cdid; double gravity; double aircontrol; int WarpTrans; int airsupply; - uint32_t compatflags, compatflags2; - uint32_t compatmask, compatmask2; + uint32_t compatflags, compatflags2; + uint32_t compatmask, compatmask2; FString Translator; // for converting Doom-format linedef and sector types. int DefaultEnvironment; // Default sound environment for the map. FName Intermission; FName deathsequence; FName slideshow; - uint32_t hazardcolor; - uint32_t hazardflash; + uint32_t hazardcolor; + uint32_t hazardflash; int fogdensity; int outsidefogdensity; int skyfog; - + float pixelstretch; + // Redirection: If any player is carrying the specified item, then // you go to the RedirectMap instead of this one. FName RedirectType; diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 44edf83e8..bbb9ed607 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -275,6 +275,11 @@ void level_info_t::Reset() teamdamage = 0.f; hazardcolor = 0xff004200; hazardflash = 0xff00ff00; + fogdensity = 0; + outsidefogdensity = 0; + skyfog = 0; + pixelstretch = 1.2f; + specialactions.Clear(); DefaultEnvironment = 0; PrecacheSounds.Clear(); @@ -1237,6 +1242,13 @@ DEFINE_MAP_OPTION(skyfog, false) info->skyfog = parse.sc.Number; } +DEFINE_MAP_OPTION(pixelratio, false) +{ + parse.ParseAssign(); + parse.sc.MustGetFloat(); + info->pixelstretch = (float)parse.sc.Float; +} + //========================================================================== // @@ -1344,6 +1356,7 @@ MapFlagHandlers[] = { "unfreezesingleplayerconversations",MITYPE_SETFLAG2, LEVEL2_CONV_SINGLE_UNFREEZE, 0 }, { "spawnwithweaponraised", MITYPE_SETFLAG2, LEVEL2_PRERAISEWEAPON, 0 }, { "forcefakecontrast", MITYPE_SETFLAG3, LEVEL3_FORCEFAKECONTRAST, 0 }, + { "nolightfade", MITYPE_SETFLAG3, LEVEL3_NOLIGHTFADE, 0 }, { "nobotnodes", MITYPE_IGNORE, 0, 0 }, // Skulltag option: nobotnodes { "compat_shorttex", MITYPE_COMPATFLAG, COMPATF_SHORTTEX, 0 }, { "compat_stairs", MITYPE_COMPATFLAG, COMPATF_STAIRINDEX, 0 }, diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 45832fc6c..824407399 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -56,7 +56,6 @@ GLRenderSettings glset; long gl_frameMS; -long gl_frameCount; EXTERN_CVAR(Int, gl_lightmode) EXTERN_CVAR(Bool, gl_brightfog) @@ -193,11 +192,9 @@ struct FGLROptions : public FOptionalMapinfoData brightfog = false; lightmode = -1; nocoloredspritelighting = -1; - nolightfade = false; notexturefill = -1; skyrotatevector = FVector3(0,0,1); skyrotatevector2 = FVector3(0,0,1); - pixelstretch = 1.2f; lightadditivesurfaces = false; } virtual FOptionalMapinfoData *Clone() const @@ -206,11 +203,9 @@ struct FGLROptions : public FOptionalMapinfoData newopt->identifier = identifier; newopt->lightmode = lightmode; newopt->nocoloredspritelighting = nocoloredspritelighting; - newopt->nolightfade = nolightfade; newopt->notexturefill = notexturefill; newopt->skyrotatevector = skyrotatevector; newopt->skyrotatevector2 = skyrotatevector2; - newopt->pixelstretch = pixelstretch; newopt->lightadditivesurfaces = lightadditivesurfaces; return newopt; } @@ -219,10 +214,8 @@ struct FGLROptions : public FOptionalMapinfoData int8_t lightadditivesurfaces; int8_t nocoloredspritelighting; int8_t notexturefill; - bool nolightfade; FVector3 skyrotatevector; FVector3 skyrotatevector2; - float pixelstretch; }; DEFINE_MAP_OPTION(brightfog, false) @@ -255,20 +248,6 @@ DEFINE_MAP_OPTION(nocoloredspritelighting, false) } } -DEFINE_MAP_OPTION(nolightfade, false) -{ - FGLROptions *opt = info->GetOptData("gl_renderer"); - if (parse.CheckAssign()) - { - parse.sc.MustGetNumber(); - opt->nolightfade = !!parse.sc.Number; - } - else - { - opt->nolightfade = true; - } -} - DEFINE_MAP_OPTION(notexturefill, false) { FGLROptions *opt = info->GetOptData("gl_renderer"); @@ -329,15 +308,6 @@ DEFINE_MAP_OPTION(skyrotate2, false) opt->skyrotatevector2.MakeUnit(); } -DEFINE_MAP_OPTION(pixelratio, false) -{ - FGLROptions *opt = info->GetOptData("gl_renderer"); - - parse.ParseAssign(); - parse.sc.MustGetFloat(); - opt->pixelstretch = (float)parse.sc.Float; -} - bool IsLightmodeValid() { return (glset.map_lightmode >= 0 && glset.map_lightmode <= 4) || glset.map_lightmode == 8; @@ -370,8 +340,6 @@ void InitGLRMapinfoData() glset.map_notexturefill = opt->notexturefill; glset.skyrotatevector = opt->skyrotatevector; glset.skyrotatevector2 = opt->skyrotatevector2; - glset.pixelstretch = opt->pixelstretch; - glset.nolightfade = opt->nolightfade; } else { @@ -382,8 +350,6 @@ void InitGLRMapinfoData() glset.map_notexturefill = -1; glset.skyrotatevector = FVector3(0, 0, 1); glset.skyrotatevector2 = FVector3(0, 0, 1); - glset.pixelstretch = 1.2f; - glset.nolightfade = false; } ResetOpts(); } diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 5fecb0a5d..6abc2d36a 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -10,7 +10,6 @@ struct GLRenderSettings { int8_t lightmode; bool nocoloredspritelighting; - bool nolightfade; bool notexturefill; bool brightfog; bool lightadditivesurfaces; @@ -23,9 +22,6 @@ struct GLRenderSettings FVector3 skyrotatevector; FVector3 skyrotatevector2; - - float pixelstretch; - }; extern GLRenderSettings glset; diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index b8dcc8c7c..7a5e686be 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -1055,7 +1055,7 @@ void gl_RenderModel(GLSprite * spr) gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0); // consider the pixel stretching. For non-voxels this must be factored out here - float stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor() : 1.f) / glset.pixelstretch; + float stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor() : 1.f) / level.info->pixelstretch; gl_RenderState.mModelMatrix.scale(1, stretch, 1); diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 360ef4434..48b6da442 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -37,6 +37,7 @@ #include "g_level.h" #include "colormatcher.h" #include "textures/bitmap.h" +#include "g_levellocals.h" //#include "gl/gl_intern.h" #include "gl/system/gl_interface.h" @@ -429,7 +430,7 @@ int FVoxelModel::FindFrame(const char * name) float FVoxelModel::getAspectFactor() { - return glset.pixelstretch; + return level.info->pixelstretch; } //=========================================================================== diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 53df11aa1..69c964ca0 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -290,7 +290,7 @@ float gl_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity) else if ((fogcolor.d & 0xffffff) == 0) { // case 2: black fog - if (glset.lightmode != 8 && !glset.nolightfade) + if (glset.lightmode != 8 && !(level.flags3 & LEVEL3_NOLIGHTFADE)) { density = distfogtable[glset.lightmode != 0][gl_ClampLight(lightlevel)]; } diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index dcaa5612e..8198511c7 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -221,7 +221,7 @@ void GLSceneDrawer::SetProjection(VSMatrix matrix) void GLSceneDrawer::SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror) { float mult = mirror? -1:1; - float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch; + float planemult = planemirror? -level.info->pixelstretch : level.info->pixelstretch; gl_RenderState.mViewMatrix.loadIdentity(); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll.Degrees, 0.0f, 0.0f, 1.0f); @@ -796,7 +796,7 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. double radPitch = r_viewpoint.Angles.Pitch.Normalized180().Radians(); double angx = cos(radPitch); - double angy = sin(radPitch) * glset.pixelstretch; + double angy = sin(radPitch) * level.info->pixelstretch; double alen = sqrt(angx*angx + angy*angy); GLRenderer->mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); @@ -869,7 +869,6 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f } stereo3dMode.TearDown(); - gl_frameCount++; // This counter must be increased right before the interpolations are restored. interpolator.RestoreInterpolations (); return lviewsector; } diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index cdf96775e..d243a1054 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -13,7 +13,6 @@ class FSimpleVertexBuffer; class FGLDebug; extern long gl_frameMS; -extern long gl_frameCount; #ifdef _WIN32 class OpenGLFrameBuffer : public Win32GLFrameBuffer { diff --git a/src/polyrenderer/poly_renderer.cpp b/src/polyrenderer/poly_renderer.cpp index 0e4c98028..c53de5d62 100644 --- a/src/polyrenderer/poly_renderer.cpp +++ b/src/polyrenderer/poly_renderer.cpp @@ -32,6 +32,7 @@ #include "d_net.h" #include "po_man.h" #include "st_stuff.h" +#include "g_levellocals.h" #include "swrenderer/scene/r_scene.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/drawers/r_draw_rgba.h" @@ -196,7 +197,7 @@ void PolyRenderer::SetupPerspectiveMatrix() const auto &viewwindow = Thread.Viewport->viewwindow; double radPitch = viewpoint.Angles.Pitch.Normalized180().Radians(); double angx = cos(radPitch); - double angy = sin(radPitch) * glset.pixelstretch; + double angy = sin(radPitch) * level.info->pixelstretch; double alen = sqrt(angx*angx + angy*angy); float adjustedPitch = (float)asin(angy / alen); float adjustedViewAngle = (float)(viewpoint.Angles.Yaw - 90).Radians(); @@ -208,7 +209,7 @@ void PolyRenderer::SetupPerspectiveMatrix() TriMatrix worldToView = TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * - TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * + TriMatrix::scale(1.0f, level.info->pixelstretch, 1.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-viewpoint.Pos.X, (float)-viewpoint.Pos.Y, (float)-viewpoint.Pos.Z); diff --git a/src/polyrenderer/scene/poly_portal.cpp b/src/polyrenderer/scene/poly_portal.cpp index e48399ede..f19a1e808 100644 --- a/src/polyrenderer/scene/poly_portal.cpp +++ b/src/polyrenderer/scene/poly_portal.cpp @@ -51,7 +51,7 @@ void PolyDrawSectorPortal::Render(int portalDepth) const auto &viewwindow = PolyRenderer::Instance()->Thread.Viewport->viewwindow; double radPitch = viewpoint.Angles.Pitch.Normalized180().Radians(); double angx = cos(radPitch); - double angy = sin(radPitch) * glset.pixelstretch; + double angy = sin(radPitch) * level.info->pixelstretch; double alen = sqrt(angx*angx + angy*angy); float adjustedPitch = (float)asin(angy / alen); float adjustedViewAngle = (float)(viewpoint.Angles.Yaw - 90).Radians(); @@ -61,7 +61,7 @@ void PolyDrawSectorPortal::Render(int portalDepth) TriMatrix worldToView = TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * - TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * + TriMatrix::scale(1.0f, level.info->pixelstretch, 1.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-viewpoint.Pos.X, (float)-viewpoint.Pos.Y, (float)-viewpoint.Pos.Z); TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; @@ -160,7 +160,7 @@ void PolyDrawLinePortal::Render(int portalDepth) const auto &viewwindow = PolyRenderer::Instance()->Thread.Viewport->viewwindow; double radPitch = viewpoint.Angles.Pitch.Normalized180().Radians(); double angx = cos(radPitch); - double angy = sin(radPitch) * glset.pixelstretch; + double angy = sin(radPitch) * level.info->pixelstretch; double alen = sqrt(angx*angx + angy*angy); float adjustedPitch = (float)asin(angy / alen); float adjustedViewAngle = (float)(viewpoint.Angles.Yaw - 90).Radians(); @@ -170,7 +170,7 @@ void PolyDrawLinePortal::Render(int portalDepth) TriMatrix worldToView = TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * - TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * + TriMatrix::scale(1.0f, level.info->pixelstretch, 1.0f) * TriMatrix::swapYZ() * TriMatrix::translate((float)-viewpoint.Pos.X, (float)-viewpoint.Pos.Y, (float)-viewpoint.Pos.Z); if (Mirror) diff --git a/src/swrenderer/scene/r_light.cpp b/src/swrenderer/scene/r_light.cpp index f5243c430..97f09bad9 100644 --- a/src/swrenderer/scene/r_light.cpp +++ b/src/swrenderer/scene/r_light.cpp @@ -140,12 +140,12 @@ namespace swrenderer TiltVisibility = float(vis * viewport->viewwindow.FocalTangent * (16.f * 320.f) / viewwidth); - NoLightFade = glset.nolightfade; + NoLightFade = !!(level.flags3 & LEVEL3_NOLIGHTFADE); } fixed_t LightVisibility::LightLevelToShade(int lightlevel, bool foggy) { - bool nolightfade = !foggy && (glset.nolightfade); + bool nolightfade = !foggy && ((level.flags3 & LEVEL3_NOLIGHTFADE)); if (nolightfade) { return (MAX(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8);