No doubt I am doing something stupid, but I cant get to the bottom of this error, so any help would be massively appreciated! I came across it using dx9.0c, calling the D3DXVec3Length function. Using this function with a certain D3DXVECTOR3 caused:
Unhandled exception at 0x102c6502 (msvcr80d.dll) in blah.exe: 0xC00000FD: Stack overflow.
With the code breaking at:
So I thought instead I will write my own vector length function, using the same idea. Sure enough it had the same problem. By using breakpoints I stopped it before its stack overflow and found that the vector was:
D3DXINLINE FLOAT D3DXVec3Length
( CONST D3DXVECTOR3 *pV )
return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); // BREAKING HERE!
return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z);
pV->x = 0.11898671
pV->y = 0.077150002
pV->z = 0.0
Meaning that the sqrt function's input is 0.020109955. I next tried just writing the code:
...which caused the same over flow. Changing the number to something else however appears to work.
So what glaringly obivous thing have I missed? Is there just something I do not know about the square root function? I am using VC++ 2005. Cheers for any input on this,