mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
- Stop using sqrt when calculating texture coordinates
This commit is contained in:
parent
a8e379553e
commit
0a4f4aaffd
1 changed files with 13 additions and 9 deletions
|
@ -363,20 +363,24 @@ int RenderPolyWall::GetLightLevel()
|
||||||
|
|
||||||
PolyWallTextureCoordsU::PolyWallTextureCoordsU(FTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart texpart)
|
PolyWallTextureCoordsU::PolyWallTextureCoordsU(FTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart texpart)
|
||||||
{
|
{
|
||||||
double lineLength = side->TexelLength;
|
double t1, t2;
|
||||||
double lineStart = 0.0;
|
double deltaX = line->v2->fX() - line->v1->fX();
|
||||||
|
double deltaY = line->v2->fY() - line->v1->fY();
|
||||||
bool entireSegment = ((lineseg->v1 == line->v1) && (lineseg->v2 == line->v2)) || ((lineseg->v2 == line->v1) && (lineseg->v1 == line->v2));
|
if (fabs(deltaX) > fabs(deltaY))
|
||||||
if (!entireSegment)
|
|
||||||
{
|
{
|
||||||
lineLength = (lineseg->v2->fPos() - lineseg->v1->fPos()).Length();
|
t1 = (lineseg->v1->fX() - line->v1->fX()) / deltaX;
|
||||||
lineStart = (lineseg->v1->fPos() - line->v1->fPos()).Length();
|
t2 = (lineseg->v2->fX() - line->v1->fX()) / deltaX;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
t1 = (lineseg->v1->fY() - line->v1->fY()) / deltaY;
|
||||||
|
t2 = (lineseg->v2->fY() - line->v1->fY()) / deltaY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int texWidth = tex->GetWidth();
|
int texWidth = tex->GetWidth();
|
||||||
double uscale = side->GetTextureXScale(texpart) * tex->Scale.X;
|
double uscale = side->GetTextureXScale(texpart) * tex->Scale.X;
|
||||||
u1 = lineStart + side->GetTextureXOffset(texpart);
|
u1 = t1 * side->TexelLength + side->GetTextureXOffset(texpart);
|
||||||
u2 = u1 + lineLength;
|
u2 = t2 * side->TexelLength + side->GetTextureXOffset(texpart);
|
||||||
u1 *= uscale;
|
u1 *= uscale;
|
||||||
u2 *= uscale;
|
u2 *= uscale;
|
||||||
u1 /= texWidth;
|
u1 /= texWidth;
|
||||||
|
|
Loading…
Reference in a new issue