Also calculate wallsprite and decal texture coordinates in ProjectedWallTexcoords
This commit is contained in:
parent
37fdf14422
commit
879fae7cd0
5 changed files with 32 additions and 65 deletions
|
|
@ -69,8 +69,6 @@ namespace swrenderer
|
|||
{
|
||||
DVector2 decal_left, decal_right, decal_pos;
|
||||
int x1, x2;
|
||||
double yscale;
|
||||
uint8_t flipx;
|
||||
double zpos;
|
||||
int needrepeat = 0;
|
||||
sector_t *back;
|
||||
|
|
@ -127,7 +125,6 @@ namespace swrenderer
|
|||
}
|
||||
|
||||
FTexture *tex = TexMan.GetPalettedTexture(decal->PicNum, true);
|
||||
flipx = (uint8_t)(decal->RenderFlags & RF_XFLIP);
|
||||
|
||||
if (tex == NULL || !tex->isValid())
|
||||
{
|
||||
|
|
@ -149,13 +146,11 @@ namespace swrenderer
|
|||
decal_pos = { dcx, dcy };
|
||||
|
||||
DVector2 angvec = (curline->v2->fPos() - curline->v1->fPos()).Unit();
|
||||
float maskedScaleY;
|
||||
|
||||
decal_left = decal_pos - edge_left * angvec - thread->Viewport->viewpoint.Pos;
|
||||
decal_right = decal_pos + edge_right * angvec - thread->Viewport->viewpoint.Pos;
|
||||
|
||||
CameraLight *cameraLight;
|
||||
double texturemid;
|
||||
|
||||
FWallCoords WallC;
|
||||
if (WallC.Init(thread, decal_left, decal_right, TOO_CLOSE_Z))
|
||||
|
|
@ -167,9 +162,6 @@ namespace swrenderer
|
|||
if (x1 >= clipper->x2 || x2 <= clipper->x1)
|
||||
return;
|
||||
|
||||
FWallTmapVals WallT;
|
||||
WallT.InitFromWallCoords(thread, &WallC);
|
||||
|
||||
if (drawsegPass)
|
||||
{
|
||||
uint32_t clipMode = decal->RenderFlags & RF_CLIPMASK;
|
||||
|
|
@ -230,9 +222,6 @@ namespace swrenderer
|
|||
}
|
||||
}
|
||||
|
||||
yscale = decal->ScaleY;
|
||||
texturemid = WallSpriteTile->GetTopOffset(0) + (zpos - thread->Viewport->viewpoint.Pos.Z) / yscale;
|
||||
|
||||
// Clip sprite to drawseg
|
||||
x1 = MAX<int>(clipper->x1, x1);
|
||||
x2 = MIN<int>(clipper->x2, x2);
|
||||
|
|
@ -255,24 +244,12 @@ namespace swrenderer
|
|||
cameraLight = CameraLight::Instance();
|
||||
|
||||
// Draw it
|
||||
bool sprflipvert;
|
||||
if (decal->RenderFlags & RF_YFLIP)
|
||||
{
|
||||
sprflipvert = true;
|
||||
yscale = -yscale;
|
||||
texturemid -= WallSpriteTile->GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
sprflipvert = false;
|
||||
}
|
||||
|
||||
maskedScaleY = float(1 / yscale);
|
||||
FWallTmapVals WallT;
|
||||
WallT.InitFromWallCoords(thread, &WallC);
|
||||
|
||||
ProjectedWallTexcoords walltexcoords;
|
||||
walltexcoords.Project(thread->Viewport.get(), WallSpriteTile->GetWidth(), x1, x2, WallT, flipx);
|
||||
walltexcoords.yscale = maskedScaleY;
|
||||
walltexcoords.texturemid = texturemid;
|
||||
walltexcoords.ProjectSprite(thread->Viewport.get(), zpos, decal->ScaleY, decal->RenderFlags & RF_XFLIP, decal->RenderFlags & RF_YFLIP, x1, x2, WallT, WallSpriteTile);
|
||||
|
||||
do
|
||||
{
|
||||
|
|
@ -288,6 +265,7 @@ namespace swrenderer
|
|||
if (visible)
|
||||
{
|
||||
thread->PrepareTexture(WallSpriteTile, decal->RenderStyle);
|
||||
bool sprflipvert = (decal->RenderFlags & RF_YFLIP);
|
||||
while (x < x2)
|
||||
{
|
||||
if (calclighting)
|
||||
|
|
|
|||
|
|
@ -67,8 +67,6 @@
|
|||
#include "swrenderer/r_memory.h"
|
||||
#include "swrenderer/r_renderthread.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
void RenderWallSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *ppic, const DVector2 &scale, int renderflags, int lightlevel, bool foggy, FDynamicColormap *basecolormap)
|
||||
|
|
@ -162,21 +160,11 @@ namespace swrenderer
|
|||
{
|
||||
auto spr = this;
|
||||
|
||||
int x1, x2;
|
||||
double iyscale;
|
||||
bool sprflipvert;
|
||||
|
||||
x1 = MAX<int>(spr->x1, spr->wallc.sx1);
|
||||
x2 = MIN<int>(spr->x2, spr->wallc.sx2);
|
||||
int x1 = MAX<int>(spr->x1, spr->wallc.sx1);
|
||||
int x2 = MIN<int>(spr->x2, spr->wallc.sx2);
|
||||
if (x1 >= x2)
|
||||
return;
|
||||
|
||||
FWallTmapVals WallT;
|
||||
WallT.InitFromWallCoords(thread, &spr->wallc);
|
||||
|
||||
iyscale = 1 / spr->yscale;
|
||||
double texturemid = (spr->gzt - thread->Viewport->viewpoint.Pos.Z) * iyscale;
|
||||
|
||||
// Prepare lighting
|
||||
|
||||
// Decals that are added to the scene must fade to black.
|
||||
|
|
@ -200,30 +188,18 @@ namespace swrenderer
|
|||
|
||||
// Draw it
|
||||
auto WallSpriteTile = spr->pic;
|
||||
if (spr->renderflags & RF_YFLIP)
|
||||
{
|
||||
sprflipvert = true;
|
||||
iyscale = -iyscale;
|
||||
texturemid -= spr->pic->GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
sprflipvert = false;
|
||||
}
|
||||
|
||||
float maskedScaleY = (float)iyscale;
|
||||
|
||||
int x = x1;
|
||||
FWallTmapVals WallT;
|
||||
WallT.InitFromWallCoords(thread, &spr->wallc);
|
||||
|
||||
ProjectedWallTexcoords walltexcoords;
|
||||
walltexcoords.Project(thread->Viewport.get(), spr->pic->GetWidth(), x1, x2, WallT, spr->renderflags & RF_XFLIP);
|
||||
walltexcoords.yscale = maskedScaleY;
|
||||
walltexcoords.texturemid = texturemid;
|
||||
walltexcoords.ProjectSprite(thread->Viewport.get(), spr->gzt, spr->yscale, spr->renderflags & RF_XFLIP, spr->renderflags & RF_YFLIP, x1, x2, WallT, WallSpriteTile);
|
||||
|
||||
RenderTranslucentPass *translucentPass = thread->TranslucentPass.get();
|
||||
|
||||
thread->PrepareTexture(WallSpriteTile, spr->RenderStyle);
|
||||
while (x < x2)
|
||||
bool sprflipvert = (spr->renderflags & RF_YFLIP);
|
||||
for (int x = x1; x < x2; x++)
|
||||
{
|
||||
if (calclighting)
|
||||
{
|
||||
|
|
@ -233,7 +209,6 @@ namespace swrenderer
|
|||
if (!translucentPass->ClipSpriteColumnWithPortals(x, spr))
|
||||
drawerargs.DrawMaskedColumn(thread, x, WallSpriteTile, walltexcoords, sprflipvert, mfloorclip, mceilingclip, spr->RenderStyle);
|
||||
light += lightstep;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue