From f94cced13d53ea7e860d6ab48da06ff965c8effa Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 24 Jan 2017 04:24:04 +0100 Subject: [PATCH] Move ColormapLight to r_light --- src/swrenderer/scene/r_light.cpp | 44 +++++++++++++++++++++++ src/swrenderer/scene/r_light.h | 11 ++++++ src/swrenderer/things/r_visiblesprite.cpp | 42 ---------------------- src/swrenderer/things/r_visiblesprite.h | 12 +------ 4 files changed, 56 insertions(+), 53 deletions(-) diff --git a/src/swrenderer/scene/r_light.cpp b/src/swrenderer/scene/r_light.cpp index a1bcc75de..028927c5b 100644 --- a/src/swrenderer/scene/r_light.cpp +++ b/src/swrenderer/scene/r_light.cpp @@ -172,4 +172,48 @@ namespace swrenderer Printf("Visibility cannot be changed in net games.\n"); } } + + ///////////////////////////////////////////////////////////////////////// + + void ColormapLight::SetColormap(double visibility, int shade, FDynamicColormap *basecolormap, bool fullbright, bool invertColormap, bool fadeToBlack) + { + if (fadeToBlack) + { + if (invertColormap) // Fade to white + { + basecolormap = GetSpecialLights(basecolormap->Color, MAKERGB(255, 255, 255), basecolormap->Desaturate); + invertColormap = false; + } + else // Fade to black + { + basecolormap = GetSpecialLights(basecolormap->Color, MAKERGB(0, 0, 0), basecolormap->Desaturate); + } + } + + if (invertColormap) + { + basecolormap = GetSpecialLights(basecolormap->Color, basecolormap->Fade.InverseColor(), basecolormap->Desaturate); + } + + if (fixedcolormap) + { + BaseColormap = fixedcolormap; + ColormapNum = 0; + } + else if (fixedlightlev >= 0) + { + BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap; + ColormapNum = fixedlightlev >> COLORMAPSHIFT; + } + else if (fullbright) + { + BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap; + ColormapNum = 0; + } + else + { + BaseColormap = basecolormap; + ColormapNum = GETPALOOKUP(visibility, shade); + } + } } diff --git a/src/swrenderer/scene/r_light.h b/src/swrenderer/scene/r_light.h index 26469b37c..44f1b49f5 100644 --- a/src/swrenderer/scene/r_light.h +++ b/src/swrenderer/scene/r_light.h @@ -49,6 +49,8 @@ // Converts fixedlightlev into a shade value #define FIXEDLIGHT2SHADE(lightlev) (((lightlev) >> COLORMAPSHIFT) << FRACBITS) +struct FSWColormap; + namespace swrenderer { extern double r_BaseVisibility; @@ -67,4 +69,13 @@ namespace swrenderer double R_GetVisibility(); void R_SetupColormap(AActor *actor); + + class ColormapLight + { + public: + int ColormapNum = 0; + FSWColormap *BaseColormap = nullptr; + + void SetColormap(double visibility, int shade, FDynamicColormap *basecolormap, bool fullbright, bool invertColormap, bool fadeToBlack); + }; } diff --git a/src/swrenderer/things/r_visiblesprite.cpp b/src/swrenderer/things/r_visiblesprite.cpp index 73cf909f4..0f1088d80 100644 --- a/src/swrenderer/things/r_visiblesprite.cpp +++ b/src/swrenderer/things/r_visiblesprite.cpp @@ -408,46 +408,4 @@ namespace swrenderer spr->Light.BaseColormap = colormap; spr->Light.ColormapNum = colormapnum; } - - void ColormapLight::SetColormap(double visibility, int shade, FDynamicColormap *basecolormap, bool fullbright, bool invertColormap, bool fadeToBlack) - { - if (fadeToBlack) - { - if (invertColormap) // Fade to white - { - basecolormap = GetSpecialLights(basecolormap->Color, MAKERGB(255, 255, 255), basecolormap->Desaturate); - invertColormap = false; - } - else // Fade to black - { - basecolormap = GetSpecialLights(basecolormap->Color, MAKERGB(0, 0, 0), basecolormap->Desaturate); - } - } - - if (invertColormap) - { - basecolormap = GetSpecialLights(basecolormap->Color, basecolormap->Fade.InverseColor(), basecolormap->Desaturate); - } - - if (fixedcolormap) - { - BaseColormap = fixedcolormap; - ColormapNum = 0; - } - else if (fixedlightlev >= 0) - { - BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap; - ColormapNum = fixedlightlev >> COLORMAPSHIFT; - } - else if (fullbright) - { - BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap; - ColormapNum = 0; - } - else - { - BaseColormap = basecolormap; - ColormapNum = GETPALOOKUP(visibility, shade); - } - } } diff --git a/src/swrenderer/things/r_visiblesprite.h b/src/swrenderer/things/r_visiblesprite.h index edc83667e..87abe767a 100644 --- a/src/swrenderer/things/r_visiblesprite.h +++ b/src/swrenderer/things/r_visiblesprite.h @@ -14,24 +14,14 @@ #pragma once #include "swrenderer/line/r_line.h" +#include "swrenderer/scene/r_light.h" #include "swrenderer/scene/r_opaque_pass.h" #include "swrenderer/things/r_visiblespritelist.h" #define MINZ double((2048*4) / double(1 << 20)) -struct FSWColormap; - namespace swrenderer { - class ColormapLight - { - public: - int ColormapNum = 0; - FSWColormap *BaseColormap = nullptr; - - void SetColormap(double visibility, int shade, FDynamicColormap *basecolormap, bool fullbright, bool invertColormap, bool fadeToBlack); - }; - class VisibleSprite { public: