From 2787d1230b89d2e9fb95cfb6cef4c4bd69210420 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 01:55:06 -0500 Subject: [PATCH 1/4] common/math_util: Remove unused IntervalsIntersect() function This hasn't been used since the project started, so we may as well get rid of it to keep it from bit rotting. --- src/common/math_util.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/common/math_util.h b/src/common/math_util.h index 343cdd902..b553d47dd 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -4,7 +4,6 @@ #pragma once -#include #include #include @@ -12,11 +11,6 @@ namespace MathUtil { static constexpr float PI = 3.14159265f; -inline bool IntervalsIntersect(unsigned start0, unsigned length0, unsigned start1, - unsigned length1) { - return (std::max(start0, start1) < std::min(start0 + length0, start1 + length1)); -} - template struct Rectangle { T left{}; From bf8f7f0ab6c33c52c63173235a5796b0bb517e85 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 01:56:14 -0500 Subject: [PATCH 2/4] common/math_util: Remove unnecessary static from PI const/constexpr variables have internal linkage by default. --- src/common/math_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/math_util.h b/src/common/math_util.h index b553d47dd..cbcc414be 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -9,7 +9,7 @@ namespace MathUtil { -static constexpr float PI = 3.14159265f; +constexpr float PI = 3.14159265f; template struct Rectangle { From 8d169a4bfa2e96a2483cde2a4b113f2cc82d4901 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 01:57:32 -0500 Subject: [PATCH 3/4] common/math_util: Make Rectangle's constructors constexpr Allows objects that contain rectangle instances to be constexpr constructible as well. --- src/common/math_util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/math_util.h b/src/common/math_util.h index cbcc414be..cf5ad8457 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -18,9 +18,9 @@ struct Rectangle { T right{}; T bottom{}; - Rectangle() = default; + constexpr Rectangle() = default; - Rectangle(T left, T top, T right, T bottom) + constexpr Rectangle(T left, T top, T right, T bottom) : left(left), top(top), right(right), bottom(bottom) {} T GetWidth() const { From d37c826097101fa7ac59fb1e90e9419090d41380 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 01:59:27 -0500 Subject: [PATCH 4/4] common/math_util: Simplify std::make_signed usages to std::make_signed_t Gets rid of the need to use typename to access the ::type alias. --- src/common/math_util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/math_util.h b/src/common/math_util.h index cf5ad8457..94b4394c5 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -24,10 +24,10 @@ struct Rectangle { : left(left), top(top), right(right), bottom(bottom) {} T GetWidth() const { - return std::abs(static_cast::type>(right - left)); + return std::abs(static_cast>(right - left)); } T GetHeight() const { - return std::abs(static_cast::type>(bottom - top)); + return std::abs(static_cast>(bottom - top)); } Rectangle TranslateX(const T x) const { return Rectangle{left + x, top, right + x, bottom};