- replaced default values by float ones (implicit float to int is more useful)
authorAkiko <akiko@linux-addicted.net>
Fri, 25 Oct 2013 08:36:31 +0000 (10:36 +0200)
committerAkiko <akiko@linux-addicted.net>
Fri, 25 Oct 2013 08:36:31 +0000 (10:36 +0200)
- replaced gcc specific data alignment by C++11 version

engine/Vector.hxx

index c224610..9d41a84 100644 (file)
@@ -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{00}
+    : 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<MT> vector3() const
     {
-        return {x, y, 0};
+        return {x, y, 0.0};
     }
 
     Vector4<MT> vector4() const
     {
-        return {x, y, 00};
+        return {x, y, 0.0, 0.0};
     }
 
     // --- Vector2: static methods ---
@@ -371,12 +371,12 @@ public:
 
     static Vector3<MT> toVector3(const Vector2& vec)
     {
-        return {vec.x, vec.y, 0};
+        return {vec.x, vec.y, 0.0};
     }
 
     static Vector4<MT> toVector4(const Vector2& vec)
     {
-        return {vec.x, vec.y, 00};
+        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<MT>& 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<MT> vector4() const
     {
-        return {x, y, z, 0};
+        return {x, y, z, 0.0};
     }
 
     // --- Vector3: static methods ---
@@ -972,7 +972,7 @@ public:
 
     static Vector4<MT> 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<MT>& vec)
-    : xyzw{vec.x, vec.y, 00}
+    : xyzw{vec.x, vec.y, 0.0, 0.0}
     {
     }
 
@@ -1203,7 +1203,7 @@ public:
     }
 
     Vector4(const Vector3<MT>& 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