[PATCH] Implement D3DXMatrixReflect with a test

David Adam David.Adam at math.cnrs.fr
Thu Nov 15 06:09:38 CST 2007


---
 dlls/d3dx8/d3dx8.spec   |    2 +-
 dlls/d3dx8/math.c       |   21 +++++++++++++++++++++
 dlls/d3dx8/tests/math.c |    7 +++++++
 include/d3dx8math.h     |    1 +
 4 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index dae4570..9dca39b 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -48,7 +48,7 @@
 @ stdcall D3DXMatrixOrthoOffCenterRH(ptr long long long long long long)
 @ stdcall D3DXMatrixOrthoOffCenterLH(ptr long long long long long long)
 @ stdcall D3DXMatrixShadow(ptr ptr ptr)
-@ stub D3DXMatrixReflect
+@ stdcall D3DXMatrixReflect(ptr ptr)
 @ stub D3DXQuaternionToAxisAngle
 @ stub D3DXQuaternionRotationMatrix
 @ stub D3DXQuaternionRotationAxis
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index 990aa55..cb6789a 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -325,6 +325,27 @@ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH(D3DXMATRIX *=
pout, FLOAT w, FLOAT h, F
     return pout;
 }
=20
+D3DXMATRIX* WINAPI D3DXMatrixReflect(D3DXMATRIX *pout, CONST D3DXPLANE *ppl=
ane)
+{
+    D3DXPLANE Nplane;
+
+    D3DXPlaneNormalize(&Nplane, pplane);
+    D3DXMatrixIdentity(pout);
+    pout->u.m[0][0] =3D 1.0f - 2.0f * Nplane.a * Nplane.a;
+    pout->u.m[0][1] =3D -2.0f * Nplane.a * Nplane.b;
+    pout->u.m[0][2] =3D -2.0f * Nplane.a * Nplane.c;
+    pout->u.m[1][0] =3D -2.0f * Nplane.a * Nplane.b;
+    pout->u.m[1][1] =3D 1.0f - 2.0f * Nplane.b * Nplane.b;
+    pout->u.m[1][2] =3D -2.0f * Nplane.b * Nplane.c;
+    pout->u.m[2][0] =3D -2.0f * Nplane.c * Nplane.a;
+    pout->u.m[2][1] =3D -2.0f * Nplane.c * Nplane.b;
+    pout->u.m[2][2] =3D 1.0f - 2.0f * Nplane.c * Nplane.c;
+    pout->u.m[3][0] =3D -2.0f * Nplane.d * Nplane.a;
+    pout->u.m[3][1] =3D -2.0f * Nplane.d * Nplane.b;
+    pout->u.m[3][2] =3D -2.0f * Nplane.d * Nplane.c;
+    return pout;
+}
+
 D3DXMATRIX* WINAPI D3DXMatrixRotationAxis(D3DXMATRIX *pout, CONST D3DXVECTO=
R3 *pv, FLOAT angle)
 {
     D3DXVECTOR3 v;
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index abc3a98..05a72e9 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -346,6 +346,13 @@ static void D3DXMatrixTest(void)
     D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
     expect_mat(expectedmat,gotmat);
=20
+/*____________D3DXMatrixReflect______________*/
+    U(expectedmat).m[0][0] =3D 0.307692f; U(expectedmat).m[0][1] =3D -0.230=
769f; U(expectedmat).m[0][2] =3D 0.923077f; U(expectedmat).m[0][3] =3D 0.0f;
+    U(expectedmat).m[1][0] =3D -0.230769; U(expectedmat).m[1][1] =3D 0.9230=
77f; U(expectedmat).m[1][2] =3D 0.307693f; U(expectedmat).m[1][3] =3D 0.0f;
+    U(expectedmat).m[2][0] =3D 0.923077f; U(expectedmat).m[2][1] =3D 0.3076=
93f; U(expectedmat).m[2][2] =3D -0.230769f; U(expectedmat).m[2][3] =3D 0.0f;
+    U(expectedmat).m[3][0] =3D 1.615385f; U(expectedmat).m[3][1] =3D 0.5384=
62f; U(expectedmat).m[3][2] =3D -2.153846f; U(expectedmat).m[3][3] =3D 1.0f;
+    D3DXMatrixReflect(&gotmat,&plane);
+    expect_mat(expectedmat,gotmat);
 /*____________D3DXMatrixRotationAxis_____*/
     U(expectedmat).m[0][0] =3D 0.508475f; U(expectedmat).m[0][1] =3D 0.7638=
05f; U(expectedmat).m[0][2] =3D 0.397563f; U(expectedmat).m[0][3] =3D 0.0f;
     U(expectedmat).m[1][0] =3D -0.814652f; U(expectedmat).m[1][1] =3D 0.576=
271f; U(expectedmat).m[1][2] =3D -0.065219f; U(expectedmat).m[1][3] =3D 0.0f=
;
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 9abbb6c..ef5edbc 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -281,6 +281,7 @@ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH(D3DXMATRIX *p=
out, FLOAT w, FLOAT h, F
 D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH(D3DXMATRIX *pout, FLOAT=
 l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf);
 D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH(D3DXMATRIX *pout, FLOAT=
 l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf);
 D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH(D3DXMATRIX *pout, FLOAT w, FLOAT=
 h, FLOAT zn, FLOAT zf);
+D3DXMATRIX* WINAPI D3DXMatrixReflect(D3DXMATRIX *pout, CONST D3DXPLANE *ppl=
ane);
 D3DXMATRIX* WINAPI D3DXMatrixRotationAxis(D3DXMATRIX *pout, CONST D3DXVECTO=
R3 *pv, FLOAT angle);
 D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion(D3DXMATRIX *pout, CONST D3D=
XQUATERNION *pq);
 D3DXMATRIX* WINAPI D3DXMatrixRotationX(D3DXMATRIX *pout, FLOAT angle);
--=20
1.5.3.2


--=_8tpp3pmaslo--



More information about the wine-patches mailing list