[PATCH] Implement D3DX8Vec2LengthSq with a test
David Adam
DavidAdam at math.cnrs.fr
Sat Oct 13 18:15:30 CDT 2007
---
dlls/d3dx8/tests/math.c | 12 ++++++++++++
include/d3dx8math.h | 1 +
include/d3dx8math.inl | 6 ++++++
3 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 8d22ef4..d8d677c 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -39,7 +39,19 @@ static void D3X8Vector2Test(void)
expected=3D0.0f;
got=3D D3DXVec2Length(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
+
+
+/*_______________D3DXVec2LengthSq________________________*/
+ expected =3D 25.0f;
+ got =3D D3DXVec2LengthSq(&u);
+ ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", e=
xpected, got);
+ /* Tests the case NULL */
+ expected=3D0.0f;
+ got=3D D3DXVec2LengthSq(NULL);
+ ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
+
}
+
START_TEST(math)
{
D3X8Vector2Test();
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index aa561ed..2a98e00 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -59,5 +59,6 @@ typedef struct D3DXCOLOR
} D3DXCOLOR, *LPD3DXCOLOR;
=20
FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
+FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv);
=20
#endif /* __D3DX8MATH_H__ */
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index e9b1b6d..e5ced8d 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -25,4 +25,10 @@ extern inline FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv)
return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
}
=20
+extern inline FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv)
+{
+ if (!pv) return 0.0f;
+ return( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
+}
+
#endif
--=20
1.5.3.2
--=_2e51mdzgg44k--
More information about the wine-patches
mailing list