From 7d75ad8230e182fe4c6724aed20b6a9302d7fa54 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rico=20Sch=C3=BCller?= Date: Wed, 26 Sep 2012 13:57:05 +0200 Subject: [PATCH] d3dx9: Use float functions in D3DXQuaternionRotationYawPitchRoll(). --- dlls/d3dx9_36/math.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c index 7599a0aa89..3f0e8e4a32 100644 --- a/dlls/d3dx9_36/math.c +++ b/dlls/d3dx9_36/math.c @@ -1424,15 +1424,25 @@ D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix(D3DXQUATERNION *pout, CONST return pout; } -D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll(D3DXQUATERNION *pout, FLOAT yaw, FLOAT pitch, FLOAT roll) +D3DXQUATERNION * WINAPI D3DXQuaternionRotationYawPitchRoll(D3DXQUATERNION *out, FLOAT yaw, FLOAT pitch, FLOAT roll) { - TRACE("(%p, %f, %f, %f)\n", pout, yaw, pitch, roll); + FLOAT syaw, cyaw, spitch, cpitch, sroll, croll; - pout->x = sin( yaw / 2.0f) * cos(pitch / 2.0f) * sin(roll / 2.0f) + cos(yaw / 2.0f) * sin(pitch / 2.0f) * cos(roll / 2.0f); - pout->y = sin( yaw / 2.0f) * cos(pitch / 2.0f) * cos(roll / 2.0f) - cos(yaw / 2.0f) * sin(pitch / 2.0f) * sin(roll / 2.0f); - pout->z = cos(yaw / 2.0f) * cos(pitch / 2.0f) * sin(roll / 2.0f) - sin( yaw / 2.0f) * sin(pitch / 2.0f) * cos(roll / 2.0f); - pout->w = cos( yaw / 2.0f) * cos(pitch / 2.0f) * cos(roll / 2.0f) + sin(yaw / 2.0f) * sin(pitch / 2.0f) * sin(roll / 2.0f); - return pout; + TRACE("out %p, yaw %f, pitch %f, roll %f\n", out, yaw, pitch, roll); + + syaw = sinf(yaw / 2.0f); + cyaw = cosf(yaw / 2.0f); + spitch = sinf(pitch / 2.0f); + cpitch = cosf(pitch / 2.0f); + sroll = sinf(roll / 2.0f); + croll = cosf(roll / 2.0f); + + out->x = syaw * cpitch * sroll + cyaw * spitch * croll; + out->y = syaw * cpitch * croll - cyaw * spitch * sroll; + out->z = cyaw * cpitch * sroll - syaw * spitch * croll; + out->w = cyaw * cpitch * croll + syaw * spitch * sroll; + + return out; } D3DXQUATERNION * WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *out, const D3DXQUATERNION *q1, -- 2.32.0.93.g670b81a890