summaryrefslogtreecommitdiffstats
path: root/core/vectors.hh
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-03-19 18:07:51 +0500
committeruntodesu <kirill@untode.su>2025-03-19 18:07:51 +0500
commitfddd7f761176bb45cfdd41eeccaeadac22d33ddf (patch)
tree96fdc781f2cd96e769c148e850e411a90ff1ad5b /core/vectors.hh
parent1c138d80ac08dfc48f0916c568f780e15db73834 (diff)
downloadvoxelius-fddd7f761176bb45cfdd41eeccaeadac22d33ddf.tar.bz2
voxelius-fddd7f761176bb45cfdd41eeccaeadac22d33ddf.zip
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)
Diffstat (limited to 'core/vectors.hh')
-rw-r--r--core/vectors.hh49
1 files changed, 49 insertions, 0 deletions
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<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)
+{
+ 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)
+{
+ 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)
+{
+ static_assert(std::is_arithmetic_v<value_type>);
+ return cxvectors::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)
+{
+ static_assert(std::is_arithmetic_v<value_type>);
+ return cxvectors::length2(vector_a - vector_b);
+}
+
+#endif /* CORE_VECTORS_HH */