[PATCH] Implement D3DXVec2Minimize with a test
David Adam
DavidAdam at math.cnrs.fr
Sun Oct 14 12:28:03 CDT 2007
---
dlls/d3dx8/tests/math.c | 11 +++++++++++
include/d3dx8math.h | 1 +
include/d3dx8math.inl | 8 ++++++++
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 18f9970..de32d9f 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -87,6 +87,17 @@ static void D3X8Vector2Test(void)
got =3D D3DXVec2LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
=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 */
+ funcpointer =3D D3DXVec2Minimize(&gotvec,NULL,&v);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+ funcpointer =3D D3DXVec2Minimize(NULL,NULL,NULL);
+ 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 e1c25a1..d71c015 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* D3DXVec2Minimize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CO=
NST D3DXVECTOR2 *pv2);
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 bafee45..0c39d91 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* D3DXVec2Minimize(D3DXVECTOR2 *pout, CONST D3DXVE=
CTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
+{
+ if ( !pout || !pv1 || !pv2) return NULL;
+ pout->x =3D min(pv1->x , pv2->x);
+ pout->y =3D min(pv1->y , pv2->y);
+ return pout;
+}
+
extern inline D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, CONST D3DXVE=
CTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
{
if ( !pout || !pv1 || !pv2) return NULL;
--=20
1.5.3.2
--=_4pgezcicebgg--
More information about the wine-patches
mailing list