attempt to fix interpolation when y0>y1

This commit is contained in:
StapleButter 2017-07-10 13:31:05 +02:00
parent 8f031f698b
commit 800540b710
1 changed files with 30 additions and 6 deletions

View File

@ -199,20 +199,44 @@ public:
{
if (xdiff == 0) return y0;
if (wdiff != 0)
return y0 + (((y1 - y0) * yfactor) >> shift);
s32 ybase, ydiff;
if (y1 < y0)
{
ybase = y0;
ydiff = y1 - y0 - 1;
}
else
return y0 + (((y1 - y0) * x) / xdiff);
{
ybase = y0;
ydiff = y1 - y0;
}
if (wdiff != 0)
return ybase + ((ydiff * yfactor) >> shift);
else
return ybase + ((ydiff * x) / xdiff);
}
s32 InterpolateZ(s32 z0, s32 z1, bool wbuffer)
{
if (xdiff == 0) return z0;
if ((wdiff != 0) && wbuffer)
return z0 + (((s64)(z1 - z0) * yfactor) >> shift);
s32 zbase, zdiff;
if (z1 < z0)
{
zbase = z0;
zdiff = z1 - z0 - 1;
}
else
return z0 + (((s64)(z1 - z0) * x) / xdiff);
{
zbase = z0;
zdiff = z1 - z0;
}
if ((wdiff != 0) && wbuffer)
return zbase + (((s64)zdiff * yfactor) >> shift);
else
return zbase + (((s64)zdiff * x) / xdiff);
}
private: