- move decal light calculations into RenderDecal::RenderDecals

This commit is contained in:
Magnus Norddahl 2019-11-15 06:06:11 +01:00
parent a478cf9a96
commit 9f9884d03c
4 changed files with 12 additions and 17 deletions

View file

@ -443,10 +443,7 @@ namespace swrenderer
// [ZZ] Only if not an active mirror
if (!markportal)
{
ProjectedWallLight walllight;
walllight.SetColormap(mFrontSector, mLineSegment);
walllight.SetLightLeft(Thread, WallC);
RenderDecal::RenderDecals(Thread, mLineSegment->sidedef, draw_segment, mLineSegment, walllight, walltop.ScreenY, wallbottom.ScreenY, false);
RenderDecal::RenderDecals(Thread, draw_segment, mLineSegment, mFrontSector, walltop.ScreenY, wallbottom.ScreenY, false);
}
if (markportal)

View file

@ -229,10 +229,7 @@ namespace swrenderer
RenderWallPart renderWallpart(Thread);
renderWallpart.Render(lightsector, curline, ds->WallC, rw_pic, x1, x2, wallupper.ScreenY, walllower.ScreenY, walltexcoords, top, bot, true, (rover->flags & FF_ADDITIVETRANS) != 0, Alpha);
ProjectedWallLight walllight;
walllight.SetColormap(lightsector, curline);
walllight.SetLightLeft(Thread, ds->WallC);
RenderDecal::RenderDecals(Thread, curline->sidedef, ds, curline, walllight, wallupper.ScreenY, walllower.ScreenY, true);
RenderDecal::RenderDecals(Thread, ds, curline, lightsector, wallupper.ScreenY, walllower.ScreenY, true);
}
void RenderDrawSegment::Render3DFloorWallRange(DrawSegment *ds, int x1, int x2)

View file

@ -53,19 +53,17 @@
#include "swrenderer/r_memory.h"
#include "swrenderer/r_renderthread.h"
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer
{
void RenderDecal::RenderDecals(RenderThread *thread, side_t *sidedef, DrawSegment *draw_segment, seg_t *curline, const ProjectedWallLight &light, const short *walltop, const short *wallbottom, bool drawsegPass)
void RenderDecal::RenderDecals(RenderThread *thread, DrawSegment *draw_segment, seg_t *curline, const sector_t* lightsector, const short *walltop, const short *wallbottom, bool drawsegPass)
{
for (DBaseDecal *decal = sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext)
for (DBaseDecal *decal = curline->sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext)
{
Render(thread, sidedef, decal, draw_segment, curline, light, walltop, wallbottom, drawsegPass);
Render(thread, decal, draw_segment, curline, lightsector, walltop, wallbottom, drawsegPass);
}
}
void RenderDecal::Render(RenderThread *thread, side_t *wall, DBaseDecal *decal, DrawSegment *clipper, seg_t *curline, const ProjectedWallLight &light, const short *walltop, const short *wallbottom, bool drawsegPass)
void RenderDecal::Render(RenderThread *thread, DBaseDecal *decal, DrawSegment *clipper, seg_t *curline, const sector_t* lightsector, const short *walltop, const short *wallbottom, bool drawsegPass)
{
DVector2 decal_left, decal_right, decal_pos;
int x1, x2;
@ -142,7 +140,7 @@ namespace swrenderer
edge_left *= decal->ScaleX;
double dcx, dcy;
decal->GetXY(wall, dcx, dcy);
decal->GetXY(curline->sidedef, dcx, dcy);
decal_pos = { dcx, dcy };
DVector2 angvec = (curline->v2->fPos() - curline->v1->fPos()).Unit();
@ -231,6 +229,9 @@ namespace swrenderer
}
// Prepare lighting
ProjectedWallLight light;
light.SetColormap(lightsector, curline);
light.SetLightLeft(thread, WallC);
usecolormap = light.GetBaseColormap();
// Decals that are added to the scene must fade to black.

View file

@ -12,9 +12,9 @@ namespace swrenderer
class RenderDecal
{
public:
static void RenderDecals(RenderThread *thread, side_t *wall, DrawSegment *draw_segment, seg_t *curline, const ProjectedWallLight &light, const short *walltop, const short *wallbottom, bool drawsegPass);
static void RenderDecals(RenderThread *thread, DrawSegment *draw_segment, seg_t *curline, const sector_t* lightsector, const short *walltop, const short *wallbottom, bool drawsegPass);
private:
static void Render(RenderThread *thread, side_t *wall, DBaseDecal *first, DrawSegment *clipper, seg_t *curline, const ProjectedWallLight &light, const short *walltop, const short *wallbottom, bool drawsegPass);
static void Render(RenderThread *thread, DBaseDecal *first, DrawSegment *clipper, seg_t *curline, const sector_t* lightsector, const short *walltop, const short *wallbottom, bool drawsegPass);
};
}