Commit 7bfd6342 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3dx9: Handle NULL viewport in D3DXVec3Unproject.

parent d1a99fee
......@@ -1928,22 +1928,27 @@ D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray(D3DXVECTOR3* out, UINT outstrid
D3DXVECTOR3* WINAPI D3DXVec3Unproject(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT9 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld)
{
D3DXMATRIX m;
D3DXVECTOR3 out;
TRACE("(%p, %p, %p, %p, %p, %p)\n", pout, pv, pviewport, pprojection, pview, pworld);
if (pworld) {
if (pworld)
{
D3DXMatrixMultiply(&m, pworld, pview);
D3DXMatrixMultiply(&m, &m, pprojection);
} else {
}
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;
out.z = ( pv->z - pviewport->MinZ) / ( pviewport->MaxZ - pviewport->MinZ );
D3DXVec3TransformCoord(&out, &out, &m);
*pout = out;
*pout = *pv;
if (pviewport)
{
pout->x = 2.0f * ( pout->x - pviewport->X ) / pviewport->Width - 1.0f;
pout->y = 1.0f - 2.0f * ( pout->y - pviewport->Y ) / pviewport->Height;
pout->z = ( pout->z - pviewport->MinZ) / ( pviewport->MaxZ - pviewport->MinZ );
}
D3DXVec3TransformCoord(pout, pout, &m);
return pout;
}
......
......@@ -1381,6 +1381,10 @@ static void D3DXVector3Test(void)
D3DXMatrixMultiply(&mat,&world,&view);
D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&mat,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);
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