Module: wine Branch: master Commit: ea8e7ce42d0e03ffdeb747c95470d9b93af8ad95 URL: http://source.winehq.org/git/wine.git/?a=commit;h=ea8e7ce42d0e03ffdeb747c954...
Author: David Adam David.Adam@math.cnrs.fr Date: Fri Oct 26 18:58:28 2007 +0200
d3dx8: Implement D3DX*BaryCentric.
---
dlls/d3dx8/d3dx8.spec | 6 ++-- dlls/d3dx8/math.c | 23 ++++++++++++++++++++++ dlls/d3dx8/tests/math.c | 48 +++++++++++++++++++++++++++++++++++----------- include/d3dx8math.h | 3 ++ 4 files changed, 65 insertions(+), 15 deletions(-)
diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec index 6620454..362b76c 100644 --- a/dlls/d3dx8/d3dx8.spec +++ b/dlls/d3dx8/d3dx8.spec @@ -1,14 +1,14 @@ @ stdcall D3DXVec2Normalize(ptr ptr) @ stub D3DXVec2Hermite @ stub D3DXVec2CatmullRom -@ stub D3DXVec2BaryCentric +@ stdcall D3DXVec2BaryCentric(ptr ptr ptr ptr long long) @ stub D3DXVec2Transform @ stub D3DXVec2TransformCoord @ stub D3DXVec2TransformNormal @ stdcall D3DXVec3Normalize(ptr ptr) @ stub D3DXVec3Hermite @ stub D3DXVec3CatmullRom -@ stub D3DXVec3BaryCentric +@ stdcall D3DXVec3BaryCentric(ptr ptr ptr ptr long long) @ stub D3DXVec3Transform @ stub D3DXVec3TransformCoord @ stub D3DXVec3TransformNormal @@ -18,7 +18,7 @@ @ stdcall D3DXVec4Normalize(ptr ptr) @ stub D3DXVec4Hermite @ stub D3DXVec4CatmullRom -@ stub D3DXVec4BaryCentric +@ stdcall D3DXVec4BaryCentric(ptr ptr ptr ptr long long) @ stub D3DXVec4Transform @ stub D3DXMatrixfDeterminant @ stub D3DXMatrixMultiply diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c index 8cec297..e10229c 100644 --- a/dlls/d3dx8/math.c +++ b/dlls/d3dx8/math.c @@ -54,6 +54,13 @@ D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQ } /*_________________D3DXVec2_____________________*/
+D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g) +{ + pout->x = (1.0f-f-g) * (pv1->x) + f * (pv2->x) + g * (pv3->x); + pout->y = (1.0f-f-g) * (pv1->y) + f * (pv2->y) + g * (pv3->y); + return pout; +} + D3DXVECTOR2* WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv) { FLOAT norm; @@ -74,6 +81,14 @@ D3DXVECTOR2* WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv)
/*_________________D3DXVec3_____________________*/
+D3DXVECTOR3* WINAPI D3DXVec3BaryCentric(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3, FLOAT f, FLOAT g) +{ + pout->x = (1.0f-f-g) * (pv1->x) + f * (pv2->x) + g * (pv3->x); + pout->y = (1.0f-f-g) * (pv1->y) + f * (pv2->y) + g * (pv3->y); + pout->z = (1.0f-f-g) * (pv1->z) + f * (pv2->z) + g * (pv3->z); + return pout; +} + D3DXVECTOR3* WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv) { FLOAT norm; @@ -96,6 +111,14 @@ D3DXVECTOR3* WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv)
/*_________________D3DXVec4_____________________*/
+D3DXVECTOR4* WINAPI D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT f, FLOAT g) +{ + pout->x = (1.0f-f-g) * (pv1->x) + f * (pv2->x) + g * (pv3->x); + pout->y = (1.0f-f-g) * (pv1->y) + f * (pv2->y) + g * (pv3->y); + pout->z = (1.0f-f-g) * (pv1->z) + f * (pv2->z) + g * (pv3->z); + pout->w = (1.0f-f-g) * (pv1->w) + f * (pv2->w) + g * (pv3->w); + return pout; +} D3DXVECTOR4* WINAPI D3DXVec4Normalize(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv) { FLOAT norm; diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c index 675e620..ea206ba 100644 --- a/dlls/d3dx8/tests/math.c +++ b/dlls/d3dx8/tests/math.c @@ -273,25 +273,33 @@ static void D3X8QuaternionTest(void)
static void D3X8Vector2Test(void) { - D3DXVECTOR2 expectedvec, gotvec, nul, u, v; + D3DXVECTOR2 expectedvec, gotvec, nul, u, v, w; LPD3DXVECTOR2 funcpointer; - FLOAT expected, got, scale; + FLOAT coeff1, coeff2, expected, got, scale;
nul.x = 0.0f; nul.y = 0.0f; - u.x=3.0f; u.y=4.0f; - v.x=-7.0f; v.y=9.0f; + u.x = 3.0f; u.y = 4.0f; + v.x = -7.0f; v.y = 9.0f; + w.x = 4.0f; w.y = -3.0f; + + coeff1 = 2.0f; coeff2 = 5.0f; scale = -6.5f;
/*_______________D3DXVec2Add__________________________*/ - expectedvec.x = -4.0f; expectedvec.y = 13.0f; - D3DXVec2Add(&gotvec,&u,&v); - expect_vec(expectedvec,gotvec); - /* Tests the case NULL */ + expectedvec.x = -4.0f; expectedvec.y = 13.0f; + D3DXVec2Add(&gotvec,&u,&v); + expect_vec(expectedvec,gotvec); + /* Tests the case NULL */ funcpointer = D3DXVec2Add(&gotvec,NULL,&v); ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer); funcpointer = D3DXVec2Add(NULL,NULL,NULL); ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+/*_______________D3DXVec2BaryCentric___________________*/ + expectedvec.x = -12.0f; expectedvec.y = -21.0f; + D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2); + expect_vec(expectedvec,gotvec); + /*_______________D3DXVec2CCW__________________________*/ expected = 55.0f; got = D3DXVec2CCW(&u,&v); @@ -397,13 +405,16 @@ static void D3X8Vector2Test(void)
static void D3X8Vector3Test(void) { - D3DXVECTOR3 expectedvec, gotvec, nul, u, v; + D3DXVECTOR3 expectedvec, gotvec, nul, u, v, w; LPD3DXVECTOR3 funcpointer; - FLOAT expected, got, scale; + FLOAT coeff1, coeff2, expected, got, scale;
nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; u.x = 9.0f; u.y = 6.0f; u.z = 2.0f; v.x = 2.0f; v.y = -3.0f; v.z = -4.0; + w.x = 3.0f; w.y = -5.0f; w.z = 7.0f; + + coeff1 = 2.0f; coeff2 = 5.0f; scale = -6.5f;
/*_______________D3DXVec3Add__________________________*/ @@ -416,6 +427,11 @@ static void D3X8Vector3Test(void) funcpointer = D3DXVec3Add(NULL,NULL,NULL); ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+/*_______________D3DXVec3BaryCentric___________________*/ + expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f; + D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2); + expect_vec3(expectedvec,gotvec); + /*_______________D3DXVec3Cross________________________*/ expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -30.0f; D3DXVec3Cross(&gotvec,&u,&v); @@ -518,13 +534,16 @@ static void D3X8Vector3Test(void)
static void D3X8Vector4Test(void) { - D3DXVECTOR4 expectedvec, gotvec, nul, u, v; + D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w; LPD3DXVECTOR4 funcpointer; - FLOAT expected, got, scale; + FLOAT coeff1, coeff2, expected, got, scale;
nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f; u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0; v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0; + w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f; + + coeff1 = 2.0f; coeff2 = 5.0; scale = -6.5f;
/*_______________D3DXVec4Add__________________________*/ @@ -537,6 +556,11 @@ static void D3X8Vector4Test(void) funcpointer = D3DXVec4Add(NULL,NULL,NULL); ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+/*_______________D3DXVec4BaryCentric____________________*/ + expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f; + D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2); + expect_vec4(expectedvec,gotvec); + /*_______________D3DXVec4Dot__________________________*/ expected = 55.0f; got = D3DXVec4Dot(&u,&v); diff --git a/include/d3dx8math.h b/include/d3dx8math.h index e173ac5..c510031 100644 --- a/include/d3dx8math.h +++ b/include/d3dx8math.h @@ -60,10 +60,13 @@ typedef struct D3DXCOLOR
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
+D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g); D3DXVECTOR2* WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv);
+D3DXVECTOR3* WINAPI D3DXVec3BaryCentric(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3, FLOAT f, FLOAT g); D3DXVECTOR3* WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv);
+D3DXVECTOR4* WINAPI D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT f, FLOAT g); D3DXVECTOR4* WINAPI D3DXVec4Normalize(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv);
#include <d3dx8math.inl>