David Adam : d3dx8: Implement D3DX*LengthSq.
Alexandre Julliard
julliard at winehq.org
Mon Oct 22 09:55:44 CDT 2007
Module: wine
Branch: master
Commit: bf9a690dbc43727e2e4207f13197f3baf92fdc80
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bf9a690dbc43727e2e4207f13197f3baf92fdc80
Author: David Adam <David.Adam at math.cnrs.fr>
Date: Thu Oct 18 17:47:50 2007 +0200
d3dx8: Implement D3DX*LengthSq.
---
dlls/d3dx8/tests/math.c | 27 +++++++++++++++++++++++++++
include/d3dx8math.inl | 18 ++++++++++++++++--
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index d0d0b03..a598020 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -41,6 +41,15 @@ static void D3X8QuaternionTest(void)
expected=0.0f;
got = D3DXQuaternionLength(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+
+/*_______________D3DXQuaternionLengthSq________________________*/
+ expected = 121.0f;
+ got = D3DXQuaternionLengthSq(&q);
+ ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+ /* Tests the case NULL */
+ expected=0.0f;
+ got = D3DXQuaternionLengthSq(NULL);
+ ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
}
static void D3X8Vector2Test(void)
@@ -172,6 +181,15 @@ static void D3X8Vector3Test(void)
expected=0.0f;
got = D3DXVec3Length(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+
+/*_______________D3DXVec3LengthSq________________________*/
+ expected = 121.0f;
+ got = D3DXVec3LengthSq(&u);
+ ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+ /* Tests the case NULL */
+ expected=0.0f;
+ got = D3DXVec3LengthSq(NULL);
+ ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
}
static void D3X8Vector4Test(void)
@@ -189,6 +207,15 @@ static void D3X8Vector4Test(void)
expected=0.0f;
got = D3DXVec4Length(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+
+/*_______________D3DXVec4LengthSq________________________*/
+ expected = 121.0f;
+ got = D3DXVec4LengthSq(&u);
+ ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+ /* Tests the case NULL */
+ expected=0.0f;
+ got = D3DXVec4LengthSq(NULL);
+ ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
}
START_TEST(math)
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 94e0019..c8de09b 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -101,6 +101,12 @@ static inline FLOAT D3DXVec3Length(CONST D3DXVECTOR3 *pv)
return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) );
}
+static inline FLOAT D3DXVec3LengthSq(CONST D3DXVECTOR3 *pv)
+{
+ if (!pv) return 0.0f;
+ return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z);
+}
+
/*__________________D3DXVECTOR4_______________________*/
static inline FLOAT D3DXVec4Length(CONST D3DXVECTOR4 *pv)
@@ -109,6 +115,11 @@ static inline FLOAT D3DXVec4Length(CONST D3DXVECTOR4 *pv)
return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) + (pv->w) * (pv->w) );
}
+static inline FLOAT D3DXVec4LengthSq(CONST D3DXVECTOR4 *pv)
+{
+ if (!pv) return 0.0f;
+ return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) + (pv->w) * (pv->w);
+}
/*__________________D3DXQUATERNION____________________*/
@@ -118,7 +129,10 @@ static inline FLOAT D3DXQuaternionLength( CONST D3DXQUATERNION *pq)
return sqrt( (pq->x) * (pq->x) + (pq->y) * (pq->y) + (pq->z) * (pq->z) + (pq->w) * (pq->w) );
}
-
-
+static inline FLOAT D3DXQuaternionLengthSq( CONST D3DXQUATERNION *pq)
+{
+ if (!pq) return 0.0f;
+ return (pq->x) * (pq->x) + (pq->y) * (pq->y) + (pq->z) * (pq->z) + (pq->w) * (pq->w);
+}
#endif
More information about the wine-cvs
mailing list