From 28d69ab55232a4ef1ae1763c61ade6f405e208b2 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Sun, 13 Aug 2023 18:14:22 +0200 Subject: [PATCH] Math/Box,Rect: Add GetCorners method --- include/Nazara/Math/Box.hpp | 2 ++ include/Nazara/Math/Box.inl | 15 +++++++++++++++ include/Nazara/Math/Rect.hpp | 2 ++ include/Nazara/Math/Rect.inl | 11 +++++++++++ 4 files changed, 30 insertions(+) diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index 1b7004134..1909666b6 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -7,6 +7,7 @@ #ifndef NAZARA_MATH_BOX_HPP #define NAZARA_MATH_BOX_HPP +#include #include #include #include @@ -46,6 +47,7 @@ namespace Nz constexpr Sphere GetBoundingSphere() const; constexpr Vector3 GetCenter() const; constexpr Vector3 GetCorner(BoxCorner corner) const; + constexpr EnumArray> GetCorners() const; constexpr Vector3 GetLengths() const; constexpr Vector3 GetMaximum() const; constexpr Vector3 GetMinimum() const; diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index 83c00e6dd..f556a02fa 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -309,6 +309,21 @@ namespace Nz return Vector3(); } + template + constexpr EnumArray> Box::GetCorners() const + { + return { + GetCorner(Nz::BoxCorner::FarLeftBottom), + GetCorner(Nz::BoxCorner::FarLeftTop), + GetCorner(Nz::BoxCorner::FarRightBottom), + GetCorner(Nz::BoxCorner::FarRightTop), + GetCorner(Nz::BoxCorner::NearLeftBottom), + GetCorner(Nz::BoxCorner::NearLeftTop), + GetCorner(Nz::BoxCorner::NearRightBottom), + GetCorner(Nz::BoxCorner::NearRightTop) + }; + } + /*! * \brief Gets a Vector3 for the lengths * \return The lengths of the box (width, height, depth) diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index fa372b505..d67333497 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -7,6 +7,7 @@ #ifndef NAZARA_MATH_RECT_HPP #define NAZARA_MATH_RECT_HPP +#include #include #include #include @@ -41,6 +42,7 @@ namespace Nz constexpr Vector2 GetCenter() const; constexpr Vector2 GetCorner(RectCorner corner) const; + constexpr EnumArray> GetCorners() const; constexpr Vector2 GetLengths() const; constexpr Vector2 GetMaximum() const; constexpr Vector2 GetMinimum() const; diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 8a417221e..7b4554ad1 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -250,6 +250,17 @@ namespace Nz return Vector2(); } + template + constexpr EnumArray> Rect::GetCorners() const + { + return { + GetCorner(Nz::BoxCorner::LeftBottom), + GetCorner(Nz::BoxCorner::LeftTop), + GetCorner(Nz::BoxCorner::RightBottom), + GetCorner(Nz::BoxCorner::RightTop) + }; + } + /*! * \brief Gets a Vector2 for the lengths * \return The lengths of the rectangle (width, height)