diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec index 7607d104e6d..a64e1e40029 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 98488c98825..ff1b49301c7 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 0675c4684b0..021dfe4f7d3 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 9a28a543567..a5fc09ea6c6 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);