Commit ec9db0a1 authored by Rico Schüller's avatar Rico Schüller Committed by Alexandre Julliard

d3dx9: Fix D3DXMatrixAffineTransformation() and add some tests.

parent b9c2a195
...@@ -81,7 +81,7 @@ FLOAT WINAPI D3DXFresnelTerm(FLOAT costheta, FLOAT refractionindex) ...@@ -81,7 +81,7 @@ FLOAT WINAPI D3DXFresnelTerm(FLOAT costheta, FLOAT refractionindex)
{ {
FLOAT a, d, g, result; FLOAT a, d, g, result;
TRACE("costheta %f, refractionindex %f)\n", costheta, refractionindex); TRACE("costheta %f, refractionindex %f\n", costheta, refractionindex);
g = sqrtf(refractionindex * refractionindex + costheta * costheta - 1.0f); g = sqrtf(refractionindex * refractionindex + costheta * costheta - 1.0f);
a = g + costheta; a = g + costheta;
...@@ -102,6 +102,13 @@ D3DXMATRIX * WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *out, FLOAT scalin ...@@ -102,6 +102,13 @@ D3DXMATRIX * WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *out, FLOAT scalin
D3DXMatrixIdentity(out); D3DXMatrixIdentity(out);
if (rotationcenter)
{
out->u.m[3][0] = -rotationcenter->x;
out->u.m[3][1] = -rotationcenter->y;
out->u.m[3][2] = -rotationcenter->z;
}
if (rotation) if (rotation)
{ {
FLOAT temp00, temp01, temp02, temp10, temp11, temp12, temp20, temp21, temp22; FLOAT temp00, temp01, temp02, temp10, temp11, temp12, temp20, temp21, temp22;
...@@ -130,9 +137,9 @@ D3DXMATRIX * WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *out, FLOAT scalin ...@@ -130,9 +137,9 @@ D3DXMATRIX * WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *out, FLOAT scalin
{ {
FLOAT x, y, z; FLOAT x, y, z;
x = -rotationcenter->x; x = out->u.m[3][0];
y = -rotationcenter->y; y = out->u.m[3][1];
z = -rotationcenter->z; z = out->u.m[3][2];
out->u.m[3][0] = x * temp00 + y * temp10 + z * temp20; out->u.m[3][0] = x * temp00 + y * temp10 + z * temp20;
out->u.m[3][1] = x * temp01 + y * temp11 + z * temp21; out->u.m[3][1] = x * temp01 + y * temp11 + z * temp21;
......
...@@ -275,14 +275,37 @@ static void D3DXMatrixTest(void) ...@@ -275,14 +275,37 @@ static void D3DXMatrixTest(void)
U(expectedmat).m[1][0] = 519.760010f; U(expectedmat).m[1][1] = -352.440002f; U(expectedmat).m[1][2] = -277.679993f; U(expectedmat).m[1][3] = 0.0f; U(expectedmat).m[1][0] = 519.760010f; U(expectedmat).m[1][1] = -352.440002f; U(expectedmat).m[1][2] = -277.679993f; U(expectedmat).m[1][3] = 0.0f;
U(expectedmat).m[2][0] = 363.119995f; U(expectedmat).m[2][1] = -121.040001f; U(expectedmat).m[2][2] = -117.479996f; U(expectedmat).m[2][3] = 0.0f; U(expectedmat).m[2][0] = 363.119995f; U(expectedmat).m[2][1] = -121.040001f; U(expectedmat).m[2][2] = -117.479996f; U(expectedmat).m[2][3] = 0.0f;
U(expectedmat).m[3][0] = -1239.0f; U(expectedmat).m[3][1] = 667.0f; U(expectedmat).m[3][2] = 567.0f; U(expectedmat).m[3][3] = 1.0f; U(expectedmat).m[3][0] = -1239.0f; U(expectedmat).m[3][1] = 667.0f; U(expectedmat).m[3][2] = 567.0f; U(expectedmat).m[3][3] = 1.0f;
D3DXMatrixAffineTransformation(&gotmat,3.56f,&at,&q,&axis); D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, &q, &axis);
expect_mat(&expectedmat, &gotmat); expect_mat(&expectedmat, &gotmat);
/* Test the NULL case */
U(expectedmat).m[0][0] = -459.239990f; U(expectedmat).m[0][1] = -576.719971f; U(expectedmat).m[0][2] = -263.440002f; U(expectedmat).m[0][3] = 0.0f; /* Test the NULL case */
U(expectedmat).m[1][0] = 519.760010f; U(expectedmat).m[1][1] = -352.440002f; U(expectedmat).m[1][2] = -277.679993f; U(expectedmat).m[1][3] = 0.0f; U(expectedmat).m[3][0] = 1.0f; U(expectedmat).m[3][1] = -3.0f; U(expectedmat).m[3][2] = 7.0f; U(expectedmat).m[3][3] = 1.0f;
U(expectedmat).m[2][0] = 363.119995f; U(expectedmat).m[2][1] = -121.040001f; U(expectedmat).m[2][2] = -117.479996f; U(expectedmat).m[2][3] = 0.0f; D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, &q, &axis);
expect_mat(&expectedmat, &gotmat);
U(expectedmat).m[3][0] = -1240.0f; U(expectedmat).m[3][1] = 670.0f; U(expectedmat).m[3][2] = 560.0f; U(expectedmat).m[3][3] = 1.0f;
D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, &q, NULL);
expect_mat(&expectedmat, &gotmat);
U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, &q, NULL);
expect_mat(&expectedmat, &gotmat);
U(expectedmat).m[0][0] = 3.56f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 3.56f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 3.56f; U(expectedmat).m[2][3] = 0.0f;
U(expectedmat).m[3][0] = 1.0f; U(expectedmat).m[3][1] = -3.0f; U(expectedmat).m[3][2] = 7.0f; U(expectedmat).m[3][3] = 1.0f; U(expectedmat).m[3][0] = 1.0f; U(expectedmat).m[3][1] = -3.0f; U(expectedmat).m[3][2] = 7.0f; U(expectedmat).m[3][3] = 1.0f;
D3DXMatrixAffineTransformation(&gotmat,3.56f,NULL,&q,&axis); D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, NULL, &axis);
expect_mat(&expectedmat, &gotmat);
D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, NULL, &axis);
expect_mat(&expectedmat, &gotmat);
U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, NULL, NULL);
expect_mat(&expectedmat, &gotmat);
D3DXMatrixAffineTransformation(&gotmat, 3.56f, NULL, NULL, NULL);
expect_mat(&expectedmat, &gotmat); expect_mat(&expectedmat, &gotmat);
/*____________D3DXMatrixfDeterminant_____________*/ /*____________D3DXMatrixfDeterminant_____________*/
......
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