David Adam : d3dx8: Implement D3DX*Vec4Cross.

Alexandre Julliard julliard at winehq.org
Mon Oct 29 08:35:01 CDT 2007


Module: wine
Branch: master
Commit: 0af358b52b5daf1528b26f75d714fe5dc1d9e567
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0af358b52b5daf1528b26f75d714fe5dc1d9e567

Author: David Adam <David.Adam at math.cnrs.fr>
Date:   Sat Oct 27 14:23:25 2007 +0200

d3dx8: Implement D3DX*Vec4Cross.

---

 dlls/d3dx8/d3dx8.spec   |    2 +-
 dlls/d3dx8/math.c       |    9 +++++++++
 dlls/d3dx8/tests/math.c |    5 +++++
 include/d3dx8math.h     |    1 +
 4 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index 7607d10..a64e1e4 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -14,7 +14,7 @@
 @ stdcall D3DXVec3TransformNormal(ptr ptr ptr)
 @ stub D3DXVec3Project
 @ stub D3DXVec3Unproject
-@ stub D3DXVec4Cross
+@ stdcall D3DXVec4Cross(ptr ptr ptr)
 @ stdcall D3DXVec4Normalize(ptr ptr)
 @ stdcall D3DXVec4Hermite(ptr ptr ptr ptr ptr long)
 @ stdcall D3DXVec4CatmullRom(ptr ptr ptr ptr long)
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index 98488c9..ff1b493 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -246,6 +246,15 @@ D3DXVECTOR4* WINAPI D3DXVec4CatmullRom(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv0
     return pout;
 }
 
+D3DXVECTOR4* WINAPI D3DXVec4Cross(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3)
+{
+    pout->x = pv1->y * (pv2->z * pv3->w - pv3->z * pv2->w) - pv1->z * (pv2->y * pv3->w - pv3->y * pv2->w) + pv1->w * (pv2->y * pv3->z - pv2->z *pv3->y);
+    pout->y = -(pv1->x * (pv2->z * pv3->w - pv3->z * pv2->w) - pv1->z * (pv2->x * pv3->w - pv3->x * pv2->w) + pv1->w * (pv2->x * pv3->z - pv3->x * pv2->z));
+    pout->z = pv1->x * (pv2->y * pv3->w - pv3->y * pv2->w) - pv1->y * (pv2->x *pv3->w - pv3->x * pv2->w) + pv1->w * (pv2->x * pv3->y - pv3->x * pv2->y);
+    pout->w = -(pv1->x * (pv2->y * pv3->z - pv3->y * pv2->z) - pv1->y * (pv2->x * pv3->z - pv3->x *pv2->z) + pv1->z * (pv2->x * pv3->y - pv3->x * pv2->y));
+    return pout;
+}
+
 D3DXVECTOR4* WINAPI D3DXVec4Hermite(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pt1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pt2, FLOAT s)
 {
     FLOAT h1, h2, h3, h4;
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 0675c46..021dfe4 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -650,6 +650,11 @@ static void D3X8Vector4Test(void)
     D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
     expect_vec4(expectedvec,gotvec);
 
+/*_______________D3DXVec4Cross_________________________*/
+    expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
+    D3DXVec4Cross(&gotvec,&u,&v,&w);
+    expect_vec4(expectedvec,gotvec);
+
 /*_______________D3DXVec4Dot__________________________*/
     expected = 55.0f;
     got = D3DXVec4Dot(&u,&v);
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 9a28a54..a5fc09e 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -78,6 +78,7 @@ D3DXVECTOR3* WINAPI D3DXVec3TransformNormal(D3DXVECTOR3 *pout, CONST D3DXVECTOR3
 
 D3DXVECTOR4* WINAPI D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT f, FLOAT g);
 D3DXVECTOR4* WINAPI D3DXVec4CatmullRom(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv0, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT s);
+D3DXVECTOR4* WINAPI D3DXVec4Cross(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3);
 D3DXVECTOR4* WINAPI D3DXVec4Hermite(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pt1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pt2, FLOAT s);
 D3DXVECTOR4* WINAPI D3DXVec4Normalize(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv);
 D3DXVECTOR4* WINAPI D3DXVec4Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv, CONST D3DXMATRIX *pm);




More information about the wine-cvs mailing list