Commit e74a99b7 authored by Rico Schüller's avatar Rico Schüller Committed by Alexandre Julliard

d3dx9: Fix calculation when in and out overlap in D3DXSHRotateZ().

parent d814eca3
...@@ -2811,70 +2811,48 @@ FLOAT* WINAPI D3DXSHRotate(FLOAT *out, UINT order, CONST D3DXMATRIX *matrix, CON ...@@ -2811,70 +2811,48 @@ FLOAT* WINAPI D3DXSHRotate(FLOAT *out, UINT order, CONST D3DXMATRIX *matrix, CON
return out; return out;
} }
FLOAT * WINAPI D3DXSHRotateZ(FLOAT *out, UINT order, FLOAT angle, CONST FLOAT *in) FLOAT * WINAPI D3DXSHRotateZ(FLOAT *out, UINT order, FLOAT angle, const FLOAT *in)
{ {
FLOAT c1a, c2a, c3a, c4a, c5a, s1a, s2a, s3a, s4a, s5a; UINT i, sum = 0;
FLOAT c[5], s[5];
TRACE("out %p, order %u, angle %f, in %p\n", out, order, angle, in); TRACE("out %p, order %u, angle %f, in %p\n", out, order, angle, in);
c1a = cosf(angle); order = min(max(order, D3DXSH_MINORDER), D3DXSH_MAXORDER);
s1a = sinf(angle);
out[0] = in[0]; out[0] = in[0];
out[1] = c1a * in[1] + s1a * in[3];
out[2] = in[2];
out[3] = c1a * in[3] - s1a * in[1];
if (order <= D3DXSH_MINORDER)
return out;
c2a = cosf(2.0f * angle); for (i = 1; i < order; i++)
s2a = sinf(2.0f * angle); {
out[4] = c2a * in[4] + s2a * in[8]; UINT j;
out[5] = c1a * in[5] + s1a * in[7];
out[6] = in[6];
out[7] = c1a * in[7] - s1a * in[5];
out[8] = c2a * in[8] - s2a * in[4];
if (order == 3)
return out;
c3a = cosf(3.0f * angle); c[i - 1] = cosf(i * angle);
s3a = sinf(3.0f * angle); s[i - 1] = sinf(i * angle);
out[9] = c3a * in[9] + s3a * in[15]; sum += i * 2;
out[10] = c2a * in[10] + s2a * in[14];
out[11] = c1a * in[11] + s1a * in[13];
out[12] = in[12];
out[13] = c1a * in[13] - s1a * in[11];
out[14] = c2a * in[14] - s2a * in[10];
out[15] = c3a * in[15] - s3a * in[9];
if (order == 4)
return out;
c4a = cosf(4.0f * angle); out[sum - i] = c[i - 1] * in[sum - i];
s4a = sinf(4.0f * angle); out[sum - i] += s[i - 1] * in[sum + i];
out[16] = c4a * in[16] + s4a * in[24]; for (j = i - 1; j > 0; j--)
out[17] = c3a * in[17] + s3a * in[23]; {
out[18] = c2a * in[18] + s2a * in[22]; out[sum - j] = 0.0f;
out[19] = c1a * in[19] + s1a * in[21]; out[sum - j] = c[j - 1] * in[sum - j];
out[20] = in[20]; out[sum - j] += s[j - 1] * in[sum + j];
out[21] = c1a * in[21] - s1a * in[19]; }
out[22] = c2a * in[22] - s2a * in[18];
out[23] = c3a * in[23] - s3a * in[17]; if (in == out)
out[24] = c4a * in[24] - s4a * in[16]; out[sum] = 0.0f;
if (order == 5) else
return out; out[sum] = in[sum];
c5a = cosf(5.0f * angle); for (j = 1; j < i; j++)
s5a = sinf(5.0f * angle); {
out[25] = c5a * in[25] + s5a * in[35]; out[sum + j] = 0.0f;
out[26] = c4a * in[26] + s4a * in[34]; out[sum + j] = -s[j - 1] * in[sum - j];
out[27] = c3a * in[27] + s3a * in[33]; out[sum + j] += c[j - 1] * in[sum + j];
out[28] = c2a * in[28] + s2a * in[32]; }
out[29] = c1a * in[29] + s1a * in[31]; out[sum + i] = -s[i - 1] * in[sum - i];
out[30] = in[30]; out[sum + i] += c[i - 1] * in[sum + i];
out[31] = c1a * in[31] - s1a * in[29]; }
out[32] = c2a * in[32] - s2a * in[28];
out[33] = c3a * in[33] - s3a * in[27];
out[34] = c4a * in[34] - s4a * in[26];
out[35] = c5a * in[35] - s5a * in[25];
return out; return out;
} }
......
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