From 34bf6443ce2beee28e193c8f4939ac85340aac39 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 25 Nov 2015 12:07:47 +0000 Subject: [PATCH] Polymodes: Slight optimizations in getshadefactor. git-svn-id: https://svn.eduke32.com/eduke32@5439 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/polymost.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/build/include/polymost.h b/polymer/eduke32/build/include/polymost.h index 1603a3797..3e528cfa1 100644 --- a/polymer/eduke32/build/include/polymost.h +++ b/polymer/eduke32/build/include/polymost.h @@ -72,9 +72,6 @@ static inline int32_t eligible_for_tileshades(int32_t const picnum, int32_t cons static inline float getshadefactor(int32_t const shade) { - int32_t const shadebound = (shadescale_unbounded || shade>=numshades) ? numshades : numshades-1; - float const clamped_shade = min(max(shade*shadescale, 0), shadebound); - // 8-bit tiles, i.e. non-hightiles and non-models, don't get additional // glColor() shading with r_usetileshades! if (getrendermode() == REND_POLYMOST && r_usetileshades && @@ -82,6 +79,10 @@ static inline float getshadefactor(int32_t const shade) eligible_for_tileshades(globalpicnum, globalpal)) return 1.f; + float const shadebound = (float)((shadescale_unbounded || shade>=numshades) ? numshades : numshades-1); + float const scaled_shade = (float)shade*shadescale; + float const clamped_shade = min(max(scaled_shade, 0.f), shadebound); + return ((float)(numshades-clamped_shade))/(float)numshades; }