d3dx8: Implement D3DXVec2Lerp with a test.

This commit is contained in:
David Adam 2007-10-14 20:31:58 +02:00 committed by Alexandre Julliard
parent 18123a9364
commit 8d8a5f06c2
3 changed files with 20 additions and 0 deletions

View File

@ -88,6 +88,16 @@ static void D3X8Vector2Test(void)
got = D3DXVec2LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec2Lerp__________________________*/
expectedvec.x = 68.0f; expectedvec.y = -28.5f;
D3DXVec2Lerp(&gotvec,&u,&v,scale);
expect_vec(expectedvec,gotvec);
/* Tests the case NULL */
funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
/*_______________D3DXVec2Maximize__________________________*/
expectedvec.x = 3.0f; expectedvec.y = 9.0f;
D3DXVec2Maximize(&gotvec,&u,&v);

View File

@ -63,6 +63,7 @@ FLOAT D3DXVec2CCW(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
FLOAT D3DXVec2Dot(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv);
D3DXVECTOR2* D3DXVec2Lerp(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, FLOAT s);
D3DXVECTOR2* D3DXVec2Maximize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
D3DXVECTOR2* D3DXVec2Minimize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
D3DXVECTOR2* D3DXVec2Scale(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv, FLOAT s);

View File

@ -51,6 +51,14 @@ extern inline FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv)
return( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
}
extern inline D3DXVECTOR2* D3DXVec2Lerp(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, FLOAT s)
{
if ( !pout || !pv1 || !pv2) return NULL;
pout->x = (1-s) * (pv1->x) + s * (pv2->x);
pout->y = (1-s) * (pv1->y) + s * (pv2->y);
return pout;
}
extern inline D3DXVECTOR2* D3DXVec2Maximize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
{
if ( !pout || !pv1 || !pv2) return NULL;
@ -66,6 +74,7 @@ extern inline D3DXVECTOR2* D3DXVec2Minimize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2
pout->y = min(pv1->y , pv2->y);
return pout;
}
extern inline D3DXVECTOR2* D3DXVec2Scale(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv, FLOAT s)
{
if ( !pout || !pv) return NULL;