[PATCH] Implemennt D3DXVecScale with a test

David Adam DavidAdam at math.cnrs.fr
Sun Oct 14 13:20:01 CDT 2007


---
 dlls/d3dx8/tests/math.c |   15 ++++++++++++---
 include/d3dx8math.h     |    1 +
 include/d3dx8math.inl   |    7 +++++++
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 6a774c3..c0c9a35 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -30,10 +30,11 @@ static void D3X8Vector2Test(void)
 {
     D3DXVECTOR2 expectedvec, gotvec, u, v;
     LPD3DXVECTOR2 funcpointer;
-    FLOAT expected, got;
+    FLOAT expected, got, scale;
=20
     u.x=3D3.0f; u.y=3D4.0f;
     v.x=3D-7.0f; v.y=3D9.0f;
+    scale =3D -6.5f;
=20
 /*_______________D3DXVec2Add__________________________*/
    expectedvec.x =3D -4.0f; expectedvec.y =3D 13.0f;
@@ -89,7 +90,6 @@ static void D3X8Vector2Test(void)
=20
 /*_______________D3DXVec2Maximize__________________________*/
    expectedvec.x =3D 3.0f; expectedvec.y =3D 9.0f;
-   /*gotvec.x=3D0.0f; gotvec.y=3D0.0f;*/
    D3DXVec2Maximize(&gotvec,&u,&v);
    expect_vec(expectedvec,gotvec);
    /* Tests the case NULL */
@@ -100,7 +100,6 @@ static void D3X8Vector2Test(void)
=20
 /*_______________D3DXVec2Minimize__________________________*/
    expectedvec.x =3D -7.0f; expectedvec.y =3D 4.0f;
-   /*vecgot.x=3D0.0f; vecgot.y=3D0.0f;*/
    D3DXVec2Minimize(&gotvec,&u,&v);
    expect_vec(expectedvec,gotvec);
    /* Tests the case NULL */
@@ -109,6 +108,16 @@ static void D3X8Vector2Test(void)
     funcpointer =3D D3DXVec2Minimize(NULL,NULL,NULL);
     ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
=20
+/*_______________D3DXVec2Scale____________________________*/
+    expectedvec.x =3D -19.5f; expectedvec.y =3D -26.0f;
+    D3DXVec2Scale(&gotvec,&u,scale);
+    expect_vec(expectedvec,gotvec);
+    /* Tests the case NULL */
+    funcpointer =3D D3DXVec2Scale(&gotvec,NULL,scale);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+    funcpointer =3D D3DXVec2Scale(NULL,NULL,scale);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
 /*_______________D3DXVec2Subtract__________________________*/
    expectedvec.x =3D 10.0f; expectedvec.y =3D -5.0f;
    D3DXVec2Subtract(&gotvec,&u,&v);
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 04528e9..d39563c 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -65,6 +65,7 @@ FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
 FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv);
 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);
 D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CO=
NST D3DXVECTOR2 *pv2);
=20
 #endif /* __D3DX8MATH_H__ */
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 4852f5f..81543c1 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -66,6 +66,13 @@ extern inline D3DXVECTOR2* D3DXVec2Minimize(D3DXVECTOR2 *=
pout, 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;
+    pout->x =3D s * (pv->x);
+    pout->y =3D s * (pv->y);
+    return pout;
+}
=20
 extern inline D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, CONST D3DXVE=
CTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
 {
--=20
1.5.3.2


--=_4romuon33ack--



More information about the wine-patches mailing list