From a7692beb613f6eff6e93aca365f10edc7e826701 Mon Sep 17 00:00:00 2001 From: Christian Costa Date: Mon, 12 Mar 2012 19:53:24 +0100 Subject: [PATCH] d3dx9_36: Make D3DXVec3Unproject support omission of world matrix + test. --- 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 9289abc851e..b9271e0da49 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 83e2ef61d4e..61f85675dcb 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 omitted */ + D3DXMatrixMultiply(&mat,&world,&view); + D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&mat,NULL); + expect_vec3(expectedvec,gotvec); } static void D3DXVector4Test(void) -- 2.11.4.GIT