d3dx9: Fix D3DXQuaternionInverse to make tests pass in Windows.

This commit is contained in:
David Adam 2009-07-17 11:30:29 +02:00 committed by Alexandre Julliard
parent f59e41e8d5
commit 831d6b5886
2 changed files with 12 additions and 17 deletions

View File

@ -1182,23 +1182,17 @@ D3DXQUATERNION* WINAPI D3DXQuaternionExp(D3DXQUATERNION *pout, CONST D3DXQUATERN
D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq)
{
D3DXQUATERNION out;
FLOAT norm;
norm = D3DXQuaternionLengthSq(pq);
if ( !norm )
{
pout->x = 0.0f;
pout->y = 0.0f;
pout->z = 0.0f;
pout->w = 0.0f;
}
else
{
pout->x = -pq->x / norm;
pout->y = -pq->y / norm;
pout->z = -pq->z / norm;
pout->w = pq->w / norm;
}
out.x = -pq->x / norm;
out.y = -pq->y / norm;
out.z = -pq->z / norm;
out.w = pq->w / norm;
*pout =out;
return pout;
}

View File

@ -699,11 +699,12 @@ static void D3DXQuaternionTest(void)
expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f;
D3DXQuaternionInverse(&gotquat,&q);
expect_vec4(expectedquat,gotquat);
/* test the null quaternion */
expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
D3DXQuaternionInverse(&gotquat,&nul);
expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 10.0f;
D3DXQuaternionInverse(&gotquat,&gotquat);
expect_vec4(expectedquat,gotquat);
/*_______________D3DXQuaternionIsIdentity________________*/
s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
expectedbool = TRUE;