summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-09-14 19:16:44 +0500
committeruntodesu <kirill@untode.su>2025-09-14 19:16:44 +0500
commit8bcbd2729388edc63c82d77d314b583af1447c49 (patch)
tree460c2b509372077f6adf95d72c4245988a580aed /core
parent7fc7fdb001bea8674fe0dbc1b962f3ec2702debb (diff)
downloadvoxelius-8bcbd2729388edc63c82d77d314b583af1447c49.tar.bz2
voxelius-8bcbd2729388edc63c82d77d314b583af1447c49.zip
Cleanup math with qfengine ports again
Diffstat (limited to 'core')
-rw-r--r--core/config/number.hh20
-rw-r--r--core/io/CMakeLists.txt4
-rw-r--r--core/io/physfs.cc (renamed from core/utils/physfs.cc)152
-rw-r--r--core/io/physfs.hh (renamed from core/utils/physfs.hh)28
-rw-r--r--core/math/CMakeLists.txt1
-rw-r--r--core/math/aabb.hh18
-rw-r--r--core/math/concepts.hh12
-rw-r--r--core/math/constexpr.hh210
-rw-r--r--core/math/crc64.cc5
-rw-r--r--core/math/crc64.hh1
-rw-r--r--core/math/randomizer.hh56
-rw-r--r--core/math/vectors.hh16
-rw-r--r--core/resource/image.cc4
-rw-r--r--core/resource/resource.cc5
-rw-r--r--core/threading.cc4
-rw-r--r--core/utils/CMakeLists.txt2
16 files changed, 179 insertions, 359 deletions
diff --git a/core/config/number.hh b/core/config/number.hh
index 5533459..59d3f47 100644
--- a/core/config/number.hh
+++ b/core/config/number.hh
@@ -6,7 +6,7 @@
namespace config
{
-template<math::Arithmetic T>
+template<math::arithmetic T>
class Number : public IValue {
public:
explicit Number(T default_value = T(0));
@@ -59,7 +59,7 @@ public:
};
} // namespace config
-template<math::Arithmetic T>
+template<math::arithmetic T>
inline config::Number<T>::Number(T default_value)
{
m_value = default_value;
@@ -68,7 +68,7 @@ inline config::Number<T>::Number(T default_value)
m_string = std::to_string(default_value);
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
inline config::Number<T>::Number(T default_value, T min_value, T max_value)
{
m_value = default_value;
@@ -77,7 +77,7 @@ inline config::Number<T>::Number(T default_value, T min_value, T max_value)
m_string = std::to_string(default_value);
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
inline void config::Number<T>::set(std::string_view value)
{
T parsed_value;
@@ -89,38 +89,38 @@ inline void config::Number<T>::set(std::string_view value)
}
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
inline std::string_view config::Number<T>::get(void) const
{
return m_string;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
inline T config::Number<T>::get_value(void) const
{
return m_value;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
inline void config::Number<T>::set_value(T value)
{
m_value = std::clamp(value, m_min_value, m_max_value);
m_string = std::to_string(m_value);
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
inline T config::Number<T>::get_min_value(void) const
{
return m_min_value;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
inline T config::Number<T>::get_max_value(void) const
{
return m_max_value;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
inline void config::Number<T>::set_limits(T min_value, T max_value)
{
m_min_value = min_value;
diff --git a/core/io/CMakeLists.txt b/core/io/CMakeLists.txt
index 0639d2c..3fe9fb1 100644
--- a/core/io/CMakeLists.txt
+++ b/core/io/CMakeLists.txt
@@ -4,4 +4,6 @@ target_sources(core PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/cmdline.cc"
"${CMAKE_CURRENT_LIST_DIR}/cmdline.hh"
"${CMAKE_CURRENT_LIST_DIR}/config_map.cc"
- "${CMAKE_CURRENT_LIST_DIR}/config_map.hh")
+ "${CMAKE_CURRENT_LIST_DIR}/config_map.hh"
+ "${CMAKE_CURRENT_LIST_DIR}/physfs.cc"
+ "${CMAKE_CURRENT_LIST_DIR}/physfs.hh")
diff --git a/core/utils/physfs.cc b/core/io/physfs.cc
index b801963..1c36f88 100644
--- a/core/utils/physfs.cc
+++ b/core/io/physfs.cc
@@ -1,76 +1,76 @@
-#include "core/pch.hh"
-
-#include "core/utils/physfs.hh"
-
-bool utils::read_file(std::string_view path, std::vector<std::byte>& buffer)
-{
- auto file = PHYSFS_openRead(std::string(path).c_str());
-
- if(file == nullptr) {
- spdlog::error("physfs: {}: {}", path, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
- return false;
- }
-
- PHYSFS_sint64 file_size = PHYSFS_fileLength(file);
- buffer.resize(static_cast<std::size_t>(file_size));
-
- PHYSFS_readBytes(file, buffer.data(), file_size);
- PHYSFS_close(file);
-
- return true;
-}
-
-bool utils::read_file(std::string_view path, std::string& buffer)
-{
- auto file = PHYSFS_openRead(std::string(path).c_str());
-
- if(file == nullptr) {
- spdlog::error("physfs: {}: {}", path, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
- return false;
- }
-
- PHYSFS_sint64 file_size = PHYSFS_fileLength(file);
- buffer.resize(static_cast<std::size_t>(file_size));
-
- PHYSFS_readBytes(file, buffer.data(), file_size);
- PHYSFS_close(file);
-
- return true;
-}
-
-bool utils::write_file(std::string_view path, const std::vector<std::byte>& buffer)
-{
- auto file = PHYSFS_openWrite(std::string(path).c_str());
-
- if(file == nullptr) {
- spdlog::error("physfs: {}: {}", path, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
- return false;
- }
-
- PHYSFS_writeBytes(file, buffer.data(), static_cast<PHYSFS_uint64>(buffer.size()));
- PHYSFS_close(file);
-
- return true;
-}
-
-bool utils::write_file(std::string_view path, const std::string& buffer)
-{
- auto file = PHYSFS_openWrite(std::string(path).c_str());
-
- if(file == nullptr) {
- spdlog::error("physfs: {}: {}", path, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
- return false;
- }
-
- PHYSFS_writeBytes(file, buffer.data(), static_cast<PHYSFS_uint64>(buffer.size()));
- PHYSFS_close(file);
-
- return true;
-}
-
-std::string_view utils::physfs_error(void)
-{
- auto error_code = PHYSFS_getLastErrorCode();
- auto error_string = PHYSFS_getErrorByCode(error_code);
- return std::string_view(error_string, std::strlen(error_string));
-}
+#include "core/pch.hh"
+
+#include "core/io/physfs.hh"
+
+bool io::read_file(std::string_view path, std::vector<std::byte>& buffer)
+{
+ auto file = PHYSFS_openRead(std::string(path).c_str());
+
+ if(file == nullptr) {
+ spdlog::error("physfs: {}: {}", path, physfs_error());
+ return false;
+ }
+
+ PHYSFS_sint64 file_size = PHYSFS_fileLength(file);
+ buffer.resize(static_cast<std::size_t>(file_size));
+
+ PHYSFS_readBytes(file, buffer.data(), file_size);
+ PHYSFS_close(file);
+
+ return true;
+}
+
+bool io::read_file(std::string_view path, std::string& buffer)
+{
+ auto file = PHYSFS_openRead(std::string(path).c_str());
+
+ if(file == nullptr) {
+ spdlog::error("physfs: {}: {}", path, physfs_error());
+ return false;
+ }
+
+ PHYSFS_sint64 file_size = PHYSFS_fileLength(file);
+ buffer.resize(static_cast<std::size_t>(file_size));
+
+ PHYSFS_readBytes(file, buffer.data(), file_size);
+ PHYSFS_close(file);
+
+ return true;
+}
+
+bool io::write_file(std::string_view path, const std::vector<std::byte>& buffer)
+{
+ auto file = PHYSFS_openWrite(std::string(path).c_str());
+
+ if(file == nullptr) {
+ spdlog::error("physfs: {}: {}", path, physfs_error());
+ return false;
+ }
+
+ PHYSFS_writeBytes(file, buffer.data(), static_cast<PHYSFS_uint64>(buffer.size()));
+ PHYSFS_close(file);
+
+ return true;
+}
+
+bool io::write_file(std::string_view path, const std::string& buffer)
+{
+ auto file = PHYSFS_openWrite(std::string(path).c_str());
+
+ if(file == nullptr) {
+ spdlog::error("physfs: {}: {}", path, physfs_error());
+ return false;
+ }
+
+ PHYSFS_writeBytes(file, buffer.data(), static_cast<PHYSFS_uint64>(buffer.size()));
+ PHYSFS_close(file);
+
+ return true;
+}
+
+std::string_view io::physfs_error(void)
+{
+ auto error_code = PHYSFS_getLastErrorCode();
+ auto error_string = PHYSFS_getErrorByCode(error_code);
+ return std::string_view(error_string, std::strlen(error_string));
+}
diff --git a/core/utils/physfs.hh b/core/io/physfs.hh
index 220954e..01282ad 100644
--- a/core/utils/physfs.hh
+++ b/core/io/physfs.hh
@@ -1,14 +1,14 @@
-#pragma once
-
-namespace utils
-{
-bool read_file(std::string_view path, std::vector<std::byte>& buffer);
-bool read_file(std::string_view path, std::string& buffer);
-bool write_file(std::string_view path, const std::vector<std::byte>& buffer);
-bool write_file(std::string_view path, const std::string& buffer);
-} // namespace utils
-
-namespace utils
-{
-std::string_view physfs_error(void);
-} // namespace utils
+#pragma once
+
+namespace io
+{
+bool read_file(std::string_view path, std::vector<std::byte>& buffer);
+bool read_file(std::string_view path, std::string& buffer);
+bool write_file(std::string_view path, const std::vector<std::byte>& buffer);
+bool write_file(std::string_view path, const std::string& buffer);
+} // namespace io
+
+namespace io
+{
+std::string_view physfs_error(void);
+} // namespace io
diff --git a/core/math/CMakeLists.txt b/core/math/CMakeLists.txt
index b994969..bcb45aa 100644
--- a/core/math/CMakeLists.txt
+++ b/core/math/CMakeLists.txt
@@ -5,5 +5,4 @@ target_sources(core PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/constexpr.hh"
"${CMAKE_CURRENT_LIST_DIR}/crc64.cc"
"${CMAKE_CURRENT_LIST_DIR}/crc64.hh"
- "${CMAKE_CURRENT_LIST_DIR}/randomizer.hh"
"${CMAKE_CURRENT_LIST_DIR}/vectors.hh")
diff --git a/core/math/aabb.hh b/core/math/aabb.hh
index ed3cf39..9a64aad 100644
--- a/core/math/aabb.hh
+++ b/core/math/aabb.hh
@@ -4,7 +4,7 @@
namespace math
{
-template<Arithmetic T>
+template<arithmetic T>
class AABB {
public:
using value_type = T;
@@ -35,27 +35,27 @@ namespace math
using AABBf = AABB<float>;
} // namespace math
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr math::AABB<T>::AABB(const vector_type& start, const vector_type& end)
{
set_bounds(start, end);
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr void math::AABB<T>::set_bounds(const vector_type& start, const vector_type& end)
{
min = start;
max = end;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr void math::AABB<T>::set_offset(const vector_type& base, const vector_type& size)
{
min = base;
max = base + size;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr bool math::AABB<T>::contains(const vector_type& point) const
{
auto result = true;
@@ -65,7 +65,7 @@ constexpr bool math::AABB<T>::contains(const vector_type& point) const
return result;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr bool math::AABB<T>::intersect(const AABB<value_type>& other_box) const
{
auto result = true;
@@ -75,7 +75,7 @@ constexpr bool math::AABB<T>::intersect(const AABB<value_type>& other_box) const
return result;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr math::AABB<T> math::AABB<T>::combine(const AABB<value_type>& other_box) const
{
AABB<value_type> result;
@@ -88,7 +88,7 @@ constexpr math::AABB<T> math::AABB<T>::combine(const AABB<value_type>& other_box
return result;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr math::AABB<T> math::AABB<T>::multiply(const AABB<value_type>& other_box) const
{
AABB<value_type> result;
@@ -101,7 +101,7 @@ constexpr math::AABB<T> math::AABB<T>::multiply(const AABB<value_type>& other_bo
return result;
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr math::AABB<T> math::AABB<T>::push(const vector_type& vector) const
{
AABB<value_type> result;
diff --git a/core/math/concepts.hh b/core/math/concepts.hh
index 10cb74a..19d372c 100644
--- a/core/math/concepts.hh
+++ b/core/math/concepts.hh
@@ -2,10 +2,10 @@
namespace math
{
-template<typename T>
-concept Arithmetic = std::is_arithmetic_v<T>;
-template<typename T>
-concept Integer = std::is_integral_v<T>;
-template<typename T>
-concept FloatingPoint = std::is_floating_point_v<T>;
+template<typename type>
+concept arithmetic = std::is_arithmetic_v<type>;
+template<typename type>
+concept signed_arithmetic = std::is_arithmetic_v<type> && std::is_signed_v<type>;
+template<typename type>
+concept unsigned_arithmetic = std::is_arithmetic_v<type> && std::is_unsigned_v<type>;
} // namespace math
diff --git a/core/math/constexpr.hh b/core/math/constexpr.hh
index e6c4b6d..6641f23 100644
--- a/core/math/constexpr.hh
+++ b/core/math/constexpr.hh
@@ -4,195 +4,69 @@
namespace math
{
-template<math::Arithmetic T>
-constexpr static inline const T abs(const T x);
-template<typename T, std::size_t L>
-constexpr static inline const std::size_t array_size(const T (&)[L]);
-template<math::Integer T, math::FloatingPoint F>
-constexpr static inline const T ceil(const F x);
-template<math::Arithmetic T>
-constexpr static inline const T degrees(const T x);
-template<math::Integer T, math::FloatingPoint F>
-constexpr static inline const T floor(const F x);
-template<math::Arithmetic T>
-constexpr static inline const T clamp(const T x, const T min, const T max);
-template<math::Arithmetic T, math::FloatingPoint F>
-constexpr static inline const T lerp(const T x, const T y, const F a);
-template<math::Arithmetic T>
-constexpr static inline const T log2(const T x);
-template<math::Arithmetic T>
-constexpr static inline const T max(const T x, const T y);
-template<math::Arithmetic T>
-constexpr static inline const T min(const T x, const T y);
-template<math::Integer T>
-requires std::is_signed_v<T>
-constexpr static inline const T mod_signed(const T x, const T m);
-template<math::Arithmetic T>
-constexpr static inline const T pow2(const T x);
-template<math::Arithmetic T>
-constexpr static inline const T radians(const T x);
-template<math::Arithmetic T>
-constexpr static inline const bool range(const T x, const T min, const T max);
-template<math::Arithmetic T, math::FloatingPoint F>
-constexpr static inline const T sign(const F x);
-template<math::Arithmetic T, math::FloatingPoint F>
-constexpr static inline const T smoothstep(const T x, const T y, const F a);
+template<typename type, std::size_t size>
+constexpr std::size_t array_size(const type (&)[size]);
} // namespace math
-template<math::Arithmetic T>
-constexpr static inline const T math::abs(const T x)
-{
- if(x < static_cast<T>(0)) {
- return -x;
- }
- else {
- return x;
- }
-}
-
-template<typename T, std::size_t L>
-constexpr static inline const std::size_t math::array_size(const T (&)[L])
-{
- return L;
-}
-
-template<math::Integer T, math::FloatingPoint F>
-constexpr static inline const T math::ceil(const F x)
-{
- const T ival = static_cast<T>(x);
-
- if(ival < x) {
- return ival + static_cast<T>(1);
- }
- else {
- return ival;
- }
-}
-
-template<math::Arithmetic T>
-constexpr static inline const T math::degrees(const T x)
-{
- return x * static_cast<T>(180.0) / static_cast<T>(M_PI);
-}
-
-template<math::Integer T, math::FloatingPoint F>
-constexpr static inline const T math::floor(const F x)
-{
- const T ival = static_cast<T>(x);
-
- if(ival > x) {
- return ival - static_cast<T>(1);
- }
- else {
- return ival;
- }
-}
-
-template<math::Arithmetic T>
-constexpr static inline const T math::clamp(const T x, const T min, const T max)
-{
- if(x < min) {
- return min;
- }
- else if(x > max) {
- return max;
- }
- else {
- return x;
- }
-}
-
-template<math::Arithmetic T, math::FloatingPoint F>
-constexpr static inline const T math::lerp(const T x, const T y, const F a)
+namespace math
{
- return static_cast<T>(static_cast<F>(x) * (static_cast<F>(1.0f) - a) + static_cast<F>(y) * a);
-}
+template<std::integral scalar>
+constexpr scalar log2(const scalar x);
+template<std::signed_integral scalar>
+constexpr scalar mod_signed(const scalar x, const scalar m);
+template<math::signed_arithmetic result_scalar, math::arithmetic scalar>
+constexpr result_scalar sign(const scalar x);
+} // namespace math
-template<math::Arithmetic T>
-constexpr static inline const T math::log2(const T x)
+namespace math
{
- if(x < 2) {
- return 0;
- }
- else {
- return math::log2<T>((x + 1) >> 1) + 1;
- }
-}
+template<math::arithmetic scalar>
+constexpr scalar degrees(const scalar x);
+template<math::arithmetic scalar>
+constexpr scalar radians(const scalar x);
+} // namespace math
-template<math::Arithmetic T>
-constexpr static inline const T math::max(const T x, const T y)
+template<typename type, std::size_t size>
+constexpr std::size_t math::array_size(const type (&)[size])
{
- if(x < y) {
- return y;
- }
- else {
- return x;
- }
+ return size;
}
-template<math::Arithmetic T>
-constexpr static inline const T math::min(const T x, const T y)
+template<std::integral scalar>
+constexpr scalar math::log2(const scalar x)
{
- if(x > y) {
- return y;
- }
- else {
- return x;
- }
+ if(x < static_cast<scalar>(2))
+ return static_cast<scalar>(0);
+ return math::log2<scalar>((x + static_cast<scalar>(1)) >> 1) + static_cast<scalar>(1);
}
-template<math::Integer T>
-requires std::is_signed_v<T>
-constexpr static inline const T math::mod_signed(const T x, const T m)
+template<std::signed_integral scalar>
+constexpr scalar math::mod_signed(const scalar x, const scalar m)
{
- auto result = static_cast<T>(x % m);
-
- if(result < T(0)) {
+ auto result = static_cast<scalar>(x % m);
+ if(result < static_cast<scalar>(0))
return result + m;
- }
- else {
- return result;
- }
-}
-
-template<math::Arithmetic T>
-constexpr static inline const T math::pow2(const T x)
-{
- T value = static_cast<T>(1);
- while(value < x)
- value *= static_cast<T>(2);
- return value;
-}
-
-template<math::Arithmetic T>
-constexpr static inline const T math::radians(const T x)
-{
- return x * static_cast<T>(M_PI) / static_cast<T>(180.0);
+ return result;
}
-template<math::Arithmetic T>
-constexpr static inline const bool math::range(const T x, const T min, const T max)
+template<math::signed_arithmetic result_scalar, math::arithmetic scalar>
+constexpr result_scalar math::sign(const scalar x)
{
- return ((x >= min) && (x <= max));
+ if(x < static_cast<scalar>(0))
+ return static_cast<result_scalar>(-1);
+ if(x > static_cast<scalar>(0))
+ return static_cast<result_scalar>(+1);
+ return static_cast<result_scalar>(0);
}
-template<math::Arithmetic T, math::FloatingPoint F>
-constexpr static inline const T math::sign(const F x)
+template<math::arithmetic scalar>
+constexpr scalar math::degrees(const scalar x)
{
- if(x < F(0)) {
- return T(-1);
- }
- else if(x > F(0)) {
- return T(+1);
- }
- else {
- return T(0);
- }
+ return static_cast<scalar>(static_cast<double>(x) * 180.0 / M_PI);
}
-template<math::Arithmetic T, math::FloatingPoint F>
-constexpr static inline const T math::smoothstep(const T x, const T y, const F a)
+template<math::arithmetic scalar>
+constexpr scalar math::radians(const scalar x)
{
- const F t = math::clamp<F>((a - x) / (y - x), F(0), F(1));
- return static_cast<T>(t * t * (F(3) - F(2) * t));
+ return static_cast<scalar>(static_cast<double>(x) * M_PI / 180.0);
}
diff --git a/core/math/crc64.cc b/core/math/crc64.cc
index 0b6a830..ea7841d 100644
--- a/core/math/crc64.cc
+++ b/core/math/crc64.cc
@@ -69,3 +69,8 @@ std::uint64_t math::crc64(const std::string& buffer, std::uint64_t combine)
{
return math::crc64(buffer.data(), buffer.size(), combine);
}
+
+std::uint64_t math::crc64(std::string_view buffer, std::uint64_t combine)
+{
+ return math::crc64(buffer.data(), buffer.size(), combine);
+}
diff --git a/core/math/crc64.hh b/core/math/crc64.hh
index f68c951..5a6fea4 100644
--- a/core/math/crc64.hh
+++ b/core/math/crc64.hh
@@ -5,4 +5,5 @@ namespace math
std::uint64_t crc64(const void* buffer, std::size_t size, std::uint64_t combine = UINT64_C(0));
std::uint64_t crc64(const std::vector<std::byte>& buffer, std::uint64_t combine = UINT64_C(0));
std::uint64_t crc64(const std::string& buffer, std::uint64_t combine = UINT64_C(0));
+std::uint64_t crc64(std::string_view buffer, std::uint64_t combine = UINT64_C(0));
} // namespace math
diff --git a/core/math/randomizer.hh b/core/math/randomizer.hh
deleted file mode 100644
index db21c95..0000000
--- a/core/math/randomizer.hh
+++ /dev/null
@@ -1,56 +0,0 @@
-#pragma once
-
-namespace math
-{
-template<typename T>
-class Randomizer final {
-public:
- explicit Randomizer(void);
- explicit Randomizer(std::uint64_t seed);
- virtual ~Randomizer(void) = default;
- void add(const T& value);
- const T& get(void);
- void clear(void);
-
-private:
- std::vector<T> m_vector;
- std::mt19937_64 m_twister;
- std::uniform_int_distribution<std::size_t> m_dist;
-};
-} // namespace math
-
-template<typename T>
-inline math::Randomizer<T>::Randomizer(void)
-{
- m_vector.clear();
- m_twister.seed(std::random_device()());
- m_dist = std::uniform_int_distribution<std::size_t>(0, 0);
-}
-
-template<typename T>
-inline math::Randomizer<T>::Randomizer(std::uint64_t seed)
-{
- m_vector.clear();
- m_twister.seed(seed);
- m_dist = std::uniform_int_distribution<std::size_t>(0, 0);
-}
-
-template<typename T>
-inline void math::Randomizer<T>::add(const T& value)
-{
- m_vector.push_back(value);
- m_dist = std::uniform_int_distribution<std::size_t>(0, m_vector.size() - 1);
-}
-
-template<typename T>
-inline const T& math::Randomizer<T>::get(void)
-{
- return m_vector.at(m_dist(m_twister));
-}
-
-template<typename T>
-inline void math::Randomizer<T>::clear(void)
-{
- m_vector.clear();
- m_dist = std::uniform_int_distribution<std::size_t>(0, 0);
-}
diff --git a/core/math/vectors.hh b/core/math/vectors.hh
index 9b9e762..ff2b8c9 100644
--- a/core/math/vectors.hh
+++ b/core/math/vectors.hh
@@ -8,35 +8,35 @@
namespace math
{
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr static inline const T length2(const glm::vec<2, T>& vector);
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr static inline const T length2(const glm::vec<3, T>& vector);
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr static inline const T distance2(const glm::vec<2, T>& vector_a, const glm::vec<2, T>& vector_b);
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr static inline const T distance2(const glm::vec<3, T>& vector_a, const glm::vec<3, T>& vector_b);
} // namespace math
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr static inline const T math::length2(const glm::vec<2, T>& vector)
{
return (vector.x * vector.x) + (vector.y * vector.y);
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr static inline const T math::length2(const glm::vec<3, T>& vector)
{
return (vector.x * vector.x) + (vector.y * vector.y) + (vector.z * vector.z);
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr static inline const T math::distance2(const glm::vec<2, T>& vector_a, const glm::vec<2, T>& vector_b)
{
return math::length2(vector_a - vector_b);
}
-template<math::Arithmetic T>
+template<math::arithmetic T>
constexpr static inline const T math::distance2(const glm::vec<3, T>& vector_a, const glm::vec<3, T>& vector_b)
{
return math::length2(vector_a - vector_b);
diff --git a/core/resource/image.cc b/core/resource/image.cc
index 45fe96e..8c83c55 100644
--- a/core/resource/image.cc
+++ b/core/resource/image.cc
@@ -4,7 +4,7 @@
#include "core/resource/resource.hh"
-#include "core/utils/physfs.hh"
+#include "core/io/physfs.hh"
static int stbi_physfs_read(void* context, char* data, int size)
{
@@ -36,7 +36,7 @@ static const void* image_load_func(const char* name, std::uint32_t flags)
auto file = PHYSFS_openRead(name);
if(file == nullptr) {
- spdlog::error("image: {}: {}", name, utils::physfs_error());
+ spdlog::error("image: {}: {}", name, io::physfs_error());
return nullptr;
}
diff --git a/core/resource/resource.cc b/core/resource/resource.cc
index 21d1e4e..7ca2ef9 100644
--- a/core/resource/resource.cc
+++ b/core/resource/resource.cc
@@ -10,10 +10,7 @@ struct ResourceLoader final {
std::string class_name;
};
-namespace
-{
-emhash8::HashMap<std::type_index, std::unique_ptr<ResourceLoader>> loaders;
-} // namespace
+static emhash8::HashMap<std::type_index, std::unique_ptr<ResourceLoader>> loaders;
void resource::detail::register_loader(const std::type_info& type, ResourceLoadFunc load_func, ResourceFreeFunc free_func)
{
diff --git a/core/threading.cc b/core/threading.cc
index dcbdb9a..8514481 100644
--- a/core/threading.cc
+++ b/core/threading.cc
@@ -49,7 +49,7 @@ void threading::init(void)
auto result = std::from_chars(argument.data(), argument.data() + argument.size(), thread_pool_size);
if(result.ec == std::errc()) {
- thread_pool_size = math::clamp<unsigned int>(thread_pool_size, 1U, num_concurrent_threads);
+ thread_pool_size = glm::clamp<unsigned int>(thread_pool_size, 1U, num_concurrent_threads);
}
else {
thread_pool_size = 4U;
@@ -59,7 +59,7 @@ void threading::init(void)
auto result = std::from_chars(argument.data(), argument.data() + argument.size(), thread_pool_size);
if(result.ec == std::errc()) {
- thread_pool_size = math::max<unsigned int>(thread_pool_size, 1U);
+ thread_pool_size = glm::max<unsigned int>(thread_pool_size, 1U);
}
else {
thread_pool_size = 4U;
diff --git a/core/utils/CMakeLists.txt b/core/utils/CMakeLists.txt
index 5d59e8d..4f96261 100644
--- a/core/utils/CMakeLists.txt
+++ b/core/utils/CMakeLists.txt
@@ -1,7 +1,5 @@
target_sources(core PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/epoch.cc"
"${CMAKE_CURRENT_LIST_DIR}/epoch.hh"
- "${CMAKE_CURRENT_LIST_DIR}/physfs.cc"
- "${CMAKE_CURRENT_LIST_DIR}/physfs.hh"
"${CMAKE_CURRENT_LIST_DIR}/string.cc"
"${CMAKE_CURRENT_LIST_DIR}/string.hh")