apply the interpolation fix to Z interpolation.

more accurate conversion of Z values.

but this doesn't fix the horrendous Z-fighting in Pokémon B/W because of course it doesn't >_<
This commit is contained in:
StapleButter
2017-07-14 04:49:29 +02:00
parent e1926d6e97
commit cd6ecfc21f
2 changed files with 16 additions and 16 deletions

View File

@ -222,24 +222,24 @@ public:
s32 InterpolateZ(s32 z0, s32 z1, bool wbuffer)
{
if (xdiff == 0) return z0;
s32 zbase, zdiff;
if (z1 < z0)
{
zbase = z0;
zdiff = z1 - z0 - 1;
}
else
{
zbase = z0;
zdiff = z1 - z0;
}
if (xdiff == 0 || z0 == z1) return z0;
if ((wdiff != 0) && wbuffer)
return zbase + (((s64)zdiff * yfactor) >> shift);
{
// perspective-correct approx. interpolation
if (z0 < z1)
return z0 + (((s64)(z1-z0) * yfactor) >> shift);
else
return z1 + (((s64)(z0-z1) * ((1<<shift)-yfactor)) >> shift);
}
else
return zbase + (((s64)zdiff * x) / xdiff);
{
// linear interpolation
if (z0 < z1)
return z0 + (((s64)(z1-z0) * x) / xdiff);
else
return z1 + (((s64)(z0-z1) * (xdiff-x)) / xdiff);
}
}
private: