- 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); bool PutWallCompat(int passflag);
void PutWall(bool translucent); void PutWall(bool translucent);
void PutPortal(int ptype); void PutPortal(int ptype);
void CheckTexturePosition(); void CheckTexturePosition(FTexCoordInfo *tci);
void RenderFogBoundaryCompat(); void RenderFogBoundaryCompat();
void RenderLightsCompat(int pass); 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; float sub;
@ -634,23 +634,47 @@ void GLWall::CheckTexturePosition()
// clamp texture coordinates to a reasonable range. // clamp texture coordinates to a reasonable range.
// Extremely large values can cause visual problems // Extremely large values can cause visual problems
if (tcs[UPLFT].v < tcs[UPRGT].v) if (tci->mScale.Y > 0)
{ {
sub = float(xs_FloorToInt(tcs[UPLFT].v)); if (tcs[UPLFT].v < tcs[UPRGT].v)
{
sub = float(xs_FloorToInt(tcs[UPLFT].v));
}
else
{
sub = float(xs_FloorToInt(tcs[UPRGT].v));
}
tcs[UPLFT].v -= sub;
tcs[UPRGT].v -= sub;
tcs[LOLFT].v -= sub;
tcs[LORGT].v -= sub;
if ((tcs[UPLFT].v == 0.f && tcs[UPRGT].v == 0.f && tcs[LOLFT].v <= 1.f && tcs[LORGT].v <= 1.f) ||
(tcs[UPLFT].v >= 0.f && tcs[UPRGT].v >= 0.f && tcs[LOLFT].v == 1.f && tcs[LORGT].v == 1.f))
{
flags |= GLT_CLAMPY;
}
} }
else else
{ {
sub = float(xs_FloorToInt(tcs[UPRGT].v)); if (tcs[LOLFT].v < tcs[LORGT].v)
} {
tcs[UPLFT].v -= sub; sub = float(xs_FloorToInt(tcs[LOLFT].v));
tcs[UPRGT].v -= sub; }
tcs[LOLFT].v -= sub; else
tcs[LORGT].v -= sub; {
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[UPLFT].v == 0.f && tcs[UPRGT].v == 0.f && tcs[LOLFT].v <= 1.f && tcs[LORGT].v <= 1.f) || if ((tcs[LOLFT].v == 0.f && tcs[LORGT].v == 0.f && tcs[UPLFT].v <= 1.f && tcs[UPRGT].v <= 1.f) ||
(tcs[UPLFT].v >= 0.f && tcs[UPRGT].v >= 0.f && tcs[LOLFT].v == 1.f && tcs[LORGT].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; flags |= GLT_CLAMPY;
}
} }
// Check if this is marked as a skybox and if so, do the same for x. // Check if this is marked as a skybox and if so, do the same for x.
@ -721,7 +745,7 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg,
else else
{ {
CheckTexturePosition(); CheckTexturePosition(&tci);
// Add this wall to the render list // Add this wall to the render list
sector_t * sec = sub ? sub->sector : seg->frontsector; 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[LOLFT].v = tci.FloatToTexV(to - ff_bottomleft);
tcs[LORGT].v = tci.FloatToTexV(to - ff_bottomright); tcs[LORGT].v = tci.FloatToTexV(to - ff_bottomright);
type = RENDERWALL_FFBLOCK; type = RENDERWALL_FFBLOCK;
CheckTexturePosition(); CheckTexturePosition(&tci);
} }
ztop[0] = ff_topleft; ztop[0] = ff_topleft;