From 2b2c986bd00541420eeb22a00ffdbdc790f9f6f6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 16 Mar 2017 18:51:54 +0100 Subject: [PATCH] - cleanup of GL renderer interface and improper header use in software renderer. --- src/g_shared/a_dynlight.cpp | 12 +++++------ src/gl/data/gl_data.cpp | 11 ---------- src/gl/data/gl_data.h | 2 +- src/gl/data/gl_portaldata.cpp | 28 +++++++++++++------------- src/gl/data/gl_setup.cpp | 12 +++-------- src/gl/scene/gl_scene.cpp | 6 +++--- src/polyrenderer/poly_renderer.cpp | 1 - src/polyrenderer/scene/poly_portal.cpp | 1 - src/polyrenderer/scene/poly_scene.cpp | 1 - src/r_defs.h | 10 ++++----- src/r_utility.cpp | 11 ++++++++++ src/swrenderer/drawers/r_draw_rgba.cpp | 1 - src/swrenderer/r_swrenderer.cpp | 6 ------ src/swrenderer/scene/r_light.cpp | 1 - 14 files changed, 42 insertions(+), 61 deletions(-) diff --git a/src/g_shared/a_dynlight.cpp b/src/g_shared/a_dynlight.cpp index 1c29f4f9f..e594e6a63 100644 --- a/src/g_shared/a_dynlight.cpp +++ b/src/g_shared/a_dynlight.cpp @@ -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)); } diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index e041e5a05..1515842b9 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -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; diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 5075d9c5f..a46680ab7 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -56,7 +56,7 @@ struct FGLLinePortal int validcount = 0; }; -extern TArray portals; +extern TArray glSectorPortals; extern TArray linePortalToGL; extern TArray currentmapsection; diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 17a31d5be..cc7368249 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -72,7 +72,7 @@ typedef TArray FPortalSectors; typedef TMap FPortalMap; -TArray portals; +TArray glSectorPortals; TArray linePortalToGL; TArray 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;jValue.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 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;imDisplacement.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;jrender_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]]; diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index f1add246d..6c314cdb7 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -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;iglportal = NULL; + for(unsigned i=0;iglportal = 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(); diff --git a/src/polyrenderer/poly_renderer.cpp b/src/polyrenderer/poly_renderer.cpp index 23f659174..f279e2022 100644 --- a/src/polyrenderer/poly_renderer.cpp +++ b/src/polyrenderer/poly_renderer.cpp @@ -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" diff --git a/src/polyrenderer/scene/poly_portal.cpp b/src/polyrenderer/scene/poly_portal.cpp index f19a1e808..2f8ea0031 100644 --- a/src/polyrenderer/scene/poly_portal.cpp +++ b/src/polyrenderer/scene/poly_portal.cpp @@ -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" ///////////////////////////////////////////////////////////////////////////// diff --git a/src/polyrenderer/scene/poly_scene.cpp b/src/polyrenderer/scene/poly_scene.cpp index 2a3b5cc53..7edd216a9 100644 --- a/src/polyrenderer/scene/poly_scene.cpp +++ b/src/polyrenderer/scene/poly_scene.cpp @@ -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) diff --git a/src/r_defs.h b/src/r_defs.h index a6d2b8fd2..74c08e266 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -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; + 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; diff --git a/src/r_utility.cpp b/src/r_utility.cpp index d2d80be66..bcd613af6 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -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(); + } +} diff --git a/src/swrenderer/drawers/r_draw_rgba.cpp b/src/swrenderer/drawers/r_draw_rgba.cpp index 57ea136f1..453071eae 100644 --- a/src/swrenderer/drawers/r_draw_rgba.cpp +++ b/src/swrenderer/drawers/r_draw_rgba.cpp @@ -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 diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index 1c4232a4f..93ac87f7d 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -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() diff --git a/src/swrenderer/scene/r_light.cpp b/src/swrenderer/scene/r_light.cpp index 6e61e3b99..fab0bf7e1 100644 --- a/src/swrenderer/scene/r_light.cpp +++ b/src/swrenderer/scene/r_light.cpp @@ -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)