diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 860e86de0..40420963c 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -594,7 +594,6 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSe for (unsigned i = 0; i < collected_ss.Size(); i++) { subSec = collected_ss[i].sub; - auto &pos = collected_ss[i].pos; touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors); if (subSec->sector->validcount != ::validcount) @@ -603,9 +602,10 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSe subSec->sector->validcount = ::validcount; } - for (unsigned int i = 0; i < subSec->numlines; i++) + for (unsigned int j = 0; j < subSec->numlines; ++j) { - seg_t * seg = subSec->firstline + i; + auto &pos = collected_ss[i].pos; + seg_t *seg = subSec->firstline + j; // check distance from x/y to seg and if within radius add this seg and, if present the opposing subsector (lather/rinse/repeat) // If out of range we do not need to bother with this seg. diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 25ad12344..ca2d32c41 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -196,14 +196,30 @@ int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon) if ((glset.lightmode & 2) && lightlevel < 192 && !weapon) { - light = xs_CRoundToInt(192.f - (192-lightlevel)* 1.95f); + if (lightlevel > 100) + { + light = xs_CRoundToInt(192.f - (192 - lightlevel)* 1.87f); + if (light + rellight < 20) + { + light = 20 + (light + rellight - 20) / 5; + } + else + { + light += rellight; + } + } + else + { + light = (lightlevel + rellight) / 5; + } + } else { - light=lightlevel; + light=lightlevel+rellight; } - return clamp(light+rellight, 0, 255); + return clamp(light, 0, 255); } //========================================================================== diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index f0ddfd642..9e5ea258d 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -363,8 +363,12 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) SetupSprite.Clock(); sector_t * sec=sub->sector; // Handle all things in sector. - for (AActor * thing = sec->thinglist; thing; thing = thing->snext) + for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext) { + auto thing = p->m_thing; + if (thing->validcount == validcount) continue; + thing->validcount = validcount; + FIntCVar *cvar = thing->GetClass()->distancecheck; if (cvar != NULL && *cvar >= 0) { @@ -378,6 +382,7 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) GLRenderer->ProcessSprite(thing, sector, false); } + for (msecnode_t *node = sec->render_thinglist; node; node = node->m_snext) { AActor *thing = node->m_thing; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 5b969d7b9..5cca167d3 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -91,6 +91,7 @@ extern bool r_showviewer; DWORD gl_fixedcolormap; area_t in_area; TArray currentmapsection; +int camtexcount; void gl_ParseDefs(); @@ -1356,6 +1357,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in } tex->SetUpdated(); + camtexcount++; } //========================================================================== diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 48795148c..a015e99d9 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -207,22 +207,25 @@ void OpenGLFrameBuffer::Update() // //========================================================================== -CVAR(Bool, gl_finishbeforeswap, false, 0); +CVAR(Bool, gl_finishbeforeswap, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +extern int camtexcount; void OpenGLFrameBuffer::Swap() { + bool swapbefore = gl_finishbeforeswap && camtexcount == 0; Finish.Reset(); Finish.Clock(); - if (gl_finishbeforeswap) glFinish(); + if (swapbefore) glFinish(); if (needsetgamma) { //DoSetGamma(); needsetgamma = false; } SwapBuffers(); - if (!gl_finishbeforeswap) glFinish(); + if (!swapbefore) glFinish(); Finish.Unclock(); swapped = true; + camtexcount = 0; FHardwareTexture::UnbindAll(); mDebug->Update(); } diff --git a/wadsrc/static/zscript/shared/dynlights.txt b/wadsrc/static/zscript/shared/dynlights.txt index 578354130..f851d88d0 100644 --- a/wadsrc/static/zscript/shared/dynlights.txt +++ b/wadsrc/static/zscript/shared/dynlights.txt @@ -5,6 +5,7 @@ class DynamicLight : Actor native Height 0; Radius 0.1; FloatBobPhase 0; + RenderRadius -1; +NOBLOCKMAP +NOGRAVITY +FIXMAPTHINGPOS