Sebastian Lackner : d3dx9_36: Allow NULL pointer for optional arguments of D3DXIntersectTri.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Nov 14 03:22:44 CST 2014
Module: wine
Branch: master
Commit: b69038e3d96bd4eee19be6d6c6de7d4abb03460d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b69038e3d96bd4eee19be6d6c6de7d4abb03460d
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Sat Nov 8 19:29:53 2014 +0100
d3dx9_36: Allow NULL pointer for optional arguments of D3DXIntersectTri.
---
dlls/d3dx9_36/mesh.c | 6 +++---
dlls/d3dx9_36/tests/mesh.c | 9 +++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c
index 9aece61..6f268f2 100644
--- a/dlls/d3dx9_36/mesh.c
+++ b/dlls/d3dx9_36/mesh.c
@@ -2407,9 +2407,9 @@ BOOL WINAPI D3DXIntersectTri(const D3DXVECTOR3 *p0, const D3DXVECTOR3 *p1, const
D3DXVec4Transform(&vec, &vec, &m);
if ( (vec.x >= 0.0f) && (vec.y >= 0.0f) && (vec.x + vec.y <= 1.0f) && (vec.z >= 0.0f) )
{
- *pu = vec.x;
- *pv = vec.y;
- *pdist = fabsf( vec.z );
+ if (pu) *pu = vec.x;
+ if (pv) *pv = vec.y;
+ if (pdist) *pdist = fabsf( vec.z );
return TRUE;
}
}
diff --git a/dlls/d3dx9_36/tests/mesh.c b/dlls/d3dx9_36/tests/mesh.c
index 870f62a..dac0f60 100644
--- a/dlls/d3dx9_36/tests/mesh.c
+++ b/dlls/d3dx9_36/tests/mesh.c
@@ -1104,6 +1104,9 @@ static void D3DXIntersectTriTest(void)
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);
+
/*Only positive ray is taken in account*/
vertex[0].x = 1.0f; vertex[0].y = 0.0f; vertex[0].z = 0.0f;
@@ -1119,6 +1122,9 @@ static void D3DXIntersectTriTest(void)
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);
+ 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);
+
/*Intersection between ray and triangle in a same plane is considered as empty*/
vertex[0].x = 4.0f; vertex[0].y = 0.0f; vertex[0].z = 0.0f;
@@ -1133,6 +1139,9 @@ static void D3DXIntersectTriTest(void)
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);
+
+ 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);
}
static void D3DXCreateMeshTest(void)
More information about the wine-cvs
mailing list