d3dx8: Implement D3DXQuaternionIsIdentity.

This commit is contained in:
David Adam 2007-10-18 23:15:18 +02:00 committed by Alexandre Julliard
parent 4be363ac80
commit 604867c9dd
2 changed files with 21 additions and 2 deletions

View File

@ -32,9 +32,10 @@
static void D3X8QuaternionTest(void)
{
D3DXQUATERNION expectedquat, gotquat, q, r;
D3DXQUATERNION expectedquat, gotquat, q, r, s;
LPD3DXQUATERNION funcpointer;
FLOAT expected, got;
BOOL expectedbool, gotbool;
q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
@ -49,7 +50,6 @@ static void D3X8QuaternionTest(void)
funcpointer = D3DXQuaternionConjugate(NULL,NULL);
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
/*_______________D3DXQuaternionDot______________________*/
expected = 55.0f;
got = D3DXQuaternionDot(&q,&r);
@ -70,6 +70,19 @@ static void D3X8QuaternionTest(void)
funcpointer = D3DXQuaternionIdentity(NULL);
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
/*_______________D3DXQuaternionIsIdentity________________*/
s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
expectedbool = TRUE;
gotbool = D3DXQuaternionIsIdentity(&s);
ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
expectedbool = FALSE;
gotbool = D3DXQuaternionIsIdentity(&q);
ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
/* Test the NULL case */
gotbool = D3DXQuaternionIsIdentity(NULL);
ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
/*_______________D3DXQuaternionLength__________________________*/
expected = 11.0f;
got = D3DXQuaternionLength(&q);

View File

@ -284,6 +284,12 @@ static inline D3DXQUATERNION* D3DXQuaternionIdentity(D3DXQUATERNION *pout)
return pout;
}
static inline BOOL D3DXQuaternionIsIdentity(D3DXQUATERNION *pq)
{
if ( !pq) return FALSE;
return ( (pq->x == 0.0f) && (pq->y == 0.0f) && (pq->z == 0.0f) && (pq->w == 1.0f) );
}
static inline FLOAT D3DXQuaternionLength(CONST D3DXQUATERNION *pq)
{
if (!pq) return 0.0f;