   D3DXMatrixReflect
  What is wrong with the following code?D3DXPLANE mirrorPlane(0.0f, 0.0f, 1.0f, 0.0f); // xy planeD3DXMATRIX R;D3DXMatrixReflect(&R, &mirrorPlane);When I run the program, it crashes constantly due to the D3DXMatrixReflect call. When I use the debugger, it gives the error:Unhandled exception at 0x6366b9b6 (D3DX10d_43.dll) in dX.exe: 0xC0000005: Access violation reading location 0xffffffff.At the top of the call stack, the yellow arrow is pointing to:> D3DX10d_43.dll!intelsse2_D3DXMatrixReflect() + 0x22 bytes The program crashes maybe half of the time I try to run it. What is wrong?
  possible reasons is invalid D3DXMatrix alignement[you use custom allocator?]wrong dll version or sdk mixupit could be some fatal error in ur code that ruins stack position and point to the wrong errortry disabling SSE extension for D3DX math library   ;  You're reflecting the matrix R about the plane mirrorPlane, resulting in reflected matrix R'.  So R must be a valid matrix.   ;Quote:Original post by e3d_ALiVEpossible reasons is invalid D3DXMatrix alignement[you use custom allocator?]Alignment doesn't matter, the D3DX library just won't use the SSE2 version if it's not aligned.Quote:Original post by e3d_ALiVEwrong dll version or sdk mixupit could be some fatal error in ur code that ruins stack position and point to the wrong errorI think that's most likely, especially if it crashes half the time - I'd guess stack corruption.Quote:Original post by Scoob DroolinsYou're reflecting the matrix R about the plane mirrorPlane, resulting in reflected matrix R'.  So R must be a valid matrix.No, D3DXMatrixReflect generates a matrix, it doesn't modify the input matrix (And even if it did, that wouldn't cause an access violation).   ;  It doesn't happen when I link d3dx10.lib, only when I link d3dx10d.lib. I tested it over 100 times and it never crashed once when using d3dx10.lib.Does this mean there is a problem with the dll?   ;  Let me clarify - you have to initialize the matrix R with valid values.  The output (reflected version of R) is assigned to another matrix, like this:D3DXPLANE mirrorPlane(0.0f, 0.0f, 1.0f, 0.0f); // xy planeD3DXMATRIX R (1, 0, 0, 0,  0, 1, 0, 0,  0, 0, 1, 0,  0, 0, 0, 1);D3DXMATRIX Rp = D3DXMatrixReflect(&R, &mirrorPlane);;Quote:Original post by Scoob DroolinsLet me clarify - you have to initialize the matrix R with valid values.  The output (reflected version of R) is assigned to another matrix...That's not what the documentation says:Quote:D3DXMatrixReflectBuilds a matrix that reflects the coordinate system about a plane.ParameterspOut [in, out] Pointer to the D3DXMATRIX structure that is the result of the operation.[snip]P = normalize(Plane);-2 * P.a * P.a + 1  -2 * P.b * P.a -2 * P.c * P.a   0-2 * P.a * P.b -2 * P.b * P.b + 1  -2 * P.c * P.b   0-2 * P.a * P.c -2 * P.b * P.c -2 * P.c * P.c + 1    0-2 * P.a * P.d -2 * P.b * P.d -2 * P.c * P.d   1;Quote:Original post by Scoob DroolinsLet me clarify - you have to initialize the matrix R with valid values.  The output (reflected version of R) is assigned to another matrix, like this:D3DXPLANE mirrorPlane(0.0f, 0.0f, 1.0f, 0.0f); // xy planeD3DXMATRIX R (1, 0, 0, 0,  0, 1, 0, 0,  0, 0, 1, 0,  0, 0, 0, 1);D3DXMATRIX Rp = D3DXMatrixReflect(&R, &mirrorPlane);Even with your code change (only changing line 3 to a pointer), the problem still occurs. So I'm not sure it is relevant to this particular problem.The (temporary) fix is to use the release version of the library and not the debug version. But the mystery remains as to why it happens when using the debug version of the library, and if it is only happening on my machine.;I have the same problem on my machine<br /> <br /> I have the latest SDK (June 2010) and D3DXMatrixReflect crashes with d3dx10d.lib BUT doesn&#39;t crash with d3dx10.lib….<br />I have tried to re-install the SDK but I have the same problem<br /> <br />I have written my own function in order to fix the problem:<br /> <br /><code><br />D3DXMATRIX* D3DXMatrixReflect_Fixed(__inout D3DXMATRIX *pOut, __in const D3DXPLANE *pPlane)<br />{<br />D3DXPLANE P;<br />D3DXPlaneNormalize(&amp;P,pPlane);<br /><br />*pOut = D3DXMATRIX<br />(<br />-2.0f * P.a * P.a + 1.0f,  -2.0f * P.b * P.a   , -2.0f * P.c * P.a ,  0.0f ,<br />-2.0f * P.a * P.b   ,  -2.0f * P.b * P.b + 1.0f , -2.0f * P.c * P.b ,  0.0f ,<br />-2.0f * P.a * P.c   ,  -2.0f * P.b * P.c   , -2.0f * P.c * P.c + 1.0f  ,  0.0f ,<br />-2.0f * P.a * P.d   ,  -2.0f * P.b * P.d   , -2.0f * P.c * P.d ,  1.0f <br />);<br /><br />return pOut;<br />}<br /></code>;  There must be a problem with debug runtime .dlls or .libs,or,with your application configs (debug / release etc.).   