From c18134dbd3d032073ae973e1b2d4a4a89ec50971 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 4 Jun 2017 06:05:40 -0400 Subject: [PATCH] - r_vanillatrans: Cache the cache! Transform the function into a global variable and recheck at the start of D_Display --- src/d_main.cpp | 2 ++ src/gl/scene/gl_sprite.cpp | 2 +- src/polyrenderer/scene/poly_sprite.cpp | 2 +- src/r_data/r_vanillatrans.cpp | 1 + src/r_data/r_vanillatrans.h | 3 ++- src/swrenderer/things/r_sprite.cpp | 2 +- 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index b4b6947a6..fbc47da4c 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -670,6 +670,8 @@ void D_Display () cycles.Reset(); cycles.Clock(); + r_UseVanillaTransparency = UseVanillaTransparency(); // [SP] Cache UseVanillaTransparency() call + if (players[consoleplayer].camera == NULL) { players[consoleplayer].camera = players[consoleplayer].mo; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index d50c5722e..c49845688 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -993,7 +993,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { trans = 1.f; } - if (UseVanillaTransparency()) + if (r_UseVanillaTransparency) { // [SP] "canonical transparency" - with the flip of a CVar, disable transparency for Doom objects, // and disable 'additive' translucency for certain objects from other games. diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 10d6772af..5b4927431 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -146,7 +146,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); args.SetClipPlane(clipPlane); - if ((thing->renderflags & RF_ZDOOMTRANS) && UseVanillaTransparency()) + if ((thing->renderflags & RF_ZDOOMTRANS) && r_UseVanillaTransparency) args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); else args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); diff --git a/src/r_data/r_vanillatrans.cpp b/src/r_data/r_vanillatrans.cpp index 01d996d49..73f785e4b 100644 --- a/src/r_data/r_vanillatrans.cpp +++ b/src/r_data/r_vanillatrans.cpp @@ -32,6 +32,7 @@ #include "c_dispatch.h" #endif +bool r_UseVanillaTransparency; CVAR (Int, r_vanillatrans, 2, CVAR_ARCHIVE) namespace diff --git a/src/r_data/r_vanillatrans.h b/src/r_data/r_vanillatrans.h index 5bf1892c7..8fc88b5d7 100644 --- a/src/r_data/r_vanillatrans.h +++ b/src/r_data/r_vanillatrans.h @@ -22,4 +22,5 @@ void UpdateVanillaTransparency(); -bool UseVanillaTransparency(); \ No newline at end of file +bool UseVanillaTransparency(); +extern bool r_UseVanillaTransparency; diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index f28cff787..25cfd58f3 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -213,7 +213,7 @@ namespace swrenderer if (thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->RenderStyle = thing->RenderStyle; - if (UseVanillaTransparency()) + if (r_UseVanillaTransparency) { if (thing->renderflags & RF_ZDOOMTRANS) vis->RenderStyle = LegacyRenderStyles[STYLE_Normal];