- simplify colormap selection to a single function

This commit is contained in:
Magnus Norddahl 2018-12-28 00:55:44 +01:00
commit 4d3d4ea746
13 changed files with 139 additions and 143 deletions

View file

@ -244,14 +244,13 @@ namespace swrenderer
/////////////////////////////////////////////////////////////////////////
void ProjectedWallLight::SetLightLeft(RenderThread *thread, seg_t *lineseg, sector_t *frontsector, const FWallCoords &wallc)
void ProjectedWallLight::SetLightLeft(RenderThread *thread, const FWallCoords &wallc)
{
x1 = wallc.sx1;
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
{
lightlevel = lineseg->sidedef->GetLightLevel(foggy, frontsector->lightlevel);
lightleft = float(thread->Light->WallVis(wallc.sz1, foggy));
lightstep = float((thread->Light->WallVis(wallc.sz2, foggy) - lightleft) / (wallc.sx2 - wallc.sx1));
}
@ -261,4 +260,24 @@ namespace swrenderer
lightstep = 0;
}
}
void ProjectedWallLight::SetColormap(const sector_t *frontsector, seg_t *lineseg, lightlist_t *lit)
{
if (!lit)
{
basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
foggy = level.fadeto || frontsector->Colormap.FadeColor || (level.flags & LEVEL_HASFADETABLE);
if (!(lineseg->sidedef->Flags & WALLF_POLYOBJ))
lightlevel = lineseg->sidedef->GetLightLevel(foggy, frontsector->lightlevel);
else
lightlevel = frontsector->GetLightLevel();
}
else
{
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
foggy = level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE);
lightlevel = lineseg->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
}
}
}