[PATCH] d3dx9_36: Make D3DXVec3Unproject support omission of world matrix + test.

Christian Costa titan.costa at gmail.com
Mon Mar 12 13:53:24 CDT 2012


---
 dlls/d3dx9_36/math.c       |    8 ++++++--
 dlls/d3dx9_36/tests/math.c |   10 +++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c
index 9289abc..b9271e0 100644
--- a/dlls/d3dx9_36/math.c
+++ b/dlls/d3dx9_36/math.c
@@ -1661,8 +1661,12 @@ D3DXVECTOR3* WINAPI D3DXVec3Unproject(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv,
     D3DXMATRIX m;
     D3DXVECTOR3 out;
 
-    D3DXMatrixMultiply(&m, pworld, pview);
-    D3DXMatrixMultiply(&m, &m, pprojection);
+    if (pworld) {
+        D3DXMatrixMultiply(&m, pworld, pview);
+        D3DXMatrixMultiply(&m, &m, pprojection);
+    } else {
+        D3DXMatrixMultiply(&m, pview, pprojection);
+    }
     D3DXMatrixInverse(&m, NULL, &m);
     out.x = 2.0f * ( pv->x - pviewport->X ) / pviewport->Width - 1.0f;
     out.y = 1.0f - 2.0f * ( pv->y - pviewport->Y ) / pviewport->Height;
diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c
index 83e2ef6..5869f0c 100644
--- a/dlls/d3dx9_36/tests/math.c
+++ b/dlls/d3dx9_36/tests/math.c
@@ -1197,9 +1197,9 @@ static void D3DXVector3Test(void)
     expect_vec3(expectedvec,gotvec);
 
 /*_______________D3DXVec3Length__________________________*/
-   expected = 11.0f;
-   got = D3DXVec3Length(&u);
-   ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+    expected = 11.0f;
+    got = D3DXVec3Length(&u);
+    ok(relative_error(got, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
    /* Tests the case NULL */
     expected=0.0f;
     got = D3DXVec3Length(NULL);
@@ -1299,6 +1299,10 @@ static void D3DXVector3Test(void)
     D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
     D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
     expect_vec3(expectedvec,gotvec);
+    /* World matrix can be ommited */
+    D3DXMatrixMultiply(&mat,&world,&view);
+    D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&mat,NULL);
+    expect_vec3(expectedvec,gotvec);
 }
 
 static void D3DXVector4Test(void)




More information about the wine-patches mailing list