[PATCH] Implement D3DXVec2Lerp with a test
David Adam
DavidAdam at math.cnrs.fr
Sun Oct 14 13:31:58 CDT 2007
---
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 c0c9a35..083a5f5 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -88,6 +88,16 @@ static void D3X8Vector2Test(void)
got =3D D3DXVec2LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
=20
+/*_______________D3DXVec2Lerp__________________________*/
+ expectedvec.x =3D 68.0f; expectedvec.y =3D -28.5f;
+ D3DXVec2Lerp(&gotvec,&u,&v,scale);
+ expect_vec(expectedvec,gotvec);
+ /* Tests the case NULL */
+ funcpointer =3D D3DXVec2Lerp(&gotvec,NULL,&v,scale);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+ funcpointer =3D D3DXVec2Lerp(NULL,NULL,NULL,scale);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
/*_______________D3DXVec2Maximize__________________________*/
expectedvec.x =3D 3.0f; expectedvec.y =3D 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 D3DXVECTOR=
2 *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, CO=
NST D3DXVECTOR2 *pv2);
D3DXVECTOR2* D3DXVec2Minimize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CO=
NST 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 *p=
v)
return( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
}
=20
+extern inline D3DXVECTOR2* D3DXVec2Lerp(D3DXVECTOR2 *pout, CONST D3DXVECTOR=
2 *pv1, CONST D3DXVECTOR2 *pv2, FLOAT s)
+{
+ if ( !pout || !pv1 || !pv2) return NULL;
+ pout->x =3D (1-s) * (pv1->x) + s * (pv2->x);
+ pout->y =3D (1-s) * (pv1->y) + s * (pv2->y);
+ return pout;
+}
+
extern inline D3DXVECTOR2* D3DXVec2Maximize(D3DXVECTOR2 *pout, CONST D3DXVE=
CTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
{
if ( !pout || !pv1 || !pv2) return NULL;
@@ -66,6 +74,7 @@ extern inline D3DXVECTOR2* D3DXVec2Minimize(D3DXVECTOR2 *p=
out, CONST D3DXVECTOR2
pout->y =3D min(pv1->y , pv2->y);
return pout;
}
+
extern inline D3DXVECTOR2* D3DXVec2Scale(D3DXVECTOR2 *pout, CONST D3DXVECTO=
R2 *pv, FLOAT s)
{
if ( !pout || !pv) return NULL;
--=20
1.5.3.2
--=_2pxwb7jg3nms--
More information about the wine-patches
mailing list