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

d3dx9: D3DXQuaternionSquadSetup should support arguments aliasing.

parent 453d9f7b
......@@ -1587,6 +1587,7 @@ static D3DXQUATERNION add_diff(const D3DXQUATERNION *q1, const D3DXQUATERNION *q
void WINAPI D3DXQuaternionSquadSetup(D3DXQUATERNION *paout, D3DXQUATERNION *pbout, D3DXQUATERNION *pcout, const D3DXQUATERNION *pq0, const D3DXQUATERNION *pq1, const D3DXQUATERNION *pq2, const D3DXQUATERNION *pq3)
{
D3DXQUATERNION q, temp1, temp2, temp3, zero;
D3DXQUATERNION aout, cout;
TRACE("paout %p, pbout %p, pcout %p, pq0 %p, pq1 %p, pq2 %p, pq3 %p\n", paout, pbout, pcout, pq0, pq1, pq2, pq3);
......@@ -1595,17 +1596,17 @@ void WINAPI D3DXQuaternionSquadSetup(D3DXQUATERNION *paout, D3DXQUATERNION *pbou
zero.z = 0.0f;
zero.w = 0.0f;
if ( D3DXQuaternionDot(pq0, pq1) < 0.0f )
if (D3DXQuaternionDot(pq0, pq1) < 0.0f)
temp2 = add_diff(&zero, pq0, -1.0f);
else
temp2 = *pq0;
if ( D3DXQuaternionDot(pq1, pq2) < 0.0f )
*pcout = add_diff(&zero, pq2, -1.0f);
if (D3DXQuaternionDot(pq1, pq2) < 0.0f)
cout = add_diff(&zero, pq2, -1.0f);
else
*pcout = *pq2;
cout = *pq2;
if ( D3DXQuaternionDot(pcout, pq3) < 0.0f )
if (D3DXQuaternionDot(&cout, pq3) < 0.0f)
temp3 = add_diff(&zero, pq3, -1.0f);
else
temp3 = *pq3;
......@@ -1613,7 +1614,7 @@ void WINAPI D3DXQuaternionSquadSetup(D3DXQUATERNION *paout, D3DXQUATERNION *pbou
D3DXQuaternionInverse(&temp1, pq1);
D3DXQuaternionMultiply(&temp2, &temp1, &temp2);
D3DXQuaternionLn(&temp2, &temp2);
D3DXQuaternionMultiply(&q, &temp1, pcout);
D3DXQuaternionMultiply(&q, &temp1, &cout);
D3DXQuaternionLn(&q, &q);
temp1 = add_diff(&temp2, &q, 1.0f);
temp1.x *= -0.25f;
......@@ -1621,9 +1622,9 @@ void WINAPI D3DXQuaternionSquadSetup(D3DXQUATERNION *paout, D3DXQUATERNION *pbou
temp1.z *= -0.25f;
temp1.w *= -0.25f;
D3DXQuaternionExp(&temp1, &temp1);
D3DXQuaternionMultiply(paout, pq1, &temp1);
D3DXQuaternionMultiply(&aout, pq1, &temp1);
D3DXQuaternionInverse(&temp1, pcout);
D3DXQuaternionInverse(&temp1, &cout);
D3DXQuaternionMultiply(&temp2, &temp1, pq1);
D3DXQuaternionLn(&temp2, &temp2);
D3DXQuaternionMultiply(&q, &temp1, &temp3);
......@@ -1634,9 +1635,9 @@ void WINAPI D3DXQuaternionSquadSetup(D3DXQUATERNION *paout, D3DXQUATERNION *pbou
temp1.z *= -0.25f;
temp1.w *= -0.25f;
D3DXQuaternionExp(&temp1, &temp1);
D3DXQuaternionMultiply(pbout, pcout, &temp1);
return;
D3DXQuaternionMultiply(pbout, &cout, &temp1);
*paout = aout;
*pcout = cout;
}
void WINAPI D3DXQuaternionToAxisAngle(const D3DXQUATERNION *pq, D3DXVECTOR3 *paxis, FLOAT *pangle)
......
......@@ -975,42 +975,49 @@ static void D3DXQuaternionTest(void)
s.x = -3.0f; s.y = 4.0f; s.z = -5.0f; s.w = 7.0;
t.x = -1111.0f, t.y = 111.0f; t.z = -11.0f; t.w = 1.0f;
u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
D3DXQuaternionSquadSetup(&gotquat,&Nq,&Nq1,&r,&s,&t,&u);
D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &u);
expectedquat.x = 7.121285f; expectedquat.y = 2.159964f; expectedquat.z = -3.855094f; expectedquat.w = 5.362844f;
expect_vec4(expectedquat,gotquat);
expect_vec4(expectedquat, gotquat);
expectedquat.x = -1113.492920f; expectedquat.y = 82.679260f; expectedquat.z = -6.696645f; expectedquat.w = -4.090050f;
expect_vec4(expectedquat,Nq);
expect_vec4(expectedquat, Nq);
expectedquat.x = -1111.0f; expectedquat.y = 111.0f; expectedquat.z = -11.0f; expectedquat.w = 1.0f;
expect_vec4(expectedquat,Nq1);
expect_vec4(expectedquat, Nq1);
gotquat = s;
D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &gotquat, &t, &u);
expectedquat.x = -1113.492920f; expectedquat.y = 82.679260f; expectedquat.z = -6.696645f; expectedquat.w = -4.090050f;
expect_vec4(expectedquat, Nq);
Nq1 = u;
D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &Nq1);
expect_vec4(expectedquat, Nq);
r.x = 0.2f; r.y = 0.3f; r.z = 1.3f; r.w = -0.6f;
s.x = -3.0f; s.y =-2.0f; s.z = 4.0f; s.w = 0.2f;
t.x = 0.4f; t.y = 8.3f; t.z = -3.1f; t.w = -2.7f;
u.x = 1.1f; u.y = -0.7f; u.z = 9.2f; u.w = 0.0f;
D3DXQuaternionSquadSetup(&gotquat,&Nq,&Nq1,&r,&s,&u,&t);
D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &u, &t);
expectedquat.x = -4.139569f; expectedquat.y = -2.469115f; expectedquat.z = 2.364477f; expectedquat.w = 0.465494f;
expect_vec4(expectedquat,gotquat);
expect_vec4(expectedquat, gotquat);
expectedquat.x = 2.342533f; expectedquat.y = 2.365127f; expectedquat.z = 8.628538f; expectedquat.w = -0.898356f;
expect_vec4(expectedquat,Nq);
expect_vec4(expectedquat, Nq);
expectedquat.x = 1.1f; expectedquat.y = -0.7f; expectedquat.z = 9.2f; expectedquat.w = 0.0f;
expect_vec4(expectedquat,Nq1);
D3DXQuaternionSquadSetup(&gotquat,&Nq,&Nq1,&r,&s,&t,&u);
expect_vec4(expectedquat, Nq1);
D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &u);
expectedquat.x = -3.754567f; expectedquat.y = -0.586085f; expectedquat.z = 3.815818f; expectedquat.w = -0.198150f;
expect_vec4(expectedquat,gotquat);
expect_vec4(expectedquat, gotquat);
expectedquat.x = 0.140773f; expectedquat.y = -8.737090f; expectedquat.z = -0.516593f; expectedquat.w = 3.053942f;
expect_vec4(expectedquat,Nq);
expect_vec4(expectedquat, Nq);
expectedquat.x = -0.4f; expectedquat.y = -8.3f; expectedquat.z = 3.1f; expectedquat.w = 2.7f;
expect_vec4(expectedquat,Nq1);
expect_vec4(expectedquat, Nq1);
r.x = -1.0f; r.y = 0.0f; r.z = 0.0f; r.w = 0.0f;
s.x = 1.0f; s.y =0.0f; s.z = 0.0f; s.w = 0.0f;
t.x = 1.0f; t.y = 0.0f; t.z = 0.0f; t.w = 0.0f;
u.x = -1.0f; u.y = 0.0f; u.z = 0.0f; u.w = 0.0f;
D3DXQuaternionSquadSetup(&gotquat,&Nq,&Nq1,&r,&s,&t,&u);
D3DXQuaternionSquadSetup(&gotquat, &Nq, &Nq1, &r, &s, &t, &u);
expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
expect_vec4(expectedquat,gotquat);
expect_vec4(expectedquat, gotquat);
expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
expect_vec4(expectedquat,Nq);
expect_vec4(expectedquat, Nq);
expectedquat.x = 1.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
expect_vec4(expectedquat,Nq1);
expect_vec4(expectedquat, Nq1);
/*_______________D3DXQuaternionToAxisAngle__________________*/
Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
......
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