diff options
| author | untodesu <kirill@untode.su> | 2025-06-28 01:59:49 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-06-28 01:59:49 +0500 |
| commit | 61e5bcef2629e2d68b805a956a96fff264d4f74d (patch) | |
| tree | bca3a94bac79d34e3c0db57c77604f5a823ecbda /core/vectors.hh | |
| parent | 88c01588aa0830e219eaa62588839e4d1e2883ce (diff) | |
| download | voxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.tar.bz2 voxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.zip | |
Restructure dependencies and update to C++20
- Nuked static_assert from almost everywhere in the project
- Nuked binary dependency support. Might add one later though
- Separated dependency headers into a separate include subdirectory
- Grafted a thirdpartylegalnotices.txt generator from RITEG
- Pushed development snapshot version to 2126 (26th week of 2025)
Diffstat (limited to 'core/vectors.hh')
| -rw-r--r-- | core/vectors.hh | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/core/vectors.hh b/core/vectors.hh index 86263b7..a6e9c75 100644 --- a/core/vectors.hh +++ b/core/vectors.hh @@ -2,48 +2,46 @@ #define CORE_VECTORS_HH 1 #pragma once -// cxvectors.hh - because NO ONE would POSSIBLY +#include "core/concepts.hh" + +// core/vectors.hh - because NO ONE would POSSIBLY // need integer-based distance calculations in a // game about voxels. That would be INSANE! :D -namespace cxvectors +namespace vx { -template<typename value_type> -constexpr static inline const value_type length2(const glm::vec<2, value_type>& vector); -template<typename value_type> -constexpr static inline const value_type length2(const glm::vec<3, value_type>& vector); -template<typename value_type> -constexpr static inline const value_type distance2(const glm::vec<2, value_type>& vector_a, const glm::vec<2, value_type>& vector_b); -template<typename value_type> -constexpr static inline const value_type distance2(const glm::vec<3, value_type>& vector_a, const glm::vec<3, value_type>& vector_b); -} // namespace cxvectors - -template<typename value_type> -constexpr static inline const value_type cxvectors::length2(const glm::vec<2, value_type>& vector) +template<vx::Arithmetic T> +constexpr static inline const T length2(const glm::vec<2, T>& vector); +template<vx::Arithmetic T> +constexpr static inline const T length2(const glm::vec<3, T>& vector); +template<vx::Arithmetic T> +constexpr static inline const T distance2(const glm::vec<2, T>& vector_a, const glm::vec<2, T>& vector_b); +template<vx::Arithmetic T> +constexpr static inline const T distance2(const glm::vec<3, T>& vector_a, const glm::vec<3, T>& vector_b); +} // namespace vx + +template<vx::Arithmetic T> +constexpr static inline const T vx::length2(const glm::vec<2, T>& vector) { - static_assert(std::is_arithmetic_v<value_type>); return (vector.x * vector.x) + (vector.y * vector.y); } -template<typename value_type> -constexpr static inline const value_type cxvectors::length2(const glm::vec<3, value_type>& vector) +template<vx::Arithmetic T> +constexpr static inline const T vx::length2(const glm::vec<3, T>& vector) { - static_assert(std::is_arithmetic_v<value_type>); return (vector.x * vector.x) + (vector.y * vector.y) + (vector.z * vector.z); } -template<typename value_type> -constexpr static inline const value_type cxvectors::distance2(const glm::vec<2, value_type>& vector_a, const glm::vec<2, value_type>& vector_b) +template<vx::Arithmetic T> +constexpr static inline const T vx::distance2(const glm::vec<2, T>& vector_a, const glm::vec<2, T>& vector_b) { - static_assert(std::is_arithmetic_v<value_type>); - return cxvectors::length2(vector_a - vector_b); + return vx::length2(vector_a - vector_b); } -template<typename value_type> -constexpr static inline const value_type cxvectors::distance2(const glm::vec<3, value_type>& vector_a, const glm::vec<3, value_type>& vector_b) +template<vx::Arithmetic T> +constexpr static inline const T vx::distance2(const glm::vec<3, T>& vector_a, const glm::vec<3, T>& vector_b) { - static_assert(std::is_arithmetic_v<value_type>); - return cxvectors::length2(vector_a - vector_b); + return vx::length2(vector_a - vector_b); } #endif /* CORE_VECTORS_HH */ |
