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

This commit is contained in:
Christian Costa 2012-03-12 19:53:24 +01:00 committed by Alexandre Julliard
parent a85957ae0e
commit a7692beb61
2 changed files with 13 additions and 5 deletions

View file

@ -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;

View file

@ -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)