Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

d3dx9: Fix D3DXMatrixAffineTransformation() and add some tests.

  • Loading branch information...
commit ec9db0a11f4030358f68e238a99c74314eb9c8d9 1 parent b9c2a19
@kgbricola kgbricola authored julliard committed
Showing with 40 additions and 10 deletions.
  1. +11 −4 dlls/d3dx9_36/math.c
  2. +29 −6 dlls/d3dx9_36/tests/math.c
View
15 dlls/d3dx9_36/math.c
@@ -81,7 +81,7 @@ FLOAT WINAPI D3DXFresnelTerm(FLOAT costheta, FLOAT refractionindex)
{
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);
a = g + costheta;
@@ -102,6 +102,13 @@ D3DXMATRIX * WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *out, FLOAT scalin
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)
{
FLOAT temp00, temp01, temp02, temp10, temp11, temp12, temp20, temp21, temp22;
@@ -130,9 +137,9 @@ D3DXMATRIX * WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *out, FLOAT scalin
{
FLOAT x, y, z;
- x = -rotationcenter->x;
- y = -rotationcenter->y;
- z = -rotationcenter->z;
+ x = out->u.m[3][0];
+ y = out->u.m[3][1];
+ z = out->u.m[3][2];
out->u.m[3][0] = x * temp00 + y * temp10 + z * temp20;
out->u.m[3][1] = x * temp01 + y * temp11 + z * temp21;
View
35 dlls/d3dx9_36/tests/math.c
@@ -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[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;
- D3DXMatrixAffineTransformation(&gotmat,3.56f,&at,&q,&axis);
+ D3DXMatrixAffineTransformation(&gotmat, 3.56f, &at, &q, &axis);
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;
- 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;
+
+ /* Test the NULL case */
+ 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);
+ 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;
- 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);
/*____________D3DXMatrixfDeterminant_____________*/
Please sign in to comment.
Something went wrong with that request. Please try again.