Hi,

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:

Code:
D3DXINLINE FLOAT D3DXVec3Length
    ( CONST D3DXVECTOR3 *pV )
{
#ifdef D3DX_DEBUG
    if(!pV)
        return 0.0f;
#endif

#ifdef __cplusplus
    return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z);   // BREAKING HERE!
#else
    return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z);
#endif
}
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:

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:
Code:
	sqrtf(0.020109955f);
...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,

Skusey