I am using DirectXMath
, creating XMMatrix
and XMVector
in classes.
When I call XMMatrixMultiply
it throws unhandled exception on it.
I have found online that it is an issue with byte alligment, since DirectXMath
uses SIMD
instructions set which results in missaligned heap allocation.
One of the proposed solution was to use XMFLOAT4X4
variables and then change them to temporary XMMatrix
whenever needed, but it isn't the nicest and fastest solution imo.
Another one was to use _aligned_malloc
, yet I have no idea whatsoever how to use it. I have never had to do any memory allocations and it is black magic for me.
Another one, was to overload new operator
, yet they did not provide any information how to do it.
And regarding the overloading method, I'm not using new
to create XMMatrix
objects since I don't use them as pointers.
It was all working nice untill I have decided to split code into classes.
I think _alligned_malloc
solution would be best here, but I have no idea how to use it, where and when to call it.