diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/quaternion.h | 5 | ||||
-rw-r--r-- | src/common/scm_rev.cpp.in | 2 | ||||
-rw-r--r-- | src/common/scm_rev.h | 1 | ||||
-rw-r--r-- | src/common/vector_math.h | 7 |
4 files changed, 11 insertions, 4 deletions
diff --git a/src/common/quaternion.h b/src/common/quaternion.h index 84ac82ed3..77f626bcb 100644 --- a/src/common/quaternion.h +++ b/src/common/quaternion.h @@ -30,6 +30,11 @@ public: return {xyz * other.w + other.xyz * w + Cross(xyz, other.xyz), w * other.w - Dot(xyz, other.xyz)}; } + + Quaternion<T> Normalized() const { + T length = std::sqrt(xyz.Length2() + w * w); + return {xyz / length, w / length}; + } }; template <typename T> diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in index 0080db5d5..4083095d5 100644 --- a/src/common/scm_rev.cpp.in +++ b/src/common/scm_rev.cpp.in @@ -8,6 +8,7 @@ #define GIT_BRANCH "@GIT_BRANCH@" #define GIT_DESC "@GIT_DESC@" #define BUILD_NAME "@REPO_NAME@" +#define BUILD_DATE "@BUILD_DATE@" namespace Common { @@ -15,6 +16,7 @@ const char g_scm_rev[] = GIT_REV; const char g_scm_branch[] = GIT_BRANCH; const char g_scm_desc[] = GIT_DESC; const char g_build_name[] = BUILD_NAME; +const char g_build_date[] = BUILD_DATE; } // namespace diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h index e22389803..18aaa1735 100644 --- a/src/common/scm_rev.h +++ b/src/common/scm_rev.h @@ -10,5 +10,6 @@ extern const char g_scm_rev[]; extern const char g_scm_branch[]; extern const char g_scm_desc[]; extern const char g_build_name[]; +extern const char g_build_date[]; } // namespace diff --git a/src/common/vector_math.h b/src/common/vector_math.h index c7a461a1e..6e2a5ad60 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -31,7 +31,6 @@ #pragma once #include <cmath> -#include <type_traits> namespace Math { @@ -90,7 +89,7 @@ public: x -= other.x; y -= other.y; } - template <typename Q = T, class = typename std::enable_if<std::is_signed<Q>::value>::type> + Vec2<decltype(-T{})> operator-() const { return MakeVec(-x, -y); } @@ -247,7 +246,7 @@ public: y -= other.y; z -= other.z; } - template <typename Q = T, class = typename std::enable_if<std::is_signed<Q>::value>::type> + Vec3<decltype(-T{})> operator-() const { return MakeVec(-x, -y, -z); } @@ -462,7 +461,7 @@ public: z -= other.z; w -= other.w; } - template <typename Q = T, class = typename std::enable_if<std::is_signed<Q>::value>::type> + Vec4<decltype(-T{})> operator-() const { return MakeVec(-x, -y, -z, -w); } |