d3drm: Implement D3DRMVectorNormalize.
This commit is contained in:
parent
5524923c07
commit
819362d0f7
|
@ -12,7 +12,7 @@
|
||||||
@ stdcall D3DRMVectorCrossProduct(ptr ptr ptr)
|
@ stdcall D3DRMVectorCrossProduct(ptr ptr ptr)
|
||||||
@ stdcall D3DRMVectorDotProduct(ptr ptr)
|
@ stdcall D3DRMVectorDotProduct(ptr ptr)
|
||||||
@ stdcall D3DRMVectorModulus(ptr)
|
@ stdcall D3DRMVectorModulus(ptr)
|
||||||
@ stub D3DRMVectorNormalize
|
@ stdcall D3DRMVectorNormalize(ptr)
|
||||||
@ stub D3DRMVectorRandom
|
@ stub D3DRMVectorRandom
|
||||||
@ stub D3DRMVectorReflect
|
@ stub D3DRMVectorReflect
|
||||||
@ stub D3DRMVectorRotate
|
@ stub D3DRMVectorRotate
|
||||||
|
|
|
@ -75,6 +75,23 @@ D3DVALUE WINAPI D3DRMVectorModulus(LPD3DVECTOR v)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Normalize a vector. Returns (1,0,0) if INPUT is the NULL vector. */
|
||||||
|
LPD3DVECTOR WINAPI D3DRMVectorNormalize(LPD3DVECTOR u)
|
||||||
|
{
|
||||||
|
D3DVALUE modulus = D3DRMVectorModulus(u);
|
||||||
|
if(modulus)
|
||||||
|
{
|
||||||
|
D3DRMVectorScale(u,u,1.0/modulus);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
u->x=1.0;
|
||||||
|
u->y=0.0;
|
||||||
|
u->z=0.0;
|
||||||
|
}
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
/* Scale a vector */
|
/* Scale a vector */
|
||||||
LPD3DVECTOR WINAPI D3DRMVectorScale(LPD3DVECTOR d, LPD3DVECTOR s, D3DVALUE factor)
|
LPD3DVECTOR WINAPI D3DRMVectorScale(LPD3DVECTOR d, LPD3DVECTOR s, D3DVALUE factor)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
void VectorTest(void)
|
void VectorTest(void)
|
||||||
{
|
{
|
||||||
D3DVALUE mod,par;
|
D3DVALUE mod,par;
|
||||||
D3DVECTOR e,r,u,v;
|
D3DVECTOR e,r,u,v,casnul;
|
||||||
|
|
||||||
u.x=2.0;u.y=2.0;u.z=1.0;
|
u.x=2.0;u.y=2.0;u.z=1.0;
|
||||||
v.x=4.0;v.y=4.0;v.z=0.0;
|
v.x=4.0;v.y=4.0;v.z=0.0;
|
||||||
|
@ -61,6 +61,18 @@ void VectorTest(void)
|
||||||
mod=D3DRMVectorModulus(&u);
|
mod=D3DRMVectorModulus(&u);
|
||||||
ok((mod == 3.0), "Expected 3.0, Got %f",mod);
|
ok((mod == 3.0), "Expected 3.0, Got %f",mod);
|
||||||
|
|
||||||
|
/*_______________________VectorNormalize___________________________*/
|
||||||
|
D3DRMVectorNormalize(&u);
|
||||||
|
e.x=2.0/3.0;e.y=2.0/3.0;e.z=1.0/3.0;
|
||||||
|
expect_vec(e,u);
|
||||||
|
|
||||||
|
/* If u is the NULL vector, MSDN says that the return vector is NULL. In fact, the returned vector is (1,0,0). The following test case prove it. */
|
||||||
|
|
||||||
|
casnul.x=0.0; casnul.y=0.0; casnul.z=0.0;
|
||||||
|
D3DRMVectorNormalize(&casnul);
|
||||||
|
e.x=1.0; e.y=0.0; e.z=0.0;
|
||||||
|
expect_vec(e,casnul);
|
||||||
|
|
||||||
/*_______________________VectorScale__________________________*/
|
/*_______________________VectorScale__________________________*/
|
||||||
par=2.5;
|
par=2.5;
|
||||||
D3DRMVectorScale(&r,&v,par);
|
D3DRMVectorScale(&r,&v,par);
|
||||||
|
|
Loading…
Reference in New Issue