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



LinkBack URL
About LinkBacks



CornedBee
Well, that makes it even less likely that the sqrtf() is the problem, unless the resulting number is too large.
. As for the #ifdef __cplusplus code, that is from one of the DirectX header file, not my own code. Its definately not being passed negatives either, making sure of that in the code.