mirror of
https://github.com/citra-emu/citra-canary.git
synced 2024-12-24 16:05:34 +00:00
Merge pull request #4454 from FearlessTobi/port-1758
Port yuzu-emu/yuzu#1758: "common/math_util: Minor cleanup"
This commit is contained in:
commit
9bd7379cc6
|
@ -4,18 +4,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace MathUtil {
|
namespace MathUtil {
|
||||||
|
|
||||||
static constexpr float PI = 3.14159265f;
|
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 <class T>
|
template <class T>
|
||||||
struct Rectangle {
|
struct Rectangle {
|
||||||
|
@ -24,16 +18,16 @@ struct Rectangle {
|
||||||
T right{};
|
T right{};
|
||||||
T bottom{};
|
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) {}
|
: left(left), top(top), right(right), bottom(bottom) {}
|
||||||
|
|
||||||
T GetWidth() const {
|
T GetWidth() const {
|
||||||
return std::abs(static_cast<typename std::make_signed<T>::type>(right - left));
|
return std::abs(static_cast<std::make_signed_t<T>>(right - left));
|
||||||
}
|
}
|
||||||
T GetHeight() const {
|
T GetHeight() const {
|
||||||
return std::abs(static_cast<typename std::make_signed<T>::type>(bottom - top));
|
return std::abs(static_cast<std::make_signed_t<T>>(bottom - top));
|
||||||
}
|
}
|
||||||
Rectangle<T> TranslateX(const T x) const {
|
Rectangle<T> TranslateX(const T x) const {
|
||||||
return Rectangle{left + x, top, right + x, bottom};
|
return Rectangle{left + x, top, right + x, bottom};
|
||||||
|
|
Loading…
Reference in a new issue