Also calculate wallsprite and decal texture coordinates in ProjectedWallTexcoords

This commit is contained in:
Magnus Norddahl 2019-11-12 18:44:17 +01:00
commit 879fae7cd0
5 changed files with 32 additions and 65 deletions

View file

@ -157,7 +157,7 @@ namespace swrenderer
texturemid = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling));
double rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid);
if (tex->useWorldPanning(curline->GetLevel()))
rowoffset /= fabs(ds->texcoords.yscale);
rowoffset /= fabs(tex->GetScale().Y * curline->sidedef->GetTextureYScale(side_t::mid));
double textop = texturemid + rowoffset - Thread->Viewport->viewpoint.Pos.Z;
// [RH] Don't bother drawing segs that are completely offscreen

View file

@ -432,6 +432,19 @@ namespace swrenderer
Project(viewport, lineseg->sidedef->TexelLength * xscale, x1, x2, WallT);
}
void ProjectedWallTexcoords::ProjectSprite(RenderViewport* viewport, double topZ, double scale, bool flipX, bool flipY, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic)
{
yscale = 1.0 / scale;
texturemid = pic->GetTopOffset(0) + (topZ - viewport->viewpoint.Pos.Z) * yscale;
if (flipY)
{
yscale = -yscale;
texturemid -= pic->GetHeight();
}
Project(viewport, pic->GetWidth(), x1, x2, WallT, flipX);
}
void ProjectedWallTexcoords::Project(RenderViewport *viewport, double walxrepeat, int x1, int x2, const FWallTmapVals &WallT, bool flipx)
{
this->walxrepeat = walxrepeat;

View file

@ -66,19 +66,16 @@ namespace swrenderer
void ProjectBottom(RenderViewport* viewport, sector_t* frontsector, sector_t* backsector, seg_t* lineseg, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic);
void ProjectTranslucent(RenderViewport* viewport, sector_t* frontsector, sector_t* backsector, seg_t* lineseg, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic);
void Project3DFloor(RenderViewport* viewport, F3DFloor* rover, seg_t* lineseg, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic);
void Project(RenderViewport *viewport, double walxrepeat, int x1, int x2, const FWallTmapVals &WallT, bool flipx = false);
void ProjectSprite(RenderViewport* viewport, double topZ, double scale, bool flipX, bool flipY, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic);
float VStep(int x) const;
fixed_t UPos(int x) const;
float yscale = 1.0f;
fixed_t xoffset = 0;
double texturemid = 0.0f;
explicit operator bool() const { return valid; }
private:
void Project(RenderViewport* viewport, double walxrepeat, int x1, int x2, const FWallTmapVals& WallT, bool flipx = false);
static fixed_t GetXOffset(seg_t* lineseg, FSoftwareTexture* tex, side_t::ETexpart texpart);
static double GetRowOffset(seg_t* lineseg, FSoftwareTexture* tex, side_t::ETexpart texpart);
static double GetXScale(side_t* sidedef, FSoftwareTexture* tex, side_t::ETexpart texpart);
@ -93,6 +90,10 @@ namespace swrenderer
FWallTmapVals WallT;
bool flipx;
float yscale = 1.0f;
fixed_t xoffset = 0;
double texturemid = 0.0f;
friend class RenderWallPart;
friend class SpriteDrawerArgs;
};