我可以简化以下语句以使其更人性化吗?我可以按照对齐要求逐步进行以下乘法吗?
DirectX::XMStoreFloat4x4(&this->worldTransform, DirectX::XMMatrixMultiply(DirectX::XMMatrixMultiply(DirectX::XMMatrixScalingFromVector(DirectX::XMLoadFloat4(&this->scaling)), DirectX::XMMatrixRotationQuaternion(DirectX::XMLoadFloat4(&this->rotation))), DirectX::XMMatrixTranslationFromVector(DirectX::XMLoadFloat4(&this->translation))));
使用XMVECTOR
和XMMATRIX
局部变量。 生成的代码在优化版本中应相同。
XMVECTOR vTrans = DirectX::XMLoadFloat4(&this->translation);
XMMATRIX mTrans = DirectX::XMMatrixTranslationFromVector(vTrans);
XMVECTOR vScale = DirectX::XMLoadFloat4(&this->scaling);
XMMATRIX mScale = DirectX::XMMatrixScalingFromVector(vScale);
XMVECTOR vRot = DirectX::XMLoadFloat4(&this->rotation);
XMMATRIX mRot = DirectX::XMMatrixRotationQuaternion(rot);
XMMATRIX mTemp = DirectX::XMMatrixMultiply(mScale, mRot);
mTemp = DirectX::XMMatrixMultiply(mTemp, mTrans);
DirectX::XMStoreFloat4x4(&this->worldTransform, mTemp);