[PATCH] Implement D3DX__Subtract with a test
David Adam
David.Adam at math.cnrs.fr
Thu Oct 18 11:38:32 CDT 2007
---
dlls/d3dx8/tests/math.c | 23 ++++++++++++++++++++++-
include/d3dx8math.inl | 17 +++++++++++++++++
2 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 06c20d6..78e47d2 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -231,6 +231,17 @@ static void D3X8Vector3Test(void)
expected=3D0.0f;
got =3D D3DXVec3LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
+
+/*_______________D3DXVec3Subtract_______________________*/
+ expectedvec.x =3D 7.0f; expectedvec.y =3D 9.0f; expectedvec.z =3D 6.0f;=
=20
+ D3DXVec3Subtract(&gotvec,&u,&v);
+ expect_vec3(expectedvec,gotvec);
+ /* Tests the case NULL */
+ funcpointer =3D D3DXVec3Subtract(&gotvec,NULL,&v);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+ funcpointer =3D D3DXVec3Subtract(NULL,NULL,NULL);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
}
=20
static void D3X8Vector4Test(void)
@@ -243,7 +254,7 @@ static void D3X8Vector4Test(void)
v.x =3D -3.0f; v.y =3D 4.0f; v.z =3D -5.0f; v.w =3D 7.0;
=20
/*_______________D3DXVec3Add__________________________*/
- expectedvec.x =3D -2.0f; expectedvec.y =3D 6.0f; expectedvec.z =3D -1.0=
f; expectedvec.w =3D 17.0;
+ expectedvec.x =3D -2.0f; expectedvec.y =3D 6.0f; expectedvec.z =3D -1.0=
f; expectedvec.w =3D 17.0f;
D3DXVec4Add(&gotvec,&u,&v);
expect_vec4(expectedvec,gotvec);
/* Tests the case NULL */
@@ -281,6 +292,16 @@ static void D3X8Vector4Test(void)
expected=3D0.0f;
got =3D D3DXVec4LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
+
+/*_______________D3DXVec3Add__________________________*/
+ expectedvec.x =3D 4.0f; expectedvec.y =3D -2.0f; expectedvec.z =3D 9.0f=
; expectedvec.w =3D 3.0f;
+ D3DXVec4Subtract(&gotvec,&u,&v);
+ expect_vec4(expectedvec,gotvec);
+ /* Tests the case NULL */
+ funcpointer =3D D3DXVec4Subtract(&gotvec,NULL,&v);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+ funcpointer =3D D3DXVec4Subtract(NULL,NULL,NULL);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
}
=20
START_TEST(math)
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index d80ab65..266d923 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -122,6 +122,14 @@ static inline FLOAT D3DXVec3LengthSq(CONST D3DXVECTOR3 =
*pv)
return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z);
}
=20
+static inline D3DXVECTOR3* D3DXVec3Subtract(D3DXVECTOR3 *pout, CONST D3DXVE=
CTOR3 *pv1, CONST D3DXVECTOR3 *pv2)
+{
+ if ( !pout || !pv1 || !pv2) return NULL;
+ pout->x =3D pv1->x - pv2->x;
+ pout->y =3D pv1->y - pv2->y;
+ pout->z =3D pv1->z - pv2->z;=20
+ return pout;
+}
/*__________________D3DXVECTOR4_______________________*/
=20
static inline D3DXVECTOR4* D3DXVec4Add(D3DXVECTOR4 *pout, CONST D3DXVECTOR4=
*pv1, CONST D3DXVECTOR4 *pv2)
@@ -152,6 +160,15 @@ static inline FLOAT D3DXVec4LengthSq(CONST D3DXVECTOR4 =
*pv)
return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) + (pv-=
>w) * (pv->w);
}
=20
+static inline D3DXVECTOR4* D3DXVec4Subtract(D3DXVECTOR4 *pout, CONST D3DXVE=
CTOR4 *pv1, CONST D3DXVECTOR4 *pv2)
+{
+ if ( !pout || !pv1 || !pv2) return NULL;
+ pout->x =3D pv1->x - pv2->x;
+ pout->y =3D pv1->y - pv2->y;
+ pout->z =3D pv1->z - pv2->z;=20
+ pout->w =3D pv1->w - pv2->w;
+ return pout;
+}
/*__________________D3DXQUATERNION____________________*/
=20
static inline FLOAT D3DXQuaternionDot(CONST D3DXQUATERNION *pq1, CONST D3DX=
QUATERNION *pq2)
--=20
1.5.3.2
--=_2xp16ycmuh0k--
More information about the wine-patches
mailing list