summaryrefslogtreecommitdiff
path: root/src/common/math_util.h
diff options
context:
space:
mode:
authorGravatar Emmanuel Gil Peyrot2016-09-18 09:38:01 +0900
committerGravatar Emmanuel Gil Peyrot2016-09-18 09:38:01 +0900
commitdc8479928c5aee4c6ad6fe4f59006fb604cee701 (patch)
tree569a7f13128450bbab973236615587ff00bced5f /src/common/math_util.h
parentTravis: Import Dolphin’s clang-format hook. (diff)
downloadyuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.gz
yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.xz
yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.zip
Sources: Run clang-format on everything.
Diffstat (limited to 'src/common/math_util.h')
-rw-r--r--src/common/math_util.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/common/math_util.h b/src/common/math_util.h
index d44b06e74..696bd43ea 100644
--- a/src/common/math_util.h
+++ b/src/common/math_util.h
@@ -8,33 +8,38 @@
8#include <cstdlib> 8#include <cstdlib>
9#include <type_traits> 9#include <type_traits>
10 10
11namespace MathUtil 11namespace MathUtil {
12{
13 12
14inline bool IntervalsIntersect(unsigned start0, unsigned length0, unsigned start1, unsigned length1) { 13inline bool IntervalsIntersect(unsigned start0, unsigned length0, unsigned start1,
14 unsigned length1) {
15 return (std::max(start0, start1) < std::min(start0 + length0, start1 + length1)); 15 return (std::max(start0, start1) < std::min(start0 + length0, start1 + length1));
16} 16}
17 17
18template<typename T> 18template <typename T>
19inline T Clamp(const T val, const T& min, const T& max) 19inline T Clamp(const T val, const T& min, const T& max) {
20{
21 return std::max(min, std::min(max, val)); 20 return std::max(min, std::min(max, val));
22} 21}
23 22
24template<class T> 23template <class T>
25struct Rectangle 24struct Rectangle {
26{
27 T left; 25 T left;
28 T top; 26 T top;
29 T right; 27 T right;
30 T bottom; 28 T bottom;
31 29
32 Rectangle() {} 30 Rectangle() {
31 }
33 32
34 Rectangle(T left, T top, T right, T bottom) : left(left), top(top), right(right), bottom(bottom) {} 33 Rectangle(T left, T top, T right, T bottom)
34 : left(left), top(top), right(right), bottom(bottom) {
35 }
35 36
36 T GetWidth() const { return std::abs(static_cast<typename std::make_signed<T>::type>(right - left)); } 37 T GetWidth() const {
37 T GetHeight() const { return std::abs(static_cast<typename std::make_signed<T>::type>(bottom - top)); } 38 return std::abs(static_cast<typename std::make_signed<T>::type>(right - left));
39 }
40 T GetHeight() const {
41 return std::abs(static_cast<typename std::make_signed<T>::type>(bottom - top));
42 }
38}; 43};
39 44
40} // namespace MathUtil 45} // namespace MathUtil