Commit a7692beb authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

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

parent a85957ae
......@@ -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;
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment