Move ColormapLight to r_light

This commit is contained in:
Magnus Norddahl 2017-01-24 04:24:04 +01:00
parent ca8f71b561
commit f94cced13d
4 changed files with 56 additions and 53 deletions

View file

@ -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);
}
}
}

View file

@ -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);
};
}

View file

@ -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);
}
}
}

View file

@ -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: