From 0b8d889c861113d194c2c70f48de1ac7cb7160b5 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Sat, 13 Jul 2024 14:22:41 +0200 Subject: [PATCH] Extend AABB class --- openVulkanoCpp/Math/AABB.hpp | 16 ++++++++++++++++ .../Scene/Shader/VertexInputDescription.hpp | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/openVulkanoCpp/Math/AABB.hpp b/openVulkanoCpp/Math/AABB.hpp index b4da7f2..45f065c 100644 --- a/openVulkanoCpp/Math/AABB.hpp +++ b/openVulkanoCpp/Math/AABB.hpp @@ -35,6 +35,12 @@ namespace OpenVulkano::Math this->min = min; this->max = max; } + + void Init(const Math::Vector3f& point, float radius) + { + min = point - radius; + max = point + radius; + } /** * \brief Initiates the AABB from some other AABB @@ -83,6 +89,16 @@ namespace OpenVulkano::Math return !(other.min.x > max.x || other.max.x < min.x || other.min.y > max.y || other.max.y < min.y || other.min.z > max.z || other.max.z < min.z); } + + [[nodiscard]] bool InBounds(const Math::Vector3f& position) const + { + return min >= position && position <= max; + } + + [[nodiscard]] bool Inside(const Math::Vector3f& position) const + { + return min > position && position < max; + } /** * \brief Resets the AABB to min=Inf, max=-Inf, same as Init() diff --git a/openVulkanoCpp/Scene/Shader/VertexInputDescription.hpp b/openVulkanoCpp/Scene/Shader/VertexInputDescription.hpp index c034ec6..03cb00f 100644 --- a/openVulkanoCpp/Scene/Shader/VertexInputDescription.hpp +++ b/openVulkanoCpp/Scene/Shader/VertexInputDescription.hpp @@ -24,7 +24,7 @@ namespace OpenVulkano {} VertexInputParameter(size_t location, uint32_t binding, DataFormat format, uint32_t offset) - : location(location), binding(binding), format(format), offset(offset) + : location(static_cast(location)), binding(binding), format(format), offset(offset) {} };