matrix = *((fxMatrix*)&d3dMatrix); //Evil?

Posted by Xilliah on Stack Overflow See other posts from Stack Overflow or by Xilliah
Published on 2011-01-03T11:38:42Z Indexed on 2011/01/03 12:54 UTC
Read the original article Hit count: 166

Filed under:
|
|
|
|

I've been using

matrix = *((fxMatrix*)&d3dMatrix);

for quite a while. It worked fine until my screen turned black and received a bucket of frustration on my desk.

fxMatrix contains 4 fxVectors. fxVector used to be 16 bytes, but now it was suddenly 20. This was because it inherited fxStreamable, which added the vTable.

So one solution is of course just to not inherit fxStreamable, and leave a comment saying that it must always be 16 bytes and never more.

Another solution would be to make conversion functions, and copy the matrix completely. This makes it more secure, but has an impact on the performance. I suppose this is the best idea.

Another solution is to not convert at all, and stick to D3DXMATRIX, but this makes the engine inconsistent and I personally really dislike this idea.

What is your opinion?

© Stack Overflow or respective owner

Related posts about c++

Related posts about conversion