Module: wine Branch: master Commit: 2cb1372350dd93abf7e06a4fb4f5521c9b7a85fe URL: http://source.winehq.org/git/wine.git/?a=commit;h=2cb1372350dd93abf7e06a4fb4...
Author: Rico Schüller kgbricola@web.de Date: Tue Dec 4 22:10:46 2012 +0100
d3dx9: Improve D3DXMatrixRotationYawPitchRoll().
---
dlls/d3dx9_36/math.c | 39 ++++++++++++++++++++++++++++----------- 1 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c index e09dbec..54dda6e 100644 --- a/dlls/d3dx9_36/math.c +++ b/dlls/d3dx9_36/math.c @@ -631,20 +631,37 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationY(D3DXMATRIX *pout, FLOAT angle) return pout; }
-D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *pout, FLOAT yaw, FLOAT pitch, FLOAT roll) +D3DXMATRIX * WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *out, FLOAT yaw, FLOAT pitch, FLOAT roll) { - D3DXMATRIX m; + FLOAT sroll, croll, spitch, cpitch, syaw, cyaw;
- TRACE("(%p, %f, %f, %f)\n", pout, yaw, pitch, roll); + TRACE("out %p, yaw %f, pitch %f, roll %f\n", out, yaw, pitch, roll);
- D3DXMatrixIdentity(pout); - D3DXMatrixRotationZ(&m, roll); - D3DXMatrixMultiply(pout, pout, &m); - D3DXMatrixRotationX(&m, pitch); - D3DXMatrixMultiply(pout, pout, &m); - D3DXMatrixRotationY(&m, yaw); - D3DXMatrixMultiply(pout, pout, &m); - return pout; + sroll = sinf(roll); + croll = cosf(roll); + spitch = sinf(pitch); + cpitch = cosf(pitch); + syaw = sinf(yaw); + cyaw = cosf(yaw); + + out->u.m[0][0] = sroll * spitch * syaw + croll * cyaw; + out->u.m[0][1] = sroll * cpitch; + out->u.m[0][2] = sroll * spitch * cyaw - croll * syaw; + out->u.m[0][3] = 0.0f; + out->u.m[1][0] = croll * spitch * syaw - sroll * cyaw; + out->u.m[1][1] = croll * cpitch; + out->u.m[1][2] = croll * spitch * cyaw + sroll * syaw; + out->u.m[1][3] = 0.0f; + out->u.m[2][0] = cpitch * syaw; + out->u.m[2][1] = -spitch; + out->u.m[2][2] = cpitch * cyaw; + out->u.m[2][3] = 0.0f; + out->u.m[3][0] = 0.0f; + out->u.m[3][1] = 0.0f; + out->u.m[3][2] = 0.0f; + out->u.m[3][3] = 1.0f; + + return out; }
D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle)