>x2d=(x3d<<8 )/(z3d>>8 ); is accurancy killer. x3d
>becomes a 16:8 number while z3d loses the lowest 8
>bits.
You could try to implement this with something like
- Code:
__int64 tmp = x3d; // go to 64 bits
tmp <<= 16; // pre-adjust (possibly using the 32 high bits)
tmp /= z3d; // do the division
x2d = (int)tmp; // go back to 32-bits
This way you dont drop any bits before the division and get better precision. The computation itself is not as fast but often this doesn't really matter. The speed of many graphics algorithms is limited by memory accesses anyway. So even if this computation turns out to be 5 times slower than the one with less precision, that might not be noticeable.
The improved precision should hopefully be noticeable though. The only way to know is to try it.
/Orpe