=?UTF-8?Q?Rico=20Sch=C3=BCller=20?=: d3dx9: Fix D3DXMatrixAffineTransformation() and add some tests.
Alexandre Julliard
julliard at winehq.org
Mon Oct 1 13:35:07 CDT 2012
Module: wine
Branch: master
Commit: ec9db0a11f4030358f68e238a99c74314eb9c8d9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ec9db0a11f4030358f68e238a99c74314eb9c8d9
Author: Rico Schüller <kgbricola at web.de>
Date: Mon Oct 1 12:40:51 2012 +0200
d3dx9: Fix D3DXMatrixAffineTransformation() and add some tests.
---
dlls/d3dx9_36/math.c | 15 +++++++++++----
dlls/d3dx9_36/tests/math.c | 35 +++++++++++++++++++++++++++++------
2 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c
index 53dddd4..b43c678 100644
--- a/dlls/d3dx9_36/math.c
+++ b/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;
diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c
index 9043ab3..9a5cbcc 100644
--- a/dlls/d3dx9_36/tests/math.c
+++ b/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_____________*/
More information about the wine-cvs
mailing list