mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
d3dx8: Implement D3DXPlaneNormalize.
This commit is contained in:
parent
d1a3025826
commit
8abfaa04cc
4 changed files with 43 additions and 2 deletions
|
@ -61,7 +61,7 @@
|
|||
@ stub D3DXQuaternionSlerp
|
||||
@ stub D3DXQuaternionSquad
|
||||
@ stub D3DXQuaternionBaryCentric
|
||||
@ stub D3DXPlaneNormalize
|
||||
@ stdcall D3DXPlaneNormalize(ptr ptr)
|
||||
@ stub D3DXPlaneIntersectLine
|
||||
@ stub D3DXPlaneFromPointNormal
|
||||
@ stub D3DXPlaneFromPoints
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)<admitted_error)&&(fabs(expectedplane.b-gotplane.b)<admitted_error)&&(fabs(expectedplane.c-gotplane.c)<admitted_error)&&(fabs(expectedplane.d-gotplane.d)<admitted_error),"Expected Plane= (%f, %f, %f, %f)\n , Got Plane= (%f, %f, %f, %f)\n", expectedplane.a, expectedplane.b, expectedplane.c, expectedplane.d, gotplane.a, gotplane.b, gotplane.c, gotplane.d);
|
||||
|
||||
#define expect_vec(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
|
||||
|
||||
#define expect_vec3(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error),"Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
|
||||
|
@ -413,7 +415,7 @@ static void D3DXMatrixTest(void)
|
|||
|
||||
static void D3DXPlaneTest(void)
|
||||
{
|
||||
D3DXPLANE plane;
|
||||
D3DXPLANE expectedplane, gotplane, nulplane, plane;
|
||||
D3DXVECTOR4 vec;
|
||||
FLOAT expected, got;
|
||||
|
||||
|
@ -452,6 +454,19 @@ static void D3DXPlaneTest(void)
|
|||
expected = 0.0f;
|
||||
got = D3DXPlaneDotNormal(NULL,NULL),
|
||||
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
||||
|
||||
/*_______________D3DXPlaneDotNormalize______________*/
|
||||
expectedplane.a = -3.0f/sqrt(26.0f); expectedplane.b = -1.0f/sqrt(26.0f); expectedplane.c = 4.0f/sqrt(26.0f); expectedplane.d = 7.0/sqrt(26.0f);
|
||||
D3DXPlaneNormalize(&gotplane, &plane);
|
||||
expect_plane(expectedplane, gotplane);
|
||||
nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 0.0f;
|
||||
expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
|
||||
D3DXPlaneNormalize(&gotplane, &nulplane);
|
||||
expect_plane(expectedplane, gotplane);
|
||||
nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 4.3f;
|
||||
expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
|
||||
D3DXPlaneNormalize(&gotplane, &nulplane);
|
||||
expect_plane(expectedplane, gotplane);
|
||||
}
|
||||
|
||||
static void D3X8QuaternionTest(void)
|
||||
|
|
|
@ -291,6 +291,8 @@ D3DXMATRIX* WINAPI D3DXMatrixScaling(D3DXMATRIX *pout, FLOAT sx, FLOAT sy, FLOAT
|
|||
D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y, FLOAT z);
|
||||
D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm);
|
||||
|
||||
D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp);
|
||||
|
||||
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
|
||||
|
||||
D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g);
|
||||
|
|
Loading…
Reference in a new issue