- moved the code in gl_data.cpp to better fitting places

* the MAPINFO options now get handled in g_mapinfo.cpp and g_level.cpp, just like the rest of them as members of level_info_t and FLevelLocals.
* RecalcVertexHeights has been made a member of vertex_t and been moved to p_sectors.cpp.
* the dumpgeometry CCMD has been moved to p_setup.cpp
This commit is contained in:
Christoph Oelckers 2018-04-01 18:45:27 +02:00
parent 0127a71974
commit 65e7b6dfaa
22 changed files with 249 additions and 390 deletions

View file

@ -1043,7 +1043,6 @@ set (PCH_SOURCES
g_statusbar/sbar_mugshot.cpp g_statusbar/sbar_mugshot.cpp
g_statusbar/shared_sbar.cpp g_statusbar/shared_sbar.cpp
gl/compatibility/gl_20.cpp gl/compatibility/gl_20.cpp
gl/data/gl_data.cpp
gl/data/gl_portaldata.cpp gl/data/gl_portaldata.cpp
gl/data/gl_setup.cpp gl/data/gl_setup.cpp
gl/data/gl_vertexbuffer.cpp gl/data/gl_vertexbuffer.cpp

View file

@ -117,6 +117,31 @@ EXTERN_CVAR (String, playerclass)
void G_VerifySkill(); void G_VerifySkill();
CUSTOM_CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
if (level.info->brightfog == -1) level.brightfog = self;
}
CUSTOM_CVAR(Bool, gl_lightadditivesurfaces, false, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
if (level.info->lightadditivesurfaces == -1) level.lightadditivesurfaces = self;
}
CUSTOM_CVAR(Bool, gl_notexturefill, false, CVAR_NOINITCALL)
{
if (level.info->notexturefill == -1) level.notexturefill = self;
}
CUSTOM_CVAR(Int, gl_lightmode, 3, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
int newself = self;
if (newself > 4) newself = 8; // use 8 for software lighting to avoid conflicts with the bit mask
if (newself < 0) newself = 0;
if (self != newself) self = newself;
else if (level.info->lightmode == -1) level.lightmode = self;
}
static FRandom pr_classchoice ("RandomPlayerClassChoice"); static FRandom pr_classchoice ("RandomPlayerClassChoice");
@ -1491,6 +1516,12 @@ void G_InitLevelLocals ()
compatflags2.Callback(); compatflags2.Callback();
level.DefaultEnvironment = info->DefaultEnvironment; level.DefaultEnvironment = info->DefaultEnvironment;
level.lightmode = info->lightmode < 0? gl_lightmode : info->lightmode;
level.brightfog = info->brightfog < 0? gl_brightfog : !!info->brightfog;
level.lightadditivesurfaces = info->lightadditivesurfaces < 0 ? gl_lightadditivesurfaces : !!info->lightadditivesurfaces;
level.notexturefill = info->notexturefill < 0 ? gl_notexturefill : !!info->notexturefill;
} }
//========================================================================== //==========================================================================

View file

@ -35,6 +35,7 @@
#define __G_LEVEL_H__ #define __G_LEVEL_H__
#include "doomtype.h" #include "doomtype.h"
#include "vectors.h"
#include "sc_man.h" #include "sc_man.h"
#include "resourcefiles/file_zip.h" #include "resourcefiles/file_zip.h"
@ -395,6 +396,14 @@ struct level_info_t
TArray<FString> EventHandlers; TArray<FString> EventHandlers;
int8_t lightmode;
int8_t brightfog;
int8_t lightadditivesurfaces;
int8_t notexturefill;
FVector3 skyrotatevector;
FVector3 skyrotatevector2;
level_info_t() level_info_t()
{ {
Reset(); Reset();

View file

@ -152,6 +152,12 @@ struct FLevelLocals
float pixelstretch; float pixelstretch;
float MusicVolume; float MusicVolume;
// Hardware render stuff that can either be set via CVAR or MAPINFO
int lightmode;
bool brightfog;
bool lightadditivesurfaces;
bool notexturefill;
bool IsJumpingAllowed() const; bool IsJumpingAllowed() const;
bool IsCrouchingAllowed() const; bool IsCrouchingAllowed() const;
bool IsFreelookAllowed() const; bool IsFreelookAllowed() const;

View file

@ -283,6 +283,14 @@ void level_info_t::Reset()
specialactions.Clear(); specialactions.Clear();
DefaultEnvironment = 0; DefaultEnvironment = 0;
PrecacheSounds.Clear(); PrecacheSounds.Clear();
brightfog = -1;
lightmode = -1;
notexturefill = -1;
lightadditivesurfaces = -1;
skyrotatevector = FVector3(0, 0, 1);
skyrotatevector2 = FVector3(0, 0, 1);
} }
@ -1362,6 +1370,82 @@ DEFINE_MAP_OPTION(pixelratio, false)
} }
DEFINE_MAP_OPTION(brightfog, false)
{
parse.ParseAssign();
parse.sc.MustGetNumber();
info->brightfog = parse.sc.Number;
}
DEFINE_MAP_OPTION(lightmode, false)
{
parse.ParseAssign();
parse.sc.MustGetNumber();
if ((parse.sc.Number >= 0 && parse.sc.Number <= 4) || parse.sc.Number == 8)
{
info->lightmode = uint8_t(parse.sc.Number);
}
else
{
parse.sc.ScriptMessage("Invalid light mode %d", parse.sc.Number);
}
}
DEFINE_MAP_OPTION(notexturefill, false)
{
if (parse.CheckAssign())
{
parse.sc.MustGetNumber();
info->notexturefill = !!parse.sc.Number;
}
else
{
info->notexturefill = true;
}
}
DEFINE_MAP_OPTION(lightadditivesurfaces, false)
{
if (parse.CheckAssign())
{
parse.sc.MustGetNumber();
info->lightadditivesurfaces = !!parse.sc.Number;
}
else
{
info->lightadditivesurfaces = true;
}
}
DEFINE_MAP_OPTION(skyrotate, false)
{
parse.ParseAssign();
parse.sc.MustGetFloat();
info->skyrotatevector.X = (float)parse.sc.Float;
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
parse.sc.MustGetFloat();
info->skyrotatevector.Y = (float)parse.sc.Float;
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
parse.sc.MustGetFloat();
info->skyrotatevector.Z = (float)parse.sc.Float;
info->skyrotatevector.MakeUnit();
}
DEFINE_MAP_OPTION(skyrotate2, false)
{
parse.ParseAssign();
parse.sc.MustGetFloat();
info->skyrotatevector2.X = (float)parse.sc.Float;
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
parse.sc.MustGetFloat();
info->skyrotatevector2.Y = (float)parse.sc.Float;
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
parse.sc.MustGetFloat();
info->skyrotatevector2.Z = (float)parse.sc.Float;
info->skyrotatevector2.MakeUnit();
}
//========================================================================== //==========================================================================
// //
// All flag based map options // All flag based map options

View file

@ -485,7 +485,7 @@ static bool gl_CheckFog(FColormap *cm, int lightlevel)
{ {
frontfog = true; frontfog = true;
} }
else if (level.fogdensity != 0 || (glset.lightmode & 4) || cm->FogDensity > 0) else if (level.fogdensity != 0 || (level.lightmode & 4) || cm->FogDensity > 0)
{ {
// case 3: level has fog density set // case 3: level has fog density set
frontfog = true; frontfog = true;
@ -849,7 +849,7 @@ void GLSceneDrawer::RenderMultipassStuff()
{ {
gl_RenderState.BlendFunc(GL_ONE, GL_ONE); gl_RenderState.BlendFunc(GL_ONE, GL_ONE);
glDepthFunc(GL_EQUAL); glDepthFunc(GL_EQUAL);
if (glset.lightmode == 8) gl_RenderState.SetSoftLightLevel(255); if (level.lightmode == 8) gl_RenderState.SetSoftLightLevel(255);
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX); gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX);
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX); gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX);
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX); gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX);

View file

@ -1,323 +0,0 @@
//
//---------------------------------------------------------------------------
//
// Copyright(C) 2005-2016 Christoph Oelckers
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//--------------------------------------------------------------------------
//
/*
** gl_data.cpp
** Maintenance data for GL renderer (mostly to handle rendering hacks)
**
**/
#include "gl/system/gl_system.h"
#include "doomtype.h"
#include "colormatcher.h"
#include "i_system.h"
#include "p_local.h"
#include "p_tags.h"
#include "p_lnspec.h"
#include "c_dispatch.h"
#include "r_sky.h"
#include "sc_man.h"
#include "w_wad.h"
#include "gi.h"
#include "g_level.h"
#include "doomstat.h"
#include "d_player.h"
#include "g_levellocals.h"
#include "gl/system/gl_interface.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_lightdata.h"
#include "gl/data/gl_data.h"
#include "gl/dynlights/gl_dynlight.h"
#include "gl/dynlights/gl_glow.h"
#include "gl/models/gl_models.h"
#include "gl/utility/gl_clock.h"
#include "gl/shaders/gl_shader.h"
#include "gl/gl_functions.h"
GLRenderSettings glset;
EXTERN_CVAR(Int, gl_lightmode)
EXTERN_CVAR(Bool, gl_brightfog)
EXTERN_CVAR(Bool, gl_lightadditivesurfaces)
CUSTOM_CVAR(Bool, gl_notexturefill, false, 0)
{
glset.notexturefill = self;
}
void gl_CreateSections();
//==========================================================================
//
// Portal identifier lists
//
//==========================================================================
//==========================================================================
//
// MAPINFO stuff
//
//==========================================================================
struct FGLROptions : public FOptionalMapinfoData
{
FGLROptions()
{
identifier = "gl_renderer";
brightfog = false;
lightmode = -1;
notexturefill = -1;
skyrotatevector = FVector3(0,0,1);
skyrotatevector2 = FVector3(0,0,1);
lightadditivesurfaces = false;
}
virtual FOptionalMapinfoData *Clone() const
{
FGLROptions *newopt = new FGLROptions;
newopt->identifier = identifier;
newopt->lightmode = lightmode;
newopt->notexturefill = notexturefill;
newopt->skyrotatevector = skyrotatevector;
newopt->skyrotatevector2 = skyrotatevector2;
newopt->lightadditivesurfaces = lightadditivesurfaces;
return newopt;
}
int lightmode;
int brightfog;
int8_t lightadditivesurfaces;
int8_t notexturefill;
FVector3 skyrotatevector;
FVector3 skyrotatevector2;
};
DEFINE_MAP_OPTION(brightfog, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
parse.ParseAssign();
parse.sc.MustGetNumber();
opt->brightfog = parse.sc.Number;
}
DEFINE_MAP_OPTION(lightmode, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
parse.ParseAssign();
parse.sc.MustGetNumber();
opt->lightmode = uint8_t(parse.sc.Number);
}
DEFINE_MAP_OPTION(notexturefill, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
if (parse.CheckAssign())
{
parse.sc.MustGetNumber();
opt->notexturefill = !!parse.sc.Number;
}
else
{
opt->notexturefill = true;
}
}
DEFINE_MAP_OPTION(lightadditivesurfaces, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
if (parse.CheckAssign())
{
parse.sc.MustGetNumber();
opt->lightadditivesurfaces = !!parse.sc.Number;
}
else
{
opt->lightadditivesurfaces = true;
}
}
DEFINE_MAP_OPTION(skyrotate, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
parse.ParseAssign();
parse.sc.MustGetFloat();
opt->skyrotatevector.X = (float)parse.sc.Float;
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
parse.sc.MustGetFloat();
opt->skyrotatevector.Y = (float)parse.sc.Float;
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
parse.sc.MustGetFloat();
opt->skyrotatevector.Z = (float)parse.sc.Float;
opt->skyrotatevector.MakeUnit();
}
DEFINE_MAP_OPTION(skyrotate2, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
parse.ParseAssign();
parse.sc.MustGetFloat();
opt->skyrotatevector2.X = (float)parse.sc.Float;
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
parse.sc.MustGetFloat();
opt->skyrotatevector2.Y = (float)parse.sc.Float;
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
parse.sc.MustGetFloat();
opt->skyrotatevector2.Z = (float)parse.sc.Float;
opt->skyrotatevector2.MakeUnit();
}
bool IsLightmodeValid()
{
return (glset.map_lightmode >= 0 && glset.map_lightmode <= 4) || glset.map_lightmode == 8;
}
static void ResetOpts()
{
if (!IsLightmodeValid()) glset.lightmode = gl_lightmode;
else glset.lightmode = glset.map_lightmode;
if (glset.map_notexturefill == -1) glset.notexturefill = gl_notexturefill;
else glset.notexturefill = !!glset.map_notexturefill;
if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog;
else glset.brightfog = !!glset.map_brightfog;
if (glset.map_lightadditivesurfaces == -1) glset.lightadditivesurfaces = gl_lightadditivesurfaces;
else glset.lightadditivesurfaces = !!glset.map_lightadditivesurfaces;
}
void InitGLRMapinfoData()
{
FGLROptions *opt = level.info->GetOptData<FGLROptions>("gl_renderer", false);
if (opt != NULL)
{
glset.map_lightmode = opt->lightmode;
glset.map_lightadditivesurfaces = opt->lightadditivesurfaces;
glset.map_brightfog = opt->brightfog;
glset.map_notexturefill = opt->notexturefill;
glset.skyrotatevector = opt->skyrotatevector;
glset.skyrotatevector2 = opt->skyrotatevector2;
}
else
{
glset.map_lightmode = -1;
glset.map_lightadditivesurfaces = -1;
glset.map_brightfog = -1;
glset.map_notexturefill = -1;
glset.skyrotatevector = FVector3(0, 0, 1);
glset.skyrotatevector2 = FVector3(0, 0, 1);
}
ResetOpts();
}
CCMD(gl_resetmap)
{
ResetOpts();
}
//==========================================================================
//
// Recalculate all heights affecting this vertex.
//
//==========================================================================
void gl_RecalcVertexHeights(vertex_t * v)
{
int i,j,k;
float height;
v->numheights=0;
for(i=0;i<v->numsectors;i++)
{
for(j=0;j<2;j++)
{
if (j==0) height=v->sectors[i]->ceilingplane.ZatPoint(v);
else height=v->sectors[i]->floorplane.ZatPoint(v);
for(k=0;k<v->numheights;k++)
{
if (height == v->heightlist[k]) break;
if (height < v->heightlist[k])
{
memmove(&v->heightlist[k+1], &v->heightlist[k], sizeof(float) * (v->numheights-k));
v->heightlist[k]=height;
v->numheights++;
break;
}
}
if (k==v->numheights) v->heightlist[v->numheights++]=height;
}
}
if (v->numheights<=2) v->numheights=0; // is not in need of any special attention
v->dirty = false;
}
//==========================================================================
//
// dumpgeometry
//
//==========================================================================
CCMD(dumpgeometry)
{
for(auto &sector : level.sectors)
{
Printf(PRINT_LOG, "Sector %d\n", sector.sectornum);
for(int j=0;j<sector.subsectorcount;j++)
{
subsector_t * sub = sector.subsectors[j];
Printf(PRINT_LOG, " Subsector %d - real sector = %d - %s\n", int(sub->Index()), sub->sector->sectornum, sub->hacked&1? "hacked":"");
for(uint32_t k=0;k<sub->numlines;k++)
{
seg_t * seg = sub->firstline + k;
if (seg->linedef)
{
Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, linedef %d, side %d",
seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(),
seg->Index(), seg->linedef->Index(), seg->sidedef != seg->linedef->sidedef[0]);
}
else
{
Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, miniseg",
seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(), seg->Index());
}
if (seg->PartnerSeg)
{
subsector_t * sub2 = seg->PartnerSeg->Subsector;
Printf(PRINT_LOG, ", back sector = %d, real back sector = %d", sub2->render_sector->sectornum, seg->PartnerSeg->frontsector->sectornum);
}
else if (seg->backsector)
{
Printf(PRINT_LOG, ", back sector = %d (no partnerseg)", seg->backsector->sectornum);
}
Printf(PRINT_LOG, "\n");
}
}
}
}

View file

@ -6,24 +6,6 @@
#include "vectors.h" #include "vectors.h"
#include "r_utility.h" #include "r_utility.h"
struct GLRenderSettings
{
int8_t lightmode;
bool notexturefill;
bool brightfog;
bool lightadditivesurfaces;
int8_t map_lightmode;
int8_t map_notexturefill;
int8_t map_brightfog;
int8_t map_lightadditivesurfaces;
FVector3 skyrotatevector;
FVector3 skyrotatevector2;
};
extern GLRenderSettings glset;
#include "r_defs.h" #include "r_defs.h"
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
#include "c_cvars.h" #include "c_cvars.h"
@ -35,7 +17,6 @@ inline int getExtraLight()
return r_viewpoint.extralight * gl_weaponlight; return r_viewpoint.extralight * gl_weaponlight;
} }
void gl_RecalcVertexHeights(vertex_t * v);
struct GLSectorStackPortal; struct GLSectorStackPortal;

View file

@ -50,8 +50,6 @@
#include "gl/utility/gl_clock.h" #include "gl/utility/gl_clock.h"
#include "gl/gl_functions.h" #include "gl/gl_functions.h"
void InitGLRMapinfoData();
//========================================================================== //==========================================================================
// //
// //
@ -580,8 +578,6 @@ void gl_PreprocessLevel()
#if 0 #if 0
gl_CreateSections(); gl_CreateSections();
#endif #endif
InitGLRMapinfoData();
} }

View file

@ -53,8 +53,6 @@ CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL)
GLRenderer->mShaderManager->ResetFixedColormap(); GLRenderer->mShaderManager->ResetFixedColormap();
} }
} }
CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE);
CVAR(Bool, gl_lightadditivesurfaces, false, CVAR_ARCHIVE);
@ -97,14 +95,6 @@ CUSTOM_CVAR(Int,gl_fogmode,1,CVAR_ARCHIVE|CVAR_NOINITCALL)
if (self<0) self=0; if (self<0) self=0;
} }
CUSTOM_CVAR(Int, gl_lightmode, 3 ,CVAR_ARCHIVE|CVAR_NOINITCALL)
{
int newself = self;
if (newself > 4) newself=8; // use 8 for software lighting to avoid conflicts with the bit mask
if (newself < 0) newself=0;
if (self != newself) self = newself;
glset.lightmode = newself;
}
@ -172,7 +162,7 @@ int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon)
if (lightlevel == 0) return 0; if (lightlevel == 0) return 0;
if ((glset.lightmode & 2) && lightlevel < 192 && !weapon) if ((level.lightmode & 2) && lightlevel < 192 && !weapon)
{ {
if (lightlevel > 100) if (lightlevel > 100)
{ {
@ -210,7 +200,7 @@ static PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor)
{ {
int r,g,b; int r,g,b;
if (glset.lightmode == 8) if (level.lightmode == 8)
{ {
return pe; return pe;
} }
@ -276,7 +266,7 @@ float gl_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity)
{ {
float density; float density;
if (glset.lightmode & 4) if (level.lightmode & 4)
{ {
// uses approximations of Legacy's default settings. // uses approximations of Legacy's default settings.
density = level.fogdensity ? level.fogdensity : 18; density = level.fogdensity ? level.fogdensity : 18;
@ -289,9 +279,9 @@ float gl_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity)
else if ((fogcolor.d & 0xffffff) == 0) else if ((fogcolor.d & 0xffffff) == 0)
{ {
// case 2: black fog // case 2: black fog
if (glset.lightmode != 8 && !(level.flags3 & LEVEL3_NOLIGHTFADE)) if (level.lightmode != 8 && !(level.flags3 & LEVEL3_NOLIGHTFADE))
{ {
density = distfogtable[glset.lightmode != 0][gl_ClampLight(lightlevel)]; density = distfogtable[level.lightmode != 0][gl_ClampLight(lightlevel)];
} }
else else
{ {
@ -350,7 +340,7 @@ bool gl_CheckFog(sector_t *frontsector, sector_t *backsector)
else if (level.outsidefogdensity != 0 && APART(level.info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (level.info->outsidefog & 0xffffff)) else if (level.outsidefogdensity != 0 && APART(level.info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (level.info->outsidefog & 0xffffff))
{ {
} }
else if (level.fogdensity!=0 || (glset.lightmode & 4)) else if (level.fogdensity!=0 || (level.lightmode & 4))
{ {
// case 3: level has fog density set // case 3: level has fog density set
} }
@ -369,7 +359,7 @@ bool gl_CheckFog(sector_t *frontsector, sector_t *backsector)
{ {
return false; return false;
} }
else if (level.fogdensity!=0 || (glset.lightmode & 4)) else if (level.fogdensity!=0 || (level.lightmode & 4))
{ {
// case 3: level has fog density set // case 3: level has fog density set
return false; return false;
@ -459,7 +449,7 @@ void gl_SetFog(int lightlevel, int rellight, bool fullbright, const FColormap *c
} }
else else
{ {
if (glset.lightmode == 2 && fogcolor == 0) if (level.lightmode == 2 && fogcolor == 0)
{ {
float light = gl_CalcLightLevel(lightlevel, rellight, false); float light = gl_CalcLightLevel(lightlevel, rellight, false);
gl_SetShaderLight(light, lightlevel); gl_SetShaderLight(light, lightlevel);
@ -480,7 +470,7 @@ void gl_SetFog(int lightlevel, int rellight, bool fullbright, const FColormap *c
gl_RenderState.SetFog(fogcolor, fogdensity); gl_RenderState.SetFog(fogcolor, fogdensity);
// Korshun: fullbright fog like in software renderer. // Korshun: fullbright fog like in software renderer.
if (glset.lightmode == 8 && glset.brightfog && fogdensity != 0 && fogcolor != 0) if (level.lightmode == 8 && level.brightfog && fogdensity != 0 && fogcolor != 0)
{ {
gl_RenderState.SetSoftLightLevel(255); gl_RenderState.SetSoftLightLevel(255);
} }

View file

@ -31,6 +31,7 @@
#include "c_cvars.h" #include "c_cvars.h"
#include "r_defs.h" #include "r_defs.h"
#include "r_data/r_translate.h" #include "r_data/r_translate.h"
#include "g_levellocals.h"
class FVertexBuffer; class FVertexBuffer;
class FShader; class FShader;
@ -356,9 +357,9 @@ public:
mGlowBottom.Set(b[0], b[1], b[2], b[3]); mGlowBottom.Set(b[0], b[1], b[2], b[3]);
} }
void SetSoftLightLevel(int level) void SetSoftLightLevel(int llevel)
{ {
if (glset.lightmode == 8) mLightParms[3] = level / 255.f; if (level.lightmode == 8) mLightParms[3] = llevel / 255.f;
else mLightParms[3] = -1.f; else mLightParms[3] = -1.f;
} }

View file

@ -110,7 +110,7 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli)
{ {
Plane p; Plane p;
if (renderstyle == STYLE_Add && !glset.lightadditivesurfaces) return; // no lights on additively blended surfaces. if (renderstyle == STYLE_Add && !level.lightadditivesurfaces) return; // no lights on additively blended surfaces.
if (dli != NULL && *dli != -1) if (dli != NULL && *dli != -1)
{ {

View file

@ -661,7 +661,7 @@ void FDrawInfo::DrawUnhandledMissingTextures()
if (seg->backsector->GetTexture(sector_t::ceiling) == skyflatnum) continue; if (seg->backsector->GetTexture(sector_t::ceiling) == skyflatnum) continue;
if (seg->backsector->ValidatePortal(sector_t::ceiling) != NULL) continue; if (seg->backsector->ValidatePortal(sector_t::ceiling) != NULL) continue;
if (!glset.notexturefill) FloodUpperGap(seg); if (!level.notexturefill) FloodUpperGap(seg);
} }
validcount++; validcount++;
@ -680,7 +680,7 @@ void FDrawInfo::DrawUnhandledMissingTextures()
if (seg->backsector->GetTexture(sector_t::floor) == skyflatnum) continue; if (seg->backsector->GetTexture(sector_t::floor) == skyflatnum) continue;
if (seg->backsector->ValidatePortal(sector_t::floor) != NULL) continue; if (seg->backsector->ValidatePortal(sector_t::floor) != NULL) continue;
if (!glset.notexturefill) FloodLowerGap(seg); if (!level.notexturefill) FloodLowerGap(seg);
} }
MissingUpperTextures.Clear(); MissingUpperTextures.Clear();
MissingLowerTextures.Clear(); MissingLowerTextures.Clear();

View file

@ -435,9 +435,9 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool
gl_RenderState.mModelMatrix.loadIdentity(); gl_RenderState.mModelMatrix.loadIdentity();
if (!sky2) if (!sky2)
gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, level.info->skyrotatevector.X, level.info->skyrotatevector.Z, level.info->skyrotatevector.Y);
else else
gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, level.info->skyrotatevector2.X, level.info->skyrotatevector2.Z, level.info->skyrotatevector2.Y);
if (sb->faces[5]) if (sb->faces[5])
{ {
@ -501,10 +501,10 @@ void GLSkyPortal::DrawContents()
bool drawBoth = false; bool drawBoth = false;
// We have no use for Doom lighting special handling here, so disable it for this function. // We have no use for Doom lighting special handling here, so disable it for this function.
int oldlightmode = glset.lightmode; int oldlightmode = ::level.lightmode;
if (glset.lightmode == 8) if (::level.lightmode == 8)
{ {
glset.lightmode = 2; ::level.lightmode = 2;
gl_RenderState.SetSoftLightLevel(-1); gl_RenderState.SetSoftLightLevel(-1);
} }
@ -557,7 +557,7 @@ void GLSkyPortal::DrawContents()
gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); gl_RenderState.SetVertexBuffer(GLRenderer->mVBO);
gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); gl_MatrixStack.Pop(gl_RenderState.mViewMatrix);
gl_RenderState.ApplyMatrices(); gl_RenderState.ApplyMatrices();
glset.lightmode = oldlightmode; ::level.lightmode = oldlightmode;
gl_RenderState.SetDepthClamp(oldClamp); gl_RenderState.SetDepthClamp(oldClamp);
} }

View file

@ -1482,8 +1482,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
glseg.fracright = 1; glseg.fracright = 1;
if (gl_seamless) if (gl_seamless)
{ {
if (v1->dirty) gl_RecalcVertexHeights(v1); if (v1->dirty) v1->RecalcVertexHeights();
if (v2->dirty) gl_RecalcVertexHeights(v2); if (v2->dirty) v2->RecalcVertexHeights();
} }
} }
else // polyobjects must be rendered per seg. else // polyobjects must be rendered per seg.

View file

@ -59,7 +59,7 @@ FDynLightData lightdata;
void GLWall::SetupLights() void GLWall::SetupLights()
{ {
if (RenderStyle == STYLE_Add && !glset.lightadditivesurfaces) return; // no lights on additively blended surfaces. if (RenderStyle == STYLE_Add && !level.lightadditivesurfaces) return; // no lights on additively blended surfaces.
// check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.) // check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.)
switch (type) switch (type)

View file

@ -315,7 +315,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
lightlevel = gl_CalcLightLevel(lightlevel, getExtraLight(), true); lightlevel = gl_CalcLightLevel(lightlevel, getExtraLight(), true);
if (glset.lightmode == 8 || lightlevel < 92) if (level.lightmode == 8 || lightlevel < 92)
{ {
// Korshun: the way based on max possible light level for sector like in software renderer. // Korshun: the way based on max possible light level for sector like in software renderer.
float min_L = 36.0 / 31.0 - ((lightlevel / 255.0) * (63.0 / 31.0)); // Lightlevel in range 0-63 float min_L = 36.0 / 31.0 - ((lightlevel / 255.0) * (63.0 / 31.0)); // Lightlevel in range 0-63
@ -335,7 +335,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
} }
// Korshun: fullbright fog in opengl, render weapon sprites fullbright (but don't cancel out the light color!) // Korshun: fullbright fog in opengl, render weapon sprites fullbright (but don't cancel out the light color!)
if (glset.brightfog && ((level.flags&LEVEL_HASFADETABLE) || cm.FadeColor != 0)) if (level.brightfog && ((level.flags&LEVEL_HASFADETABLE) || cm.FadeColor != 0))
{ {
lightlevel = 255; lightlevel = 255;
} }
@ -344,8 +344,8 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
// hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change // hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change
// light mode here to draw the weapon sprite. // light mode here to draw the weapon sprite.
int oldlightmode = glset.lightmode; int oldlightmode = level.lightmode;
if (glset.lightmode == 8) glset.lightmode = 2; if (level.lightmode == 8) level.lightmode = 2;
for(DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) for(DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
{ {
@ -491,7 +491,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.SetObjectColor(0xffffffff);
gl_RenderState.SetDynLight(0, 0, 0); gl_RenderState.SetDynLight(0, 0, 0);
gl_RenderState.EnableBrightmap(false); gl_RenderState.EnableBrightmap(false);
glset.lightmode = oldlightmode; level.lightmode = oldlightmode;
} }
//========================================================================== //==========================================================================

View file

@ -2395,6 +2395,46 @@ int side_t::GetLightLevel (bool foggy, int baselight, bool is3dlight, int *pfake
return baselight; return baselight;
} }
//==========================================================================
//
// Recalculate all heights affecting this vertex.
//
//==========================================================================
void vertex_t::RecalcVertexHeights()
{
int i, j, k;
float height;
numheights = 0;
for (i = 0; i < numsectors; i++)
{
for (j = 0; j<2; j++)
{
if (j == 0) height = (float)sectors[i]->ceilingplane.ZatPoint(this);
else height = (float)sectors[i]->floorplane.ZatPoint(this);
for (k = 0; k < numheights; k++)
{
if (height == heightlist[k]) break;
if (height < heightlist[k])
{
memmove(&heightlist[k + 1], &heightlist[k], sizeof(float) * (numheights - k));
heightlist[k] = height;
numheights++;
break;
}
}
if (k == numheights) heightlist[numheights++] = height;
}
}
if (numheights <= 2) numheights = 0; // is not in need of any special attention
dirty = false;
}
DEFINE_ACTION_FUNCTION(_Secplane, isSlope) DEFINE_ACTION_FUNCTION(_Secplane, isSlope)
{ {
PARAM_SELF_STRUCT_PROLOGUE(secplane_t); PARAM_SELF_STRUCT_PROLOGUE(secplane_t);

View file

@ -110,6 +110,7 @@
#include "p_spec.h" #include "p_spec.h"
#include "p_saveg.h" #include "p_saveg.h"
#include "g_levellocals.h" #include "g_levellocals.h"
#include "c_dispatch.h"
#ifndef NO_EDATA #ifndef NO_EDATA
#include "edata.h" #include "edata.h"
#endif #endif
@ -4294,3 +4295,48 @@ CCMD (lineloc)
} }
#endif #endif
//==========================================================================
//
// dumpgeometry
//
//==========================================================================
CCMD(dumpgeometry)
{
for (auto &sector : level.sectors)
{
Printf(PRINT_LOG, "Sector %d\n", sector.sectornum);
for (int j = 0; j<sector.subsectorcount; j++)
{
subsector_t * sub = sector.subsectors[j];
Printf(PRINT_LOG, " Subsector %d - real sector = %d - %s\n", int(sub->Index()), sub->sector->sectornum, sub->hacked & 1 ? "hacked" : "");
for (uint32_t k = 0; k<sub->numlines; k++)
{
seg_t * seg = sub->firstline + k;
if (seg->linedef)
{
Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, linedef %d, side %d",
seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(),
seg->Index(), seg->linedef->Index(), seg->sidedef != seg->linedef->sidedef[0]);
}
else
{
Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, miniseg",
seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(), seg->Index());
}
if (seg->PartnerSeg)
{
subsector_t * sub2 = seg->PartnerSeg->Subsector;
Printf(PRINT_LOG, ", back sector = %d, real back sector = %d", sub2->render_sector->sectornum, seg->PartnerSeg->frontsector->sectornum);
}
else if (seg->backsector)
{
Printf(PRINT_LOG, ", back sector = %d (no partnerseg)", seg->backsector->sectornum);
}
Printf(PRINT_LOG, "\n");
}
}
}
}

View file

@ -41,7 +41,6 @@
EXTERN_CVAR(Int, screenblocks) EXTERN_CVAR(Int, screenblocks)
EXTERN_CVAR(Float, r_visibility) EXTERN_CVAR(Float, r_visibility)
void InitGLRMapinfoData();
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -183,7 +182,6 @@ void PolyRenderer::SetupPerspectiveMatrix()
if (!bDidSetup) if (!bDidSetup)
{ {
InitGLRMapinfoData();
bDidSetup = true; bDidSetup = true;
} }

View file

@ -138,6 +138,7 @@ struct vertex_t
} }
int Index() const; int Index() const;
void RecalcVertexHeights();
angle_t viewangle; // precalculated angle for clipping angle_t viewangle; // precalculated angle for clipping

View file

@ -1381,7 +1381,7 @@ unsigned char * FTexture::CreateTexBuffer(int translation, int & w, int & h, int
{ {
inf.blend = (EBlend)(BLEND_DESATURATE1 + translation - STRange_Desaturate); inf.blend = (EBlend)(BLEND_DESATURATE1 + translation - STRange_Desaturate);
} }
else if (translation >= STRange_Specialcolormap && translation < STRange_Specialcolormap + SpecialColormaps.Size()) else if (translation >= STRange_Specialcolormap && translation < STRange_Specialcolormap + (int)SpecialColormaps.Size())
{ {
inf.blend = (EBlend)(BLEND_SPECIALCOLORMAP1 + translation - STRange_Specialcolormap); inf.blend = (EBlend)(BLEND_SPECIALCOLORMAP1 + translation - STRange_Specialcolormap);
} }