Module: wine Branch: master Commit: 8d8a5f06c2862080cc74fe923465643b40417a8d URL: http://source.winehq.org/git/wine.git/?a=commit;h=8d8a5f06c2862080cc74fe9234...
Author: David Adam David.Adam@math.cnrs.fr Date: Sun Oct 14 20:31:58 2007 +0200
d3dx8: Implement D3DXVec2Lerp with a test.
---
dlls/d3dx8/tests/math.c | 10 ++++++++++ include/d3dx8math.h | 1 + include/d3dx8math.inl | 9 +++++++++ 3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c index 95452b3..9ae9018 100644 --- a/dlls/d3dx8/tests/math.c +++ b/dlls/d3dx8/tests/math.c @@ -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); diff --git a/include/d3dx8math.h b/include/d3dx8math.h index d39563c..cb1753b 100644 --- a/include/d3dx8math.h +++ b/include/d3dx8math.h @@ -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); diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl index 81543c1..336ef5a 100644 --- a/include/d3dx8math.inl +++ b/include/d3dx8math.inl @@ -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;