Updates simplex iterator and size access

Changes the index type for accessing simplex points to `std::size_t` for consistency and safety.

Adds `[[nodiscard]]` attribute to `size()` and iterator functions to signal potential misuse and enable static analysis.

These updates are part of the GJK algorithm implementation.
This commit is contained in:
2025-11-09 14:05:46 +03:00
parent 338246a618
commit 31cc1116ae

View File

@@ -34,20 +34,20 @@ namespace omath::collision
m_size = std::min(m_size + 1, 4); m_size = std::min(m_size + 1, 4);
} }
Vector3<float>& operator[](const int i) Vector3<float>& operator[](const std::size_t i)
{ {
return m_points[i]; return m_points[i];
} }
size_t size() const [[nodiscard]] std::size_t size() const
{ {
return m_size; return m_size;
} }
auto begin() const [[nodiscard]] auto begin() const
{ {
return m_points.begin(); return m_points.begin();
} }
auto end() const [[nodiscard]] auto end() const
{ {
return m_points.end() - (4 - m_size); return m_points.end() - (4 - m_size);
} }