我可以简化以下声明,使其更具人性化吗?关于调整要求,我可以逐步进行乘法运算吗?
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))));
答案 0 :(得分:1)
使用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);