Commit fda55a3f authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

d3dx9: Fix D3DXIntersectTri function.

parent e29aaca0
......@@ -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;
......
......@@ -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*/
......
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