From 8abfaa04cc31763c5b048fdeace3934df0bfbfb3 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 15 Nov 2007 11:27:19 +0100 Subject: [PATCH] d3dx8: Implement D3DXPlaneNormalize. --- dlls/d3dx8/d3dx8.spec | 2 +- dlls/d3dx8/math.c | 24 ++++++++++++++++++++++++ dlls/d3dx8/tests/math.c | 17 ++++++++++++++++- include/d3dx8math.h | 2 ++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec index 75785970dfe..37595133f44 100644 --- a/dlls/d3dx8/d3dx8.spec +++ b/dlls/d3dx8/d3dx8.spec @@ -61,7 +61,7 @@ @ stub D3DXQuaternionSlerp @ stub D3DXQuaternionSquad @ stub D3DXQuaternionBaryCentric -@ stub D3DXPlaneNormalize +@ stdcall D3DXPlaneNormalize(ptr ptr) @ stub D3DXPlaneIntersectLine @ stub D3DXPlaneFromPointNormal @ stub D3DXPlaneFromPoints diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c index 15276fa669f..9a9def9e9e5 100644 --- a/dlls/d3dx8/math.c +++ b/dlls/d3dx8/math.c @@ -433,6 +433,30 @@ D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm) return pout; } +/*_________________D3DXPLANE________________*/ + +D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp) +{ + FLOAT norm; + + norm = sqrt(pp->a * pp->a + pp->b * pp->b + pp->c * pp->c); + if ( norm ) + { + pout->a = pp->a / norm; + pout->b = pp->b / norm; + pout->c = pp->c / norm; + pout->d = pp->d / norm; + } + else + { + pout->a = 0.0f; + pout->b = 0.0f; + pout->c = 0.0f; + pout->d = 0.0f; + } + return pout; +} + /*_________________D3DXQUATERNION________________*/ D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq) diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c index 9e862ab7612..e3dc06001d9 100644 --- a/dlls/d3dx8/tests/math.c +++ b/dlls/d3dx8/tests/math.c @@ -50,6 +50,8 @@ U(gotmat).m[3][0],U(gotmat).m[3][1],U(gotmat).m[3][2],U(gotmat).m[3][3]); \ } +#define expect_plane(expectedplane,gotplane) ok((fabs(expectedplane.a-gotplane.a)