Hi.
DirectXMath offers lots of opportunities in efficiently using SIMD instructions and different sorts of intrinsics.
It depends a bit on your skills/ knowledge how much of this you want to use, manual memory alignments etc. (__M128).
But.. I am however, not that skilled to user everything, so here's a way you can use it without too much hassle and with a good balance in needed time/ gained effort:
- for all vector and matrix members of classes, I use XMFLOAT (2/3/4X4 etc.), so you don't need to do manual memory alignment
- in all functions with their own scope, including member functions, I use XMVECTOR or XMMATRIX
- using the XMStoreFloat and XMLoadFloat functions, you can easily read out your 'members' and 'save' them back.
This way for the calculations you will get the avantage of the intrinsics, memory efficiency etc.
Two examples:
void CD3dmeshInst::Transform(const DirectX::XMFLOAT4X4 &pMatrix)
{
XMMATRIX xmWorldOld = XMLoadFloat4x4(&mMatWorld);
XMMATRIX xmTransform = XMLoadFloat4x4(&pMatrix);
XMMATRIX xmWorldNew = XMMatrixMultiply(xmWorldOld, xmTransform);
XMStoreFloat4x4(&mMatWorld, xmWorldNew);
mTransformed = true;
}
// transforming a vector with a matrix
XMVECTOR xmCenterOld = XMLoadFloat3(&mSphereCenterModel);
XMMATRIX xmMatWorld = XMLoadFloat4x4(&mMatWorld);
XMVECTOR xmCenterNew = XMVector3TransformCoord(xmCenterOld, xmMatWorld);
XMStoreFloat3(&mBoundingSphere.WorldCenter, xmCenterNew);
Good luck.