From 28ef19458689d7faac9d1027dc8e3ea8a060ed04 Mon Sep 17 00:00:00 2001 From: Orange Date: Tue, 11 Nov 2025 23:36:19 +0300 Subject: [PATCH] Adds nodiscard attribute to simplex functions Applies the `[[nodiscard]]` attribute to several functions within the `omath::collision` namespace to improve code safety and signal potential misuse when return values are ignored. This encourages developers to handle the results of these functions appropriately. --- include/omath/collision/simplex.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/omath/collision/simplex.hpp b/include/omath/collision/simplex.hpp index c4de3f4..7820f53 100644 --- a/include/omath/collision/simplex.hpp +++ b/include/omath/collision/simplex.hpp @@ -47,10 +47,13 @@ namespace omath::collision ++m_size; } + [[nodiscard]] constexpr const VectorType& operator[](std::size_t i) const noexcept { return m_points[i]; } + + [[nodiscard]] constexpr VectorType& operator[](std::size_t i) noexcept { return m_points[i]; @@ -126,12 +129,14 @@ namespace omath::collision } template + [[nodiscard]] static constexpr bool near_zero(const V& v, const float eps = 1e-7f) { return v.dot(v) <= eps * eps; } template + [[nodiscard]] static constexpr V any_perp(const V& v) { for (const auto& dir : {V{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}) @@ -140,6 +145,7 @@ namespace omath::collision std::unreachable(); } + [[nodiscard]] constexpr bool handle_line(VectorType& direction) { const auto& a = m_points[0];