[PATCH] Implement D3DX__Scale with a test

David Adam David.Adam at math.cnrs.fr
Thu Oct 18 12:53:30 CDT 2007


---
 dlls/d3dx8/tests/math.c |   20 ++++++++++++++++++++
 include/d3dx8math.inl   |   19 +++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 00328f2..ef796f9 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -263,6 +263,16 @@ static void D3X8Vector3Test(void)
     funcpointer =3D D3DXVec3Minimize(NULL,NULL,NULL);
     ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
=20
+/*_______________D3DXVec3Scale____________________________*/
+    expectedvec.x =3D -58.5f; expectedvec.y =3D -39.0f; expectedvec.z =3D -=
13.0f;=20
+    D3DXVec3Scale(&gotvec,&u,scale);
+    expect_vec3(expectedvec,gotvec);
+    /* Tests the case NULL */
+    funcpointer =3D D3DXVec3Scale(&gotvec,NULL,scale);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+    funcpointer =3D D3DXVec3Scale(NULL,NULL,scale);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
 /*_______________D3DXVec3Subtract_______________________*/
     expectedvec.x =3D 7.0f; expectedvec.y =3D 9.0f; expectedvec.z =3D 6.0f;=
=20
     D3DXVec3Subtract(&gotvec,&u,&v);
@@ -355,6 +365,16 @@ static void D3X8Vector4Test(void)
     funcpointer =3D D3DXVec4Minimize(NULL,NULL,NULL);
     ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
=20
+/*_______________D3DXVec4Scale____________________________*/
+    expectedvec.x =3D -6.5f; expectedvec.y =3D -13.0f; expectedvec.z =3D -2=
6.0f; expectedvec.w =3D -65.0f;
+    D3DXVec4Scale(&gotvec,&u,scale);
+    expect_vec4(expectedvec,gotvec);
+    /* Tests the case NULL */
+    funcpointer =3D D3DXVec4Scale(&gotvec,NULL,scale);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+    funcpointer =3D D3DXVec4Scale(NULL,NULL,scale);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
 /*_______________D3DXVec4Subtract__________________________*/
     expectedvec.x =3D 4.0f; expectedvec.y =3D -2.0f; expectedvec.z =3D 9.0f=
; expectedvec.w =3D 3.0f;
     D3DXVec4Subtract(&gotvec,&u,&v);
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 756d911..547dc7b 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -149,6 +149,15 @@ static inline D3DXVECTOR3* D3DXVec3Minimize(D3DXVECTOR3=
 *pout, CONST D3DXVECTOR3
     return pout;
 }
=20
+static inline D3DXVECTOR3* D3DXVec3Scale(D3DXVECTOR3 *pout, CONST D3DXVECTO=
R3 *pv, FLOAT s)
+{
+    if ( !pout || !pv) return NULL;
+    pout->x =3D s * (pv->x);
+    pout->y =3D s * (pv->y);
+    pout->z =3D s * (pv->z);
+    return pout;
+}
+
 static inline D3DXVECTOR3* D3DXVec3Subtract(D3DXVECTOR3 *pout, CONST D3DXVE=
CTOR3 *pv1, CONST D3DXVECTOR3 *pv2)
 {
     if ( !pout || !pv1 || !pv2) return NULL;
@@ -218,6 +227,16 @@ static inline D3DXVECTOR4* D3DXVec4Minimize(D3DXVECTOR4=
 *pout, CONST D3DXVECTOR4
     return pout;
 }
=20
+static inline D3DXVECTOR4* D3DXVec4Scale(D3DXVECTOR4 *pout, CONST D3DXVECTO=
R4 *pv, FLOAT s)
+{
+    if ( !pout || !pv) return NULL;
+    pout->x =3D s * (pv->x);
+    pout->y =3D s * (pv->y);
+    pout->z =3D s * (pv->z);
+    pout->w =3D s * (pv->w);
+    return pout;
+}
+
 static inline D3DXVECTOR4* D3DXVec4Subtract(D3DXVECTOR4 *pout, CONST D3DXVE=
CTOR4 *pv1, CONST D3DXVECTOR4 *pv2)
 {
     if ( !pout || !pv1 || !pv2) return NULL;
--=20
1.5.3.2


--=_2l1f4z0ahdgk--



More information about the wine-patches mailing list