For example, I have a QMatrix4x4 and I have a Ogre::Matrix4.
Converting back and forth from QMatrix to Ogre::Matrix4 is a bit tedious, I would like to know if there are any solid solutions?
Right now I’m simply copying each element over in a for loop, any suggestions?
In C++11, if both types are layout-compatible, you can simply
reinterpret_castbetween them. Example:(I hope I got the example right; live on Ideone.)
The problem with this approach is that you’ll need to dig into the internals of the implementations, which might not be stable over different releases even. As such, simply copying is likely the best (as in most portable / known / solid) approach.
One thing though: I personally don’t know which interfaces the types in question offer, Ogre might also offer algorithms that don’t directly operate on a
Matrix4but on an (2D) array aswell. Check the API documentation.