Memory Exception using XMFLOAT3 & XMVECTOR

1

I'm trying to implement Pitch/Yaw for my Camera class in D3D, but my Pitch() function, throws a "Access Violation reading location 0x0000008C".

I googled a bit and saw I can't use XMVECTOR in a class/struct because of 16 bit alignment. However I already knew that and I double checked that it was declared as a XMFLOAT3 and it was!

The thing is, in all of my other function of the Camera class (like updating the view matrix, ...) throw no exception. It's just in that one function!

So, here's how I declare my class variable that makes the function to crash (although all my variables make it crash, and they are defined the same way):

XMFLOAT3 mRight;

Here's how I declare the Pitch function:

void Pitch(float a)
{
    //Here it makes my code crash
    XMMATRIX R = XMMatrixRotationAxis(XMLoadFloat3(&mRight), a);

    //Store and compute
    XMStoreFloat3(&mLook, XMVector3TransformNormal(XMLoadFloat3(&mLook), R));
    XMStoreFloat3(&mUp, XMVector3TransformNormal(XMLoadFloat3(&mUp), R));
}

I'm also using x86 as architecture, although x64 gives the exact same results (except the memory location :D). Neither I or the DirectXMath Library can access the x, y and z values of "mRight". In my case "mRight.x" in DirectXMath's case "__m128 x = _mm_load_ss( &pSource->x );".

Some new Debug results: This weirdly happens when I call 'any' function from my WM_MOUSEMOVE event. Even my function Walk(), which works perfectly when I call it when a key is pressed.

Weirdest thing ever!

Thanks for the help!

c++
direct3d
memory-alignment
directxmath
asked on Stack Overflow Sep 28, 2014 by Rakete1111 • edited Sep 30, 2014 by Rakete1111

1 Answer

0

I know my error!! I was giving an invalid pointer to my class that uses that code :D Fixed it

answered on Stack Overflow Sep 30, 2014 by Rakete1111

User contributions licensed under CC BY-SA 3.0