From fddd7f761176bb45cfdd41eeccaeadac22d33ddf Mon Sep 17 00:00:00 2001 From: untodesu Date: Wed, 19 Mar 2025 18:07:51 +0500 Subject: Fix things and improve worldgen - Client-side now actually deletes invisible chunks - Improved world generation to use a second noise generator alongside changing how caves are generated (ie what noise they use) --- core/vectors.hh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 core/vectors.hh (limited to 'core/vectors.hh') diff --git a/core/vectors.hh b/core/vectors.hh new file mode 100644 index 0000000..e6e185a --- /dev/null +++ b/core/vectors.hh @@ -0,0 +1,49 @@ +#ifndef CORE_VECTORS_HH +#define CORE_VECTORS_HH 1 +#pragma once + +// cxvectors.hh - because NO ONE would POSSIBLY +// need integer-based distance calculations in a +// game about voxels. That would be INSANE! :D + +namespace cxvectors +{ +template +constexpr static inline const value_type length2(const glm::vec<2, value_type> &vector); +template +constexpr static inline const value_type length2(const glm::vec<3, value_type> &vector); +template +constexpr static inline const value_type distance2(const glm::vec<2, value_type> &vector_a, const glm::vec<2, value_type> &vector_b); +template +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 +constexpr static inline const value_type cxvectors::length2(const glm::vec<2, value_type> &vector) +{ + static_assert(std::is_arithmetic_v); + return (vector.x * vector.x) + (vector.y * vector.y); +} + +template +constexpr static inline const value_type cxvectors::length2(const glm::vec<3, value_type> &vector) +{ + static_assert(std::is_arithmetic_v); + return (vector.x * vector.x) + (vector.y * vector.y) + (vector.z * vector.z); +} + +template +constexpr static inline const value_type cxvectors::distance2(const glm::vec<2, value_type> &vector_a, const glm::vec<2, value_type> &vector_b) +{ + static_assert(std::is_arithmetic_v); + return cxvectors::length2(vector_a - vector_b); +} + +template +constexpr static inline const value_type cxvectors::distance2(const glm::vec<3, value_type> &vector_a, const glm::vec<3, value_type> &vector_b) +{ + static_assert(std::is_arithmetic_v); + return cxvectors::length2(vector_a - vector_b); +} + +#endif /* CORE_VECTORS_HH */ -- cgit