On Saturday, 29. May 2010 12:40:17 Michael Menegakis wrote:
> Is it in the end result of the gameplay completely safe? Does it have
> a probability to create inconsistencies or at least visual
> discrepancies?

This "hack" is actually an approximation of the inverse square root function, 
by means of the Newton-Raphson-iteration which is broken off after the first 
iteration. The trick lies in choosing a good initial value for that iteration. 
I haven't understood it myself either why it works, but choosing of initial 
value seems to be done with this line:

        t.i  = 0x5f3759df - ( t.i >> 1 );               // what the fuck?

This code apparently works for all float numbers (except for the negative ones 
of course that cannot be computed) to good accuracy. There's a paper written 
about this here:

http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf

-- 
Thilo Schulz

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
ioquake3 mailing list
ioquake3@lists.ioquake.org
http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org
By sending this message I agree to love ioquake3 and libsdl.

Reply via email to