From 74fd0aa2e8b41d2ec130b06478fe011117fdbae8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 01:55:06 -0500 Subject: 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(-) (limited to 'src/common') 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{}; -- cgit v1.2.3 From cc0801745a37c35e98562239b3121dc658366a79 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 01:56:14 -0500 Subject: 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(-) (limited to 'src/common') 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 { -- cgit v1.2.3 From f11173f88cac03eab021d27725805128d046fd0d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 01:57:32 -0500 Subject: 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(-) (limited to 'src/common') 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 { -- cgit v1.2.3 From 45211a7a9183f8f62cb3e90b6e718cf33e46bec6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 01:59:27 -0500 Subject: 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(-) (limited to 'src/common') 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}; -- cgit v1.2.3