summary refs log tree commit diff
path: root/src/Math/Vector.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-06-30 15:15:00 +0200
committerMel <einebeere@gmail.com>2023-06-30 15:15:00 +0200
commit424d00eaf7335e1c6427f40260d55782c3fd902c (patch)
tree62550b085078d84c8a48cbb01f4f7738bfeeb3da /src/Math/Vector.hpp
parent6d61b17c4289185d59d37caae8070a40e91fba40 (diff)
downloadmeowcraft-424d00eaf7335e1c6427f40260d55782c3fd902c.tar.zst
meowcraft-424d00eaf7335e1c6427f40260d55782c3fd902c.zip
Avoid per-frame chunk copies and don't render block faces between chunks
Diffstat (limited to 'src/Math/Vector.hpp')
-rw-r--r--src/Math/Vector.hpp29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/Math/Vector.hpp b/src/Math/Vector.hpp
index ccfa556..260891d 100644
--- a/src/Math/Vector.hpp
+++ b/src/Math/Vector.hpp
@@ -2,17 +2,14 @@
 
 #include <cstddef>
 #include <sstream>
-#include <iostream>
-#include <iterator>
 #include <cmath>
 #include <functional>
 
 template <size_t S, typename T = float>
 struct Vector {
-public:
     Vector(): elements{} {};
 
-    template<typename ...Args, typename std::enable_if<sizeof...(Args) == S, int>::type = 0>
+    template<typename ...Args, std::enable_if_t<sizeof...(Args) == S, int> = 0>
     Vector<S, T>(Args... args) : elements{ args... } {};
 
     Vector<S, T>(T values[S]) {
@@ -117,25 +114,17 @@ public:
         return map([=](auto x) { return x / scalar; });
     }
 
-    T x() const {
-        static_assert(S > 0);
-        return elements[0];
-    }
+    T& x() { static_assert(S > 0); return elements[0]; }
+    const T& x() const { static_assert(S > 0); return elements[0]; }
 
-    T y() const {
-        static_assert(S > 1);
-        return elements[1];
-    }
+    T& y() { static_assert(S > 1); return elements[1]; }
+    const T& y() const { static_assert(S > 1); return elements[1]; }
 
-    T z() const {
-        static_assert(S > 2);
-        return elements[2];
-    }
+    T& z() { static_assert(S > 2); return elements[2]; }
+    const T& z() const { static_assert(S > 2); return elements[2]; }
 
-    T w() const {
-        static_assert(S > 3);
-        return elements[3];
-    }
+    T& w() { static_assert(S > 3); return elements[3]; }
+    const T& w() const { static_assert(S > 3); return elements[3]; }
 
     std::string string() const {
         std::stringstream str{};