Nopers, it's this one:
I'm assuming you are using a Taylor series approximation to get the square root?
general note: it aint gonna work for doubles (it's manipulating a float outside of the fpu!)
-From tricks of the 3d game programming gurus
Uses regular registers to manipulate a float, basically just shifts the exponent to the right, but you
need to do some jumping jacks in order to do that.
float Faster_Sqrtf(float f)
mov eax, f
sub eax, 0x3f800000
sar eax, 1
add eax, 0x3f800000
mov result, eax
I wrote this one which does the newton-raphson iteration you refer to, but it's ultimately useless because it won't ever beat sqrt(), it's just an interesting exercise, and there's no reason for me to post it really
float IterSqrtf(float r, int numtries)
curry = (currx*currx) - r; //y1
//Check to see if curry is < 0
m = 2 * currx;
b = (-m*currx) + curry;
root = -b / m;
currx = root;
To anyone that is confused what he means, see the picture above!
Even a 6 plane frustum test will fail with volumes that span the frustum
Or the method I've shown above *shameless plug*.
The correct test is to test against all planes and count in's and out's
This intrigues me, I haven't thought of that before. The map editor I use can create faces that aren't convex, e.g. if you create two separate blocks and have them meet to form an L shape the editor may do a CSG operation and the top/bottom face of the unified solid won't be convex. I never actually implemented a fix for it. My initial thinking was to just break the face down into convex sections, but I never implemented it (I are lazy).
The only sure way I know of finding if a point is inside of a complex concave shape is to first find a known point that is outside of the shape and call it the origin. Then cast a ray toward the point in question from the origin and count how many times it crosses a plane