I had another look and like to give some suggestion.
On 02.09.2012 22:28, Nozomi Kodama wrote: + sinb = sqrt( 1.0f - matrix->u.m[2][2] * matrix->u.m[2][2] );
I'd prefer to declare the variables as locally as possible.
+ D3DXSHRotateZ(temp5, order, alpha, temp4); + memcpy(out, temp5, sizeof(float) * order * order); + + return out;
You probably may avoid the memcpy. What do you think about something like: return D3DXSHRotateZ(out, order, alpha, temp4);
+ FLOAT alpha, beta, gamma, sinb, temp1[36], temp2[36], temp3[36], temp4[36], temp5[36];
Do we really need that much temps? I think one is enough, but definitively 2 (I think you are able to use out as one "temp"). If you don't like the usage of out, you may use temp2 instead, but I think it could be avoided.
D3DXSHRotateZ(out, order, gamma, in); RotateX(temp, order, 1, out); D3DXSHRotateZ(out, order, beta, temp); RotateX(temp, order, 0, out); D3DXSHRotateZ(out, order, alpha, temp);
+static FLOAT* RotateX(FLOAT *out, UINT order, UINT pm, FLOAT *in)
The return value is never used. Probably you may return void or you'd like to stack the function calls above a bit and reuse the returned pointer. You also may use "BOOL pm" since it uses only 0 and 1 or you may pass the "FLOAT a" directly to the function. Whatever pm stands for...
Cheers Rico
On 3 September 2012 12:02, Rico Schüller kgbricola@web.de wrote:
sinb = sqrt( 1.0f - matrix->u.m[2][2] * matrix->u.m[2][2] );
I'd prefer to declare the variables as locally as possible.
As an aside, you'll probably want to use floating point functions like sqrtf() instead of ones operating on doubles like sqrt() in most of d3dx9. That's not a new issue though.