- cleanup of GL renderer interface and improper header use in software renderer.

This commit is contained in:
Christoph Oelckers 2017-03-16 18:51:54 +01:00
parent 245a9ef80c
commit 2b2c986bd0
14 changed files with 42 additions and 61 deletions

View file

@ -55,8 +55,6 @@
**
*/
#include "gl/system/gl_system.h"
#include "templates.h"
#include "m_random.h"
#include "p_local.h"
@ -205,14 +203,14 @@ void ADynamicLight::Activate(AActor *activator)
if (lighttype == PulseLight)
{
float pulseTime = specialf1 / TICRATE;
float pulseTime = float(specialf1 / TICRATE);
m_lastUpdate = level.maptime;
if (!swapped) m_cycler.SetParams(float(args[LIGHT_SECONDARY_INTENSITY]), float(args[LIGHT_INTENSITY]), pulseTime);
else m_cycler.SetParams(float(args[LIGHT_INTENSITY]), float(args[LIGHT_SECONDARY_INTENSITY]), pulseTime);
m_cycler.ShouldCycle(true);
m_cycler.SetCycleType(CYCLE_Sin);
m_currentRadius = m_cycler.GetVal();
m_currentRadius = float(m_cycler.GetVal());
}
if (m_currentRadius <= 0) m_currentRadius = 1;
}
@ -261,14 +259,14 @@ void ADynamicLight::Tick()
m_lastUpdate = level.maptime;
m_cycler.Update(diff);
m_currentRadius = m_cycler.GetVal();
m_currentRadius = float(m_cycler.GetVal());
break;
}
case FlickerLight:
{
int rnd = randLight();
float pct = specialf1 / 360.f;
float pct = float(specialf1 / 360.f);
m_currentRadius = float(args[LIGHT_INTENSITY + (rnd >= pct * 255)]);
break;
@ -696,7 +694,7 @@ void ADynamicLight::LinkLight()
// passing in radius*radius allows us to do a distance check without any calls to sqrt
subsector_t * subSec = R_PointInSubsector(Pos());
::validcount++;
CollectWithinRadius(Pos(), subSec, radius*radius);
CollectWithinRadius(Pos(), subSec, float(radius*radius));
}

View file

@ -62,17 +62,6 @@ EXTERN_CVAR(Bool, gl_brightfog)
EXTERN_CVAR(Bool, gl_lightadditivesurfaces)
CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE|CVAR_SERVERINFO)
{
if (self>90.f) self=90.f;
else if (self<-90.f) self=-90.f;
if (usergame)
{
// [SP] Update pitch limits to the netgame/gamesim.
players[consoleplayer].SendPitchLimits();
}
}
CUSTOM_CVAR(Bool, gl_notexturefill, false, 0)
{
glset.notexturefill = self;

View file

@ -56,7 +56,7 @@ struct FGLLinePortal
int validcount = 0;
};
extern TArray<FPortal *> portals;
extern TArray<FPortal *> glSectorPortals;
extern TArray<FGLLinePortal*> linePortalToGL;
extern TArray<uint8_t> currentmapsection;

View file

@ -72,7 +72,7 @@ typedef TArray<FPortalSector> FPortalSectors;
typedef TMap<FPortalID, FPortalSectors> FPortalMap;
TArray<FPortal *> portals;
TArray<FPortal *> glSectorPortals;
TArray<FGLLinePortal*> linePortalToGL;
TArray<FGLLinePortal> glLinePortals;
@ -371,7 +371,7 @@ void gl_InitPortals()
}
CollectPortalSectors(collection);
portals.Clear();
glSectorPortals.Clear();
FPortalMap::Iterator it(collection);
FPortalMap::Pair *pair;
@ -386,14 +386,14 @@ void gl_InitPortals()
}
for (int i=1;i<=2;i<<=1)
{
// add separate portals for floor and ceiling.
// add separate glSectorPortals for floor and ceiling.
if (planeflags & i)
{
FPortal *portal = new FPortal;
portal->mDisplacement = pair->Key.mDisplacement;
portal->plane = (i==1? sector_t::floor : sector_t::ceiling); /**/
portal->glportal = NULL;
portals.Push(portal);
glSectorPortals.Push(portal);
for(unsigned j=0;j<pair->Value.Size(); j++)
{
sector_t *sec = pair->Value[j].mSub;
@ -412,7 +412,7 @@ void gl_InitPortals()
}
}
// Now group the line portals (each group must be a continuous set of colinear linedefs with no gaps)
// Now group the line glSectorPortals (each group must be a continuous set of colinear linedefs with no gaps)
glLinePortals.Clear();
linePortalToGL.Clear();
TArray<int> tempindex;
@ -433,7 +433,7 @@ void gl_InitPortals()
FGLLinePortal &glport = glLinePortals[glLinePortals.Reserve(1)];
glport.lines.Push(&linePortals[i]);
// We cannot do this grouping for non-linked portals because they can be changed at run time.
// We cannot do this grouping for non-linked glSectorPortals because they can be changed at run time.
if (linePortals[i].mType == PORTT_LINKED && pLine != nullptr)
{
glport.v1 = pLine->v1;
@ -448,7 +448,7 @@ void gl_InitPortals()
{
line_t *pSrcLine2 = linePortals[j].mOrigin;
line_t *pLine2 = linePortals[j].mDestination;
// angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical portals aren't found here.)
// angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical glSectorPortals aren't found here.)
unsigned srcang = pSrcLine->Delta().Angle().BAMs();
unsigned dstang = pLine->Delta().Angle().BAMs();
if ((pSrcLine->v2 == pSrcLine2->v1 && pLine->v1 == pLine2->v2) ||
@ -486,18 +486,18 @@ void gl_InitPortals()
CCMD(dumpportals)
{
for(unsigned i=0;i<portals.Size(); i++)
for(unsigned i=0;i<glSectorPortals.Size(); i++)
{
double xdisp = portals[i]->mDisplacement.X;
double ydisp = portals[i]->mDisplacement.Y;
Printf(PRINT_LOG, "Portal #%d, %s, displacement = (%f,%f)\n", i, portals[i]->plane==0? "floor":"ceiling",
double xdisp = glSectorPortals[i]->mDisplacement.X;
double ydisp = glSectorPortals[i]->mDisplacement.Y;
Printf(PRINT_LOG, "Portal #%d, %s, displacement = (%f,%f)\n", i, glSectorPortals[i]->plane==0? "floor":"ceiling",
xdisp, ydisp);
Printf(PRINT_LOG, "Coverage:\n");
for(int j=0;j<numsubsectors;j++)
{
subsector_t *sub = &subsectors[j];
FPortal *port = sub->render_sector->GetGLPortal(portals[i]->plane);
if (port == portals[i])
FPortal *port = sub->render_sector->GetGLPortal(glSectorPortals[i]->plane);
if (port == glSectorPortals[i])
{
Printf(PRINT_LOG, "\tSubsector %d (%d):\n\t\t", j, sub->render_sector->sectornum);
for(unsigned k = 0;k< sub->numlines; k++)
@ -505,7 +505,7 @@ CCMD(dumpportals)
Printf(PRINT_LOG, "(%.3f,%.3f), ", sub->firstline[k].v1->fX() + xdisp, sub->firstline[k].v1->fY() + ydisp);
}
Printf(PRINT_LOG, "\n\t\tCovered by subsectors:\n");
FPortalCoverage *cov = &sub->portalcoverage[portals[i]->plane];
FPortalCoverage *cov = &sub->portalcoverage[glSectorPortals[i]->plane];
for(int l = 0;l< cov->sscount; l++)
{
subsector_t *csub = &subsectors[cov->subsectors[l]];

View file

@ -488,12 +488,6 @@ static void PrepareSegs()
int *segcount = new int[numsides];
int realsegs = 0;
// Get floatng point coordinates of vertices
for(auto &v : level.vertexes)
{
v.dirty = true;
}
// count the segs
memset(segcount, 0, numsides * sizeof(int));
@ -638,11 +632,11 @@ void gl_CleanLevelData()
}
}
}
for(unsigned i=0;i<portals.Size(); i++)
for(unsigned i=0;i<glSectorPortals.Size(); i++)
{
delete portals[i];
delete glSectorPortals[i];
}
portals.Clear();
glSectorPortals.Clear();
}

View file

@ -265,7 +265,7 @@ void GLSceneDrawer::CreateScene()
ProcessAll.Clock();
// clip the scene and fill the drawlists
for(unsigned i=0;i<portals.Size(); i++) portals[i]->glportal = NULL;
for(unsigned i=0;i<glSectorPortals.Size(); i++) glSectorPortals[i]->glportal = NULL;
GLRenderer->gl_spriteindex=0;
Bsp.Clock();
GLRenderer->mVBO->Map();
@ -459,7 +459,7 @@ void GLSceneDrawer::RenderTranslucent()
//-----------------------------------------------------------------------------
//
// gl_drawscene - this function renders the scene from the current
// viewpoint, including mirrors and skyboxes and other portals
// viewpoint, including mirrors and skyboxes and other glSectorPortals
// It is assumed that the GLPortal::EndFrame returns with the
// stencil, z-buffer and the projection matrix intact!
//
@ -510,7 +510,7 @@ void GLSceneDrawer::DrawScene(int drawmode)
gl_RenderState.ApplyMatrices();
}
// Handle all portals after rendering the opaque objects but before
// Handle all glSectorPortals after rendering the opaque objects but before
// doing all translucent stuff
recursion++;
GLPortal::EndFrame();

View file

@ -28,7 +28,6 @@
#include "r_data/r_translate.h"
#include "r_data/r_interpolate.h"
#include "poly_renderer.h"
#include "gl/data/gl_data.h"
#include "d_net.h"
#include "po_man.h"
#include "st_stuff.h"

View file

@ -30,7 +30,6 @@
#include "poly_portal.h"
#include "polyrenderer/poly_renderer.h"
#include "swrenderer/scene/r_light.h"
#include "gl/data/gl_data.h"
/////////////////////////////////////////////////////////////////////////////

View file

@ -28,7 +28,6 @@
#include "r_data/r_translate.h"
#include "polyrenderer/scene/poly_scene.h"
#include "polyrenderer/poly_renderer.h"
#include "gl/data/gl_data.h"
#include "swrenderer/scene/r_light.h"
CVAR(Bool, r_debug_cull, 0, 0)

View file

@ -132,6 +132,7 @@ struct vertex_t
int Index() const;
angle_t viewangle; // precalculated angle for clipping
int angletime; // recalculation time for view angle
bool dirty; // something has changed and needs to be recalculated
@ -1023,6 +1024,7 @@ public:
// killough 3/7/98: support flat heights drawn at another sector's heights
sector_t *heightsec; // other sector, or NULL if no other sector
FLightNode * lighthead;
uint32_t bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps
// [RH] these can also be blend values if
@ -1066,7 +1068,6 @@ public:
double transdoorheight; // for transparent door hacks
subsector_t ** subsectors;
FPortal * portals[2]; // floor and ceiling portals
FLightNode * lighthead;
enum
{
@ -1138,12 +1139,12 @@ struct side_t
DBaseDecal* AttachedDecals; // [RH] Decals bound to the wall
part textures[3];
line_t *linedef;
//uint32_t linenum;
uint32_t LeftSide, RightSide; // [RH] Group walls into loops
uint16_t TexelLength;
int16_t Light;
uint8_t Flags;
int UDMFIndex; // needed to access custom UDMF fields which are stored in loading order.
FLightNode * lighthead; // all dynamic lights that may affect this wall
int GetLightLevel (bool foggy, int baselight, bool is3dlight=false, int *pfakecontrast_usedbygzdoom=NULL) const;
@ -1254,7 +1255,6 @@ struct side_t
int Index() const;
//For GL
FLightNode * lighthead; // all blended lights that may affect this wall
seg_t **segs; // all segs belonging to this sidedef in ascending order. Used for precise rendering
int numsegs;

View file

@ -1115,3 +1115,14 @@ CUSTOM_CVAR(Float, transsouls, 0.75f, CVAR_ARCHIVE)
self = 1.f;
}
}
CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE | CVAR_SERVERINFO)
{
if (self>90.f) self = 90.f;
else if (self<-90.f) self = -90.f;
if (usergame)
{
// [SP] Update pitch limits to the netgame/gamesim.
players[consoleplayer].SendPitchLimits();
}
}

View file

@ -36,7 +36,6 @@
#include "v_palette.h"
#include "r_data/colormaps.h"
#include "r_draw_rgba.h"
//#include "gl/data/gl_matrix.h"
#include "swrenderer/viewport/r_viewport.h"
#include "swrenderer/scene/r_light.h"
#ifdef NO_SSE

View file

@ -51,10 +51,6 @@
#include "p_setup.h"
#include "g_levellocals.h"
void gl_InitData();
void gl_PreprocessLevel();
void gl_CleanLevelData();
EXTERN_CVAR(Bool, r_shadercolormaps)
EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom
@ -352,7 +348,6 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
void FSoftwareRenderer::PreprocessLevel()
{
gl_PreprocessLevel();
// This just sets the default colormap for the spftware renderer.
NormalLight.Maps = realcolormaps.Maps;
NormalLight.ChangeColor(PalEntry(255, 255, 255), 0);
@ -375,7 +370,6 @@ void FSoftwareRenderer::PreprocessLevel()
void FSoftwareRenderer::CleanLevelData()
{
gl_CleanLevelData();
}
double FSoftwareRenderer::GetVisibility()

View file

@ -32,7 +32,6 @@
#include "d_player.h"
#include "swrenderer/scene/r_light.h"
#include "swrenderer/viewport/r_viewport.h"
#include "gl/data/gl_data.h"
CVAR(Bool, r_shadercolormaps, true, CVAR_ARCHIVE)
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)