Commit 3e264ced authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3dx9: Handle NULL arguments in D3DXVec3Unproject.

parent a5d56507
......@@ -1936,16 +1936,12 @@ D3DXVECTOR3* WINAPI D3DXVec3Unproject(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv,
TRACE("(%p, %p, %p, %p, %p, %p)\n", pout, pv, pviewport, pprojection, pview, pworld);
if (pworld)
{
D3DXMatrixMultiply(&m, pworld, pview);
D3DXMatrixMultiply(&m, &m, pprojection);
}
else
{
D3DXMatrixMultiply(&m, pview, pprojection);
}
D3DXMatrixIdentity(&m);
if (pworld) D3DXMatrixMultiply(&m, &m, pworld);
if (pview) D3DXMatrixMultiply(&m, &m, pview);
if (pprojection) D3DXMatrixMultiply(&m, &m, pprojection);
D3DXMatrixInverse(&m, NULL, &m);
*pout = *pv;
if (pviewport)
{
......
......@@ -1401,6 +1401,18 @@ static void D3DXVector3Test(void)
D3DXMatrixMultiply(&mat,&world,&view);
D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&mat,NULL);
expect_vec3(expectedvec,gotvec);
/* Projection matrix can be omitted */
D3DXMatrixMultiply(&mat,&view,&projection);
D3DXVec3Unproject(&gotvec,&u,&viewport,NULL,&mat,&world);
expect_vec3(expectedvec,gotvec);
/* View matrix can be omitted */
D3DXMatrixMultiply(&mat,&world,&view);
D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,NULL,&mat);
expect_vec3(expectedvec,gotvec);
/* All matrices can be omitted */
expectedvec.x = -1.002500f; expectedvec.y = 0.997059f; expectedvec.z = 2.571429f;
D3DXVec3Unproject(&gotvec,&u,&viewport,NULL,NULL,NULL);
expect_vec3(expectedvec,gotvec);
/* Viewport can be omitted */
expectedvec.x = -11.018396f; expectedvec.y = 3.218991f; expectedvec.z = 1.380329f;
D3DXVec3Unproject(&gotvec,&u,NULL,&projection,&view,&world);
......
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