best approximation so far

This commit is contained in:
Jaklyy 2024-02-10 17:39:40 -05:00
parent 31a7f53282
commit f4bae5a5d5

View File

@ -194,22 +194,23 @@ private:
disp = z0 - z1, disp = z0 - z1,
factor = xdiff - x; factor = xdiff - x;
} }
/*
if (dir) if (dir)
{ {
int shift = 0; return base + disp * factor / xdiff;
while (disp > 0x3FF) }
else*/
{
u32 recip, recip2;
u32 shift = 0;
recip2 = recip = (factor << 16) / xdiff;
while (recip2 > 0x100)
{ {
disp >>= 1; recip2 >>= 1;
shift++; shift++;
} }
disp >>= shift;
return base + ((((s64)disp * factor * xrecip_z) >> 22) << shift); return base + ((disp * recip) >> (16 - shift));
}
else
{
disp >>= 9;
return base + (((s64)disp * factor * xrecip_z) >> 13);
} }
} }
} }