Commit 6dc78d5c authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dx9: Cleanup D3DXVec3Unproject() implementation a bit.

parent 972dc565
...@@ -1987,27 +1987,33 @@ D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray(D3DXVECTOR3* out, UINT outstrid ...@@ -1987,27 +1987,33 @@ D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray(D3DXVECTOR3* out, UINT outstrid
return out; return out;
} }
D3DXVECTOR3* WINAPI D3DXVec3Unproject(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv, const D3DVIEWPORT9 *pviewport, const D3DXMATRIX *pprojection, const D3DXMATRIX *pview, const D3DXMATRIX *pworld) D3DXVECTOR3 * WINAPI D3DXVec3Unproject(D3DXVECTOR3 *out, const D3DXVECTOR3 *v,
const D3DVIEWPORT9 *viewport, const D3DXMATRIX *projection, const D3DXMATRIX *view,
const D3DXMATRIX *world)
{ {
D3DXMATRIX m; D3DXMATRIX m;
TRACE("pout %p, pv %p, pviewport %p, pprojection %p, pview %p, pworlds %p\n", pout, pv, pviewport, pprojection, pview, pworld); TRACE("out %p, v %p, viewport %p, projection %p, view %p, world %p.\n",
out, v, viewport, projection, view, world);
D3DXMatrixIdentity(&m); D3DXMatrixIdentity(&m);
if (pworld) D3DXMatrixMultiply(&m, &m, pworld); if (world)
if (pview) D3DXMatrixMultiply(&m, &m, pview); D3DXMatrixMultiply(&m, &m, world);
if (pprojection) D3DXMatrixMultiply(&m, &m, pprojection); if (view)
D3DXMatrixMultiply(&m, &m, view);
if (projection)
D3DXMatrixMultiply(&m, &m, projection);
D3DXMatrixInverse(&m, NULL, &m); D3DXMatrixInverse(&m, NULL, &m);
*pout = *pv; *out = *v;
if (pviewport) if (viewport)
{ {
pout->x = 2.0f * ( pout->x - pviewport->X ) / pviewport->Width - 1.0f; out->x = 2.0f * (out->x - viewport->X) / viewport->Width - 1.0f;
pout->y = 1.0f - 2.0f * ( pout->y - pviewport->Y ) / pviewport->Height; out->y = 1.0f - 2.0f * (out->y - viewport->Y) / viewport->Height;
pout->z = ( pout->z - pviewport->MinZ) / ( pviewport->MaxZ - pviewport->MinZ ); out->z = (out->z - viewport->MinZ) / (viewport->MaxZ - viewport->MinZ);
} }
D3DXVec3TransformCoord(pout, pout, &m); D3DXVec3TransformCoord(out, out, &m);
return pout; return out;
} }
D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray(D3DXVECTOR3* out, UINT outstride, const D3DXVECTOR3* in, UINT instride, const D3DVIEWPORT9* viewport, const D3DXMATRIX* projection, const D3DXMATRIX* view, const D3DXMATRIX* world, UINT elements) D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray(D3DXVECTOR3* out, UINT outstride, const D3DXVECTOR3* in, UINT instride, const D3DVIEWPORT9* viewport, const D3DXMATRIX* projection, const D3DXMATRIX* view, const D3DXMATRIX* world, UINT elements)
......
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