- added missing static asserts
authorAkiko <akiko@linux-addicted.net>
Fri, 25 Oct 2013 10:44:50 +0000 (12:44 +0200)
committerAkiko <akiko@linux-addicted.net>
Fri, 25 Oct 2013 10:44:50 +0000 (12:44 +0200)
- replaced default values by float ones

engine/Quaternion.hxx

index e5652d6..23a8b69 100644 (file)
@@ -1,17 +1,15 @@
 #pragma once
 
-#include <cmath>
-#include <iostream>
-#include <sstream>
-#include <type_traits>
 #include "Vector.hxx"
 
 template <typename MT>
 class Quaternion {
+    static_assert (std::is_integral<MT>::value || std::is_floating_point<MT>::value,
+                   "ERROR: template parameter is not an integral or floating point type");
 public:
     // --- public data structurs ---
 
-    union {
+    alignas (16) union {
         struct {
             MT s;
             MT x;
@@ -19,12 +17,12 @@ public:
             MT z;
         };
         MT sxyz[4];
-    } __attribute__((packed));
+    };
 
     // --- constructors and deconstructors ---
 
     Quaternion()
-    : sxyz{1, 0, 0, 0}
+    : sxyz{1.0, 0.0, 0.0, 0.0}
     {
     }
 
@@ -297,12 +295,12 @@ public:
 
     bool isIdentity() const
     {
-        return s == 1 && x == 0 && y == 0 && z == 0;
+        return s == 1.0 && x == 0.0 && y == 0.0 && z == 0.0;
     }
 
     bool isNull() const
     {
-        return s == 0 && x == 0 && y == 0 && z == 0;
+        return s == 0.0 && x == 0.0 && y == 0.0 && z == 0.0;
     }
 
     MT length() const
@@ -327,7 +325,7 @@ public:
 
     Vector3<MT> rotatedVector3(const Vector3<MT>& vec) const
     {
-        return (*this * Quaternion(0, vec) * conjugated()).vector3();
+        return (*this * Quaternion(0.0, vec) * conjugated()).vector3();
     }
 
     std::string string() const