From aaec1656f3f74a911cf6b4544670b344d3f41d63 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 1 Feb 2016 16:16:48 +0100 Subject: [PATCH] Closes https://github.com/assimp/assimp/issues/43 : provide different matrix scheme via union. --- include/assimp/matrix3x3.h | 28 +++++++++++++++++++--------- include/assimp/matrix4x4.h | 36 +++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/include/assimp/matrix3x3.h b/include/assimp/matrix3x3.h index 802505143..6b2350efc 100644 --- a/include/assimp/matrix3x3.h +++ b/include/assimp/matrix3x3.h @@ -161,10 +161,15 @@ public: public: - - TReal a1, a2, a3; - TReal b1, b2, b3; - TReal c1, c2, c3; + union { + struct { + TReal a1, a2, a3; + TReal b1, b2, b3; + TReal c1, c2, c3; + }; + TReal m[ 3 ][ 3 ]; + TReal mData[ 9 ]; + }; } PACK_STRUCT; typedef aiMatrix3x3t aiMatrix3x3; @@ -172,13 +177,18 @@ typedef aiMatrix3x3t aiMatrix3x3; #else struct aiMatrix3x3 { - - float a1, a2, a3; - float b1, b2, b3; - float c1, c2, c3; + union { + struct { + float a1, a2, a3; + float b1, b2, b3; + float c1, c2, c3; + }; + float m[ 3 ][ 3 ]; + float mData[ 9 ]; + }; } PACK_STRUCT; -#endif +#endif // __cplusplus #include "./Compiler/poppack1.h" diff --git a/include/assimp/matrix4x4.h b/include/assimp/matrix4x4.h index 3b7b6948c..79ef26774 100644 --- a/include/assimp/matrix4x4.h +++ b/include/assimp/matrix4x4.h @@ -213,8 +213,8 @@ public: /** @brief A function for creating a rotation matrix that rotates a * vector called "from" into another vector called "to". * Input : from[3], to[3] which both must be *normalized* non-zero vectors - * Output: mtx[3][3] -- a 3x3 matrix in colum-major form - * Authors: Tomas M�ller, John Hughes + * Output: mtx[3][3] -- a 3x3 matrix in column-major form + * Authors: Tomas Mueller, John Hughes * "Efficiently Building a Matrix to Rotate One Vector to Another" * Journal of Graphics Tools, 4(4):1-4, 1999 */ @@ -222,12 +222,16 @@ public: const aiVector3t& to, aiMatrix4x4t& out); public: - - TReal a1, a2, a3, a4; - TReal b1, b2, b3, b4; - TReal c1, c2, c3, c4; - TReal d1, d2, d3, d4; - + union { + struct { + TReal a1, a2, a3, a4; + TReal b1, b2, b3, b4; + TReal c1, c2, c3, c4; + TReal d1, d2, d3, d4; + }; + TReal m[ 4 ][ 4 ]; + TReal mData[ 16 ]; + }; } PACK_STRUCT; typedef aiMatrix4x4t aiMatrix4x4; @@ -235,11 +239,17 @@ typedef aiMatrix4x4t aiMatrix4x4; #else struct aiMatrix4x4 { - float a1, a2, a3, a4; - float b1, b2, b3, b4; - float c1, c2, c3, c4; - float d1, d2, d3, d4; -}; + union { + struct { + float a1, a2, a3, a4; + float b1, b2, b3, b4; + float c1, c2, c3, c4; + float d1, d2, d3, d4; + }; + float m[ 4 ][ 4 ]; + float mData[ 16 ]; + }; +} PACK_STRUCT; #endif // __cplusplus