Further isolate texture coordinate calculations to r_wallsetup
This commit is contained in:
parent
c64fafc490
commit
62ec165d28
16 changed files with 176 additions and 174 deletions
|
|
@ -242,18 +242,7 @@ namespace swrenderer
|
|||
}
|
||||
|
||||
ProjectedWallTexcoords walltexcoords;
|
||||
walltexcoords.Project(thread->Viewport.get(), WallSpriteTile->GetWidth(), x1, x2, WallT);
|
||||
|
||||
if (flipx)
|
||||
{
|
||||
int i;
|
||||
int right = (WallSpriteTile->GetWidth() << FRACBITS) - 1;
|
||||
|
||||
for (i = x1; i < x2; i++)
|
||||
{
|
||||
walltexcoords.UPos[i] = right - walltexcoords.UPos[i];
|
||||
}
|
||||
}
|
||||
walltexcoords.Project(thread->Viewport.get(), WallSpriteTile->GetWidth(), x1, x2, WallT, flipx);
|
||||
|
||||
// Prepare lighting
|
||||
usecolormap = light.GetBaseColormap();
|
||||
|
|
@ -302,7 +291,7 @@ namespace swrenderer
|
|||
{ // calculate lighting
|
||||
drawerargs.SetLight(lightpos, light.GetLightLevel(), light.GetFoggy(), thread->Viewport.get());
|
||||
}
|
||||
DrawColumn(thread, drawerargs, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, decal->RenderStyle);
|
||||
drawerargs.DrawMaskedColumn(thread, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, decal->RenderStyle);
|
||||
lightpos += light.GetLightStep();
|
||||
x++;
|
||||
}
|
||||
|
|
@ -315,19 +304,4 @@ namespace swrenderer
|
|||
mfloorclip = wallbottom;
|
||||
} while (needrepeat--);
|
||||
}
|
||||
|
||||
void RenderDecal::DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style)
|
||||
{
|
||||
auto viewport = thread->Viewport.get();
|
||||
|
||||
float iscale = walltexcoords.VStep[x] * maskedScaleY;
|
||||
double spryscale = 1 / iscale;
|
||||
double sprtopscreen;
|
||||
if (sprflipvert)
|
||||
sprtopscreen = viewport->CenterY + texturemid * spryscale;
|
||||
else
|
||||
sprtopscreen = viewport->CenterY - texturemid * spryscale;
|
||||
|
||||
drawerargs.DrawMaskedColumn(thread, x, FLOAT2FIXED(iscale), WallSpriteTile, walltexcoords.UPos[x], spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, style);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,5 @@ namespace swrenderer
|
|||
|
||||
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 DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -405,9 +405,7 @@ namespace swrenderer
|
|||
DrawSegment *ds = segmentlist->Segment(index);
|
||||
|
||||
// determine if the drawseg obscures the sprite
|
||||
if (ds->x1 >= x2 || ds->x2 <= x1 ||
|
||||
(!(ds->silhouette & SIL_BOTH) && ds->maskedtexturecol == nullptr &&
|
||||
!ds->bFogBoundary))
|
||||
if (ds->x1 >= x2 || ds->x2 <= x1 || (!(ds->silhouette & SIL_BOTH) && !ds->texcoords && !ds->bFogBoundary))
|
||||
{
|
||||
// does not cover sprite
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -175,19 +175,10 @@ namespace swrenderer
|
|||
WallT.InitFromWallCoords(thread, &spr->wallc);
|
||||
|
||||
ProjectedWallTexcoords walltexcoords;
|
||||
walltexcoords.Project(thread->Viewport.get(), spr->pic->GetWidth() << FRACBITS, x1, x2, WallT);
|
||||
walltexcoords.Project(thread->Viewport.get(), spr->pic->GetWidth(), x1, x2, WallT, spr->renderflags & RF_XFLIP);
|
||||
|
||||
iyscale = 1 / spr->yscale;
|
||||
double texturemid = (spr->gzt - thread->Viewport->viewpoint.Pos.Z) * iyscale;
|
||||
if (spr->renderflags & RF_XFLIP)
|
||||
{
|
||||
int right = (spr->pic->GetWidth() << FRACBITS) - 1;
|
||||
|
||||
for (int i = x1; i < x2; i++)
|
||||
{
|
||||
walltexcoords.UPos[i] = right - walltexcoords.UPos[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare lighting
|
||||
|
||||
|
|
@ -238,24 +229,9 @@ namespace swrenderer
|
|||
drawerargs.SetLight(light, spr->sector->lightlevel, spr->foggy, thread->Viewport.get());
|
||||
}
|
||||
if (!translucentPass->ClipSpriteColumnWithPortals(x, spr))
|
||||
DrawColumn(thread, drawerargs, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, spr->RenderStyle);
|
||||
drawerargs.DrawMaskedColumn(thread, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, spr->RenderStyle);
|
||||
light += lightstep;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderWallSprite::DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style)
|
||||
{
|
||||
auto viewport = thread->Viewport.get();
|
||||
|
||||
float iscale = walltexcoords.VStep[x] * maskedScaleY;
|
||||
double spryscale = 1 / iscale;
|
||||
double sprtopscreen;
|
||||
if (sprflipvert)
|
||||
sprtopscreen = viewport->CenterY + texturemid * spryscale;
|
||||
else
|
||||
sprtopscreen = viewport->CenterY - texturemid * spryscale;
|
||||
|
||||
drawerargs.DrawMaskedColumn(thread, x, FLOAT2FIXED(iscale), WallSpriteTile, walltexcoords.UPos[x], spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, style);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ namespace swrenderer
|
|||
void Render(RenderThread *thread, short *cliptop, short *clipbottom, int minZ, int maxZ, Fake3DTranslucent clip3DFloor) override;
|
||||
|
||||
private:
|
||||
static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style);
|
||||
|
||||
FWallCoords wallc;
|
||||
uint32_t Translation = 0;
|
||||
uint32_t FillColor = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue