From: Akiko Date: Fri, 25 Oct 2013 08:36:31 +0000 (+0200) Subject: - replaced default values by float ones (implicit float to int is more useful) X-Git-Url: http://community.linux-addicted.net/gitweb/?a=commitdiff_plain;h=bf6df3cb3db142b49cb7e0a106e9cff1f353cafe;p=qtinns.git - replaced default values by float ones (implicit float to int is more useful) - replaced gcc specific data alignment by C++11 version --- diff --git a/engine/Vector.hxx b/engine/Vector.hxx index c224610..9d41a84 100644 --- a/engine/Vector.hxx +++ b/engine/Vector.hxx @@ -27,18 +27,18 @@ class Vector2 { public: // --- Vector2: data structures --- - union { + alignas (16) union { struct { MT x; MT y; }; MT xy[2]; - } __attribute__((packed)); + }; // --- Vector2: constructors and deconstructors --- Vector2() - : xy{0, 0} + : xy{0.0, 0.0} { } @@ -309,7 +309,7 @@ public: bool isNull() const { - return x == 0 && y == 0; + return x == 0.0 && y == 0.0; } MT length() const @@ -345,12 +345,12 @@ public: Vector3 vector3() const { - return {x, y, 0}; + return {x, y, 0.0}; } Vector4 vector4() const { - return {x, y, 0, 0}; + return {x, y, 0.0, 0.0}; } // --- Vector2: static methods --- @@ -371,12 +371,12 @@ public: static Vector3 toVector3(const Vector2& vec) { - return {vec.x, vec.y, 0}; + return {vec.x, vec.y, 0.0}; } static Vector4 toVector4(const Vector2& vec) { - return {vec.x, vec.y, 0, 0}; + return {vec.x, vec.y, 0.0, 0.0}; } }; @@ -564,19 +564,19 @@ class Vector3 { public: // --- Vector3: data structures --- - union { + alignas (16) union { struct { MT x; MT y; MT z; }; MT xyz[3]; - } __attribute__((packed)); + }; // --- Vector3: constructors and deconstructors --- Vector3() - : xyz{0, 0, 0} + : xyz{0.0, 0.0, 0.0} { } @@ -591,7 +591,7 @@ public: } Vector3(const Vector2& vec) - : xyz{vec.x, vec.y, 0} + : xyz{vec.x, vec.y, 0.0} { } @@ -878,7 +878,7 @@ public: bool isNull() const { - return x == 0 && y == 0 && z == 0; + return x == 0.0 && y == 0.0 && z == 0.0; } MT length() const @@ -929,7 +929,7 @@ public: Vector4 vector4() const { - return {x, y, z, 0}; + return {x, y, z, 0.0}; } // --- Vector3: static methods --- @@ -972,7 +972,7 @@ public: static Vector4 toVector4(const Vector3& vec) { - return {vec.x, vec.y, vec.z, 0}; + return {vec.x, vec.y, vec.z, 0.0}; } }; @@ -1160,7 +1160,7 @@ class Vector4 { public: // --- Vector4: data structures --- - union { + alignas (16) union { struct { MT x; MT y; @@ -1168,12 +1168,12 @@ public: MT w; }; MT xyzw[4]; - } __attribute__((packed)); + }; // --- Vector4: constructors and deconstructors --- Vector4() - : xyzw{0, 0, 0, 0} + : xyzw{0.0, 0.0, 0.0, 0.0} { } @@ -1188,7 +1188,7 @@ public: } Vector4(const Vector2& vec) - : xyzw{vec.x, vec.y, 0, 0} + : xyzw{vec.x, vec.y, 0.0, 0.0} { } @@ -1203,7 +1203,7 @@ public: } Vector4(const Vector3& vec) - : xyzw{vec.x, vec.y, vec.z, 0} + : xyzw{vec.x, vec.y, vec.z, 0.0} { } @@ -1458,7 +1458,7 @@ public: bool isNull() const { - return x == 0 && y == 0 && z == 0 && w == 0; + return x == 0.0 && y == 0.0 && z == 0.0 && w == 0.0; } MT length() const