- fixed texture clamping calculations for negative scales.

This commit is contained in:
Christoph Oelckers 2017-02-14 18:20:21 +01:00
parent 2e11b4f346
commit 2e5ada5f25
2 changed files with 40 additions and 16 deletions

View File

@ -192,7 +192,7 @@ private:
bool PutWallCompat(int passflag);
void PutWall(bool translucent);
void PutPortal(int ptype);
void CheckTexturePosition();
void CheckTexturePosition(FTexCoordInfo *tci);
void RenderFogBoundaryCompat();
void RenderLightsCompat(int pass);

View File

@ -626,7 +626,7 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto
//
//==========================================================================
void GLWall::CheckTexturePosition()
void GLWall::CheckTexturePosition(FTexCoordInfo *tci)
{
float sub;
@ -634,6 +634,8 @@ void GLWall::CheckTexturePosition()
// clamp texture coordinates to a reasonable range.
// Extremely large values can cause visual problems
if (tci->mScale.Y > 0)
{
if (tcs[UPLFT].v < tcs[UPRGT].v)
{
sub = float(xs_FloorToInt(tcs[UPLFT].v));
@ -652,6 +654,28 @@ void GLWall::CheckTexturePosition()
{
flags |= GLT_CLAMPY;
}
}
else
{
if (tcs[LOLFT].v < tcs[LORGT].v)
{
sub = float(xs_FloorToInt(tcs[LOLFT].v));
}
else
{
sub = float(xs_FloorToInt(tcs[LORGT].v));
}
tcs[UPLFT].v -= sub;
tcs[UPRGT].v -= sub;
tcs[LOLFT].v -= sub;
tcs[LORGT].v -= sub;
if ((tcs[LOLFT].v == 0.f && tcs[LORGT].v == 0.f && tcs[UPLFT].v <= 1.f && tcs[UPRGT].v <= 1.f) ||
(tcs[LOLFT].v >= 0.f && tcs[LORGT].v >= 0.f && tcs[UPLFT].v == 1.f && tcs[UPRGT].v == 1.f))
{
flags |= GLT_CLAMPY;
}
}
// Check if this is marked as a skybox and if so, do the same for x.
// This intentionally only tests the seg's frontsector.
@ -721,7 +745,7 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg,
else
{
CheckTexturePosition();
CheckTexturePosition(&tci);
// Add this wall to the render list
sector_t * sec = sub ? sub->sector : seg->frontsector;
@ -1139,7 +1163,7 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
tcs[LOLFT].v = tci.FloatToTexV(to - ff_bottomleft);
tcs[LORGT].v = tci.FloatToTexV(to - ff_bottomright);
type = RENDERWALL_FFBLOCK;
CheckTexturePosition();
CheckTexturePosition(&tci);
}
ztop[0] = ff_topleft;