From 931c747e49f581db59d4ae0b39baae4877ea7f89 Mon Sep 17 00:00:00 2001 From: Akiko Date: Fri, 25 Oct 2013 12:44:50 +0200 Subject: [PATCH] - added missing static asserts - replaced default values by float ones --- engine/Quaternion.hxx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/engine/Quaternion.hxx b/engine/Quaternion.hxx index e5652d6..23a8b69 100644 --- a/engine/Quaternion.hxx +++ b/engine/Quaternion.hxx @@ -1,17 +1,15 @@ #pragma once -#include -#include -#include -#include #include "Vector.hxx" template class Quaternion { + static_assert (std::is_integral::value || std::is_floating_point::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 rotatedVector3(const Vector3& vec) const { - return (*this * Quaternion(0, vec) * conjugated()).vector3(); + return (*this * Quaternion(0.0, vec) * conjugated()).vector3(); } std::string string() const -- 2.15.1