d3dx9: Fix D3DXIntersectTri function.

Signed-off-by: Paul Gofman <gofmanp@gmail.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Paul Gofman 2016-03-11 15:35:32 +03:00 committed by Alexandre Julliard
parent e29aaca018
commit fda55a3fdf
2 changed files with 36 additions and 8 deletions

View File

@ -2380,12 +2380,15 @@ BOOL WINAPI D3DXIntersectTri(const D3DXVECTOR3 *p0, const D3DXVECTOR3 *p1, const
D3DXMATRIX m;
D3DXVECTOR4 vec;
TRACE("p0 %p, p1 %p, p2 %p, praypos %p, praydir %p, pu %p, pv %p, pdist %p.\n",
p0, p1, p2, praypos, praydir, pu, pv, pdist);
m.u.m[0][0] = p1->x - p0->x;
m.u.m[1][0] = p2->x - p0->x;
m.u.m[2][0] = -praydir->x;
m.u.m[3][0] = 0.0f;
m.u.m[0][1] = p1->y - p0->z;
m.u.m[1][1] = p2->y - p0->z;
m.u.m[0][1] = p1->y - p0->y;
m.u.m[1][1] = p2->y - p0->y;
m.u.m[2][1] = -praydir->y;
m.u.m[3][1] = 0.0f;
m.u.m[0][2] = p1->z - p0->z;

View File

@ -1103,14 +1103,39 @@ static void D3DXIntersectTriTest(void)
exp_res = TRUE; exp_u = 0.5f; exp_v = 0.25f; exp_dist = 8.0f;
got_res = D3DXIntersectTri(&vertex[0],&vertex[1],&vertex[2],&position,&ray,&got_u,&got_v,&got_dist);
ok( got_res == exp_res, "Expected result = %d, got %d\n",exp_res,got_res);
ok( compare(exp_u,got_u), "Expected u = %f, got %f\n",exp_u,got_u);
ok( compare(exp_v,got_v), "Expected v = %f, got %f\n",exp_v,got_v);
ok( compare(exp_dist,got_dist), "Expected distance = %f, got %f\n",exp_dist,got_dist);
got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, &got_u, &got_v, &got_dist);
ok(got_res == exp_res, "Expected result %d, got %d.\n", exp_res, got_res);
ok(compare(exp_u, got_u), "Expected u %f, got %f.\n", exp_u, got_u);
ok(compare(exp_v, got_v), "Expected v %f, got %f.\n", exp_v, got_v);
ok(compare(exp_dist, got_dist), "Expected distance %f, got %f.\n", exp_dist, got_dist);
got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, NULL, NULL, NULL);
ok(got_res == exp_res, "Expected result = %d, got %d\n", exp_res, got_res);
ok(got_res == exp_res, "Expected result %d, got %d.\n", exp_res, got_res);
vertex[2].x = 1.0f; vertex[2].y = 0.0f; vertex[2].z = 0.0f;
vertex[1].x = 2.0f; vertex[1].y = 0.0f; vertex[1].z = 0.0f;
vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = 0.0f;
got_u = got_v = got_dist = 0.0f;
got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, &got_u, &got_v, &got_dist);
ok(got_res == exp_res, "Expected result %d, got %d.\n", exp_res, got_res);
ok(compare(exp_u, got_u), "Expected u %f, got %f.\n", exp_u, got_u);
ok(compare(exp_v, got_v), "Expected v %f, got %f.\n", exp_v, got_v);
ok(compare(exp_dist, got_dist), "Expected distance %f, got %f.\n", exp_dist, got_dist);
vertex[2].x = 1.0f; vertex[2].y = 0.0f; vertex[2].z = 0.0f;
vertex[1].x = 2.0f; vertex[1].y = 0.0f; vertex[1].z = -0.5f;
vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = -1.0f;
exp_u = 0.375f;
exp_v = 0.5625f;
exp_dist = 7.9375f;
got_u = got_v = got_dist = 0.0f;
got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, &got_u, &got_v, &got_dist);
ok(got_res == exp_res, "Expected result %d, got %d.\n", exp_res, got_res);
ok(compare(exp_u, got_u), "Expected u %f, got %f.\n", exp_u, got_u);
ok(compare(exp_v, got_v), "Expected v %f, got %f.\n", exp_v, got_v);
ok(compare(exp_dist, got_dist), "Expected distance %f, got %f.\n", exp_dist, got_dist);
/*Only positive ray is taken in account*/