Commit 720fb79d authored by David Adam's avatar David Adam Committed by Alexandre Julliard

d3dx8: Implement D3DXMatrixfDeterminant.

parent 08d17fd2
......@@ -20,7 +20,7 @@
@ stdcall D3DXVec4CatmullRom(ptr ptr ptr ptr long)
@ stdcall D3DXVec4BaryCentric(ptr ptr ptr ptr long long)
@ stdcall D3DXVec4Transform(ptr ptr ptr)
@ stub D3DXMatrixfDeterminant
@ stdcall D3DXMatrixfDeterminant(ptr)
@ stub D3DXMatrixMultiply
@ stub D3DXMatrixTranspose
@ stub D3DXMatrixInverse
......
......@@ -29,6 +29,21 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3dx8);
/*_________________D3DXMatrix____________________*/
FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm)
{
D3DXVECTOR4 minor, v1, v2, v3;
FLOAT det;
v1.x = pm->m[0][0]; v1.y = pm->m[1][0]; v1.z = pm->m[2][0]; v1.w = pm->m[3][0];
v2.x = pm->m[0][1]; v2.y = pm->m[1][1]; v2.z = pm->m[2][1]; v2.w = pm->m[3][1];
v3.x = pm->m[0][2]; v3.y = pm->m[1][2]; v3.z = pm->m[2][2]; v3.w = pm->m[3][2];
D3DXVec4Cross(&minor,&v1,&v2,&v3);
det = - (pm->m[0][3] * minor.x + pm->m[1][3] * minor.y + pm->m[2][3] * minor.z + pm->m[3][3] * minor.w);
return det;
}
/*_________________D3DXQUATERNION________________*/
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq)
......
......@@ -125,14 +125,21 @@ static void D3DXMatrixTest(void)
{
D3DXMATRIX mat;
BOOL expected, got;
FLOAT expectedfloat, gotfloat;
U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
U(mat).m[3][3] = -40.0f;
/*____________D3DXMatrixfDeterminant_____________*/
expectedfloat = -147888.0f;
gotfloat = D3DXMatrixfDeterminant(&mat);
ok(fabs( gotfloat - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, gotfloat);
/*____________D3DXMatrixIsIdentity______________*/
U(mat).m[0][1] = 0.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 0.0f; U(mat).m[1][3] = 0.0f;
U(mat).m[2][0] = 0.0f; U(mat).m[2][1] = 0.0f; U(mat).m[2][3] = 0.0f;
U(mat).m[3][0] = 0.0f; U(mat).m[3][1] = 0.0f; U(mat).m[3][2] = 0.0f;
U(mat).m[0][0] = 1.0f; U(mat).m[1][1] = 1.0f; U(mat).m[2][2] = 1.0f;
U(mat).m[3][3] = 1.0f;
expected = FALSE;
got = D3DXMatrixIsIdentity(&mat);
ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
......
......@@ -58,6 +58,8 @@ typedef struct D3DXCOLOR
FLOAT r, g, b, a;
} D3DXCOLOR, *LPD3DXCOLOR;
FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm);
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment