Browse Source

refactoring

Kajetan Johannes Hammerle 3 years ago
parent
commit
8737a41249

+ 11 - 22
client/Engine.cpp

@@ -8,14 +8,10 @@ float Engine::testBias = 0.0005;
 bool Engine::ortho = false;
 Vector Engine::testOrthoCenter;
 
-static u64 last = 0;
-static u64 sum = 0;
-static u64 tindex = 0;
-static std::array<u64, 128> values;
-
-Engine::Engine(Shaders& shaders, Framebuffers& fb, const Keys& keys, const MouseButtons& buttons, const WindowSize& size) :
-shaders(shaders), fb(fb), keys(keys), buttons(buttons), game(keys, buttons), frustum(60.0f, 0.1f, 80.0f),
-ssaoNoise(4, 4), size(size), running(!shaders.hasError() && !fb.hasError()) {
+Engine::Engine(Shaders& shaders, Framebuffers& fb, const Keys& keys, const MouseButtons& buttons, Camera& camera,
+        Ray& ray, const Clock& fps, const WindowSize& size) :
+shaders(shaders), fb(fb), keys(keys), buttons(buttons), game(keys, buttons, camera, ray), camera(camera),
+frustum(60.0f, 0.1f, 80.0f), ssaoNoise(4, 4), fps(fps), size(size), running(!shaders.hasError() && !fb.hasError()) {
     rectangle.add( {-1, -1, 0, 0, 0, 0, 0, 0});
     rectangle.add( {1, 1, 0, 1, 1, 0, 0, 0});
     rectangle.add( {-1, 1, 0, 0, 1, 0, 0, 0});
@@ -30,14 +26,7 @@ bool Engine::isRunning() const {
 }
 
 void Engine::renderTick(float lag) {
-    u64 current = GLFWWrapper::getTimeNanos();
-    sum -= values[tindex];
-    values[tindex] = current - last;
-    sum += values[tindex];
-    last = current;
-    tindex = (tindex + 1) & (127);
-
-    cam.update(lag);
+    camera.update(lag);
     updateWorldProjection();
     updateWorldView();
 
@@ -51,7 +40,7 @@ void Engine::renderTick(float lag) {
 }
 
 void Engine::tick() {
-    game.tick(cam);
+    game.tick();
     if(keys.test5.getDownTime() == 1) {
         ortho = !ortho;
     }
@@ -159,7 +148,7 @@ void Engine::renderTextOverlay(float lag) {
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glBlendEquation(GL_FUNC_ADD);
     char buffer[50];
-    snprintf(buffer, 50, "FPS: %f %f %f", 128000000000.0f / sum, Engine::testRadius, Engine::testBias);
+    snprintf(buffer, 50, "FPS: %f %f %f", fps.getUpdatesPerSecond(), Engine::testRadius, Engine::testBias);
     fontRenderer.drawString(20, 20, buffer);
     game.renderTextOverlay(lag, model, shaders.text, fontRenderer);
     glDisable(GL_BLEND);
@@ -290,10 +279,10 @@ void Engine::updateWorldProjection() {
 }
 
 void Engine::updateWorldView() {
-    Vector right = cam.getRight();
-    Vector up = cam.getUp();
-    Vector back = cam.getBack();
-    Vector pos = cam.getPosition();
+    Vector right = camera.getRight();
+    Vector up = camera.getUp();
+    Vector back = camera.getBack();
+    Vector pos = camera.getPosition();
 
     if(ortho) {
         right.set(0.939693f, 0.0f, -0.34202f);

+ 7 - 5
client/Engine.h

@@ -7,6 +7,7 @@
 #include "common/utils/Types.h"
 #include "client/input/Keys.h"
 #include "client/input/MouseButtons.h"
+#include "client/math/Ray.h"
 #include "client/rendering/FontRenderer.h"
 #include "client/rendering/Mesh.h"
 #include "client/rendering/Framebuffers.h"
@@ -17,10 +18,12 @@
 #include "client/math/Frustum.h"
 #include "client/Game.h"
 #include "client/rendering/NoiseTexture.h"
+#include "client/utils/Clock.h"
 
-class Engine {
+class Engine final {
 public:
-    Engine(Shaders& shaders, Framebuffers& fb, const Keys& keys, const MouseButtons& buttons, const WindowSize& size);
+    Engine(Shaders& shaders, Framebuffers& fb, const Keys& keys, const MouseButtons& buttons, Camera& camera, 
+            Ray& ray, const Clock& fps, const WindowSize& size);
     bool isRunning() const;
     void renderTick(float lag);
     void tick();
@@ -31,8 +34,6 @@ public:
     static bool ortho;
     static Vector testOrthoCenter;
 
-    bool once = true;
-
     Matrix worldProj;
     Matrix worldView;
     Matrix worldShadowProj;
@@ -54,12 +55,13 @@ private:
     const Keys& keys;
     const MouseButtons& buttons;
     Game game;
-    Camera cam;
+    Camera& camera;
     Frustum frustum;
     MatrixStack model;
     FontRenderer fontRenderer;
     NoiseTexture ssaoNoise;
     Mesh rectangle;
+    const Clock& fps;
 
     const WindowSize& size;
 

+ 11 - 11
client/Game.cpp

@@ -2,8 +2,8 @@
 
 #include "client/Game.h"
 
-Game::Game(const Keys& keys, const MouseButtons& buttons) : keys(keys), buttons(buttons), lengthAngle(20.0f), 
-        widthAngle(35.0f), texture("resources/textures.png") {
+Game::Game(const Keys& keys, const MouseButtons& buttons, const Camera& camera, Ray& ray) : keys(keys), buttons(buttons),
+camera(camera), ray(ray), lengthAngle(20.0f), widthAngle(35.0f), texture("resources/textures.png") {
     for(int x = -6; x <= 6; x++) {
         for(int y = -6; y <= 6; y++) {
             for(int z = -6; z <= 6; z++) {
@@ -82,25 +82,25 @@ void Game::addCube(float x, float y, float z, bool bottom, bool top, bool left,
     }
 }
 
-void Game::tick(Camera& cam) {
+void Game::tick() {
     const float speed = 0.25f;
     if(keys.down.isDown()) {
-        pos.addMul(cam.getFlatBack(), speed);
+        pos.addMul(camera.getFlatBack(), speed);
     }
     if(keys.up.isDown()) {
-        pos.addMul(cam.getFlatFront(), speed);
+        pos.addMul(camera.getFlatBack(), -speed);
     }
     if(keys.left.isDown()) {
-        pos.addMul(cam.getFlatLeft(), speed);
+        pos.addMul(camera.getFlatRight(), -speed);
     }
     if(keys.right.isDown()) {
-        pos.addMul(cam.getFlatRight(), speed);
+        pos.addMul(camera.getFlatRight(), speed);
     }
     if(keys.jump.isDown()) {
-        pos.addMul(cam.getFlatUp(), speed);
+        pos.addMul(camera.getFlatUp(), speed);
     }
     if(keys.sneak.isDown()) {
-        pos.addMul(cam.getFlatDown(), speed);
+        pos.addMul(camera.getFlatUp(), -speed);
     }
 
     const float rotation = 5.0f;
@@ -117,8 +117,8 @@ void Game::tick(Camera& cam) {
         widthAngle += rotation;
     }
 
-    cam.storePosition();
-    cam.setPosition(pos, lengthAngle, widthAngle);
+    ray.store();
+    ray.set(pos, lengthAngle, widthAngle);
 }
 
 void Game::renderWorld(float lag, MatrixStack& stack, Shader& sh) {

+ 6 - 4
client/Game.h

@@ -3,18 +3,18 @@
 
 #include "client/input/Keys.h"
 #include "client/input/MouseButtons.h"
+#include "client/math/Camera.h"
 #include "client/rendering/wrapper/Shader.h"
 #include "client/math/MatrixStack.h"
-#include "client/math/Camera.h"
 #include "client/rendering/Mesh.h"
 #include "client/rendering/Texture.h"
 #include "client/rendering/FontRenderer.h"
 
-class Game {
+class Game final {
 public:
-    Game(const Keys& keys, const MouseButtons& buttons);
+    Game(const Keys& keys, const MouseButtons& buttons, const Camera& camera, Ray& ray);
 
-    void tick(Camera& cam);
+    void tick();
     void renderWorld(float lag, MatrixStack& stack, Shader& sh);
     void renderTextOverlay(float lag, MatrixStack& stack, Shader& sh, FontRenderer& fr);
 
@@ -23,6 +23,8 @@ private:
 
     const Keys& keys;
     const MouseButtons& buttons;
+    const Camera& camera;
+    Ray& ray;
     
     float lengthAngle;
     float widthAngle;

+ 7 - 8
client/Main.cpp

@@ -8,6 +8,7 @@
 #include "client/input/Keys.h"
 #include "client/input/MouseButtons.h"
 #include "client/Engine.h"
+#include "client/utils/Clock.h"
 
 bool initGLEW() {
     GLenum err = glewInit();
@@ -74,20 +75,19 @@ int main() {
     MouseButtons mButtons;
     initCallbacks(window, size, framebuffers, keys, mButtons);
     
-    Engine engine(shaders, framebuffers, keys, mButtons, size);
+    Ray ray;
+    Camera camera(ray);
+    Clock fps;
+    
+    Engine engine(shaders, framebuffers, keys, mButtons, camera, ray, fps, size);
     window.show();
 
     const u64 nanosPerTick = 50000000;
-    u64 lastTime = GLFWWrapper::getTimeNanos();
     u64 lag = 0;
     while(!window.shouldClose() && engine.isRunning()) {
         engine.renderTick((float) lag / nanosPerTick);
         window.swapBuffers();
-
-        u64 newTime = GLFWWrapper::getTimeNanos();
-        lag += newTime - lastTime;
-        lastTime = newTime;
-
+        lag += fps.update();
         while(lag >= nanosPerTick) {
             lag -= nanosPerTick;
             keys.tick();
@@ -95,7 +95,6 @@ int main() {
             engine.tick();
             mButtons.postTick();
         }
-
         glfwPollEvents();
     }
 

+ 10 - 74
client/math/Camera.cpp

@@ -1,11 +1,7 @@
 #include "client/math/Camera.h"
 #include "client/Utils.h"
 
-Camera::Camera() : oldLengthAngle(0), lengthAngle(0), oldWidthAngle(0), widthAngle(0) {
-}
-
-const Vector& Camera::getFront() const {
-    return front;
+Camera::Camera(const Ray& ray) : ray(ray) {
 }
 
 const Vector& Camera::getBack() const {
@@ -16,22 +12,10 @@ const Vector& Camera::getRight() const {
     return right;
 }
 
-const Vector& Camera::getLeft() const {
-    return left;
-}
-
 const Vector& Camera::getUp() const {
     return up;
 }
 
-const Vector& Camera::getDown() const {
-    return down;
-}
-
-const Vector& Camera::getFlatFront() const {
-    return flatFront;
-}
-
 const Vector& Camera::getFlatBack() const {
     return flatBack;
 }
@@ -40,70 +24,22 @@ const Vector& Camera::getFlatRight() const {
     return flatRight;
 }
 
-const Vector& Camera::getFlatLeft() const {
-    return flatLeft;
-}
-
 const Vector& Camera::getFlatUp() const {
     return flatUp;
 }
 
-const Vector& Camera::getFlatDown() const {
-    return flatDown;
-}
-
 const Vector& Camera::getPosition() const {
-    return interPosition;
-}
-
-void Camera::storePosition() {
-    oldPosition = position;
-    oldLengthAngle = lengthAngle;
-    oldWidthAngle = widthAngle;
-}
-
-void Camera::setPosition(const Vector& pos, float length, float width) {
-    position = pos;
-    lengthAngle = length;
-    widthAngle = width;
+    return position;
 }
 
 void Camera::update(float lag) {
-    // back
-    back.setAngles(interpolate(lag, oldLengthAngle, lengthAngle), interpolate(lag, oldWidthAngle, widthAngle));
-    // front
-    front.setInverse(back);
-    // right
-    right = front;
-    right.cross(0.0f, 1.0f, 0.0f);
-    right.normalize();
-    // left
-    left.setInverse(right);
-    // up
-    up = front;
-    up.cross(left);
-    up.normalize();
-    // down
-    down.setInverse(up);
-    // interpolated position
-    interPosition = oldPosition;
-    interPosition.addMul(position, lag);
-    interPosition.addMul(oldPosition, -lag);
-
-    // flat back
-    flatBack = back;
-    flatBack.setY(0.0f);
-    flatBack.normalize();
-    // flat back
-    flatFront.setInverse(flatBack);
-    // flat right
-    flatRight = front;
-    flatRight.cross(0.0f, 1.0f, 0.0f);
-    flatRight.normalize();
-    // flat left
-    flatLeft.setInverse(flatRight);
-    // flat up
+    back = ray.getDirection(lag);
+    right.setInverse(back).cross(0.0f, 1.0f, 0.0f).normalize();
+    up.set(back).cross(right).normalize();
+    
+    flatBack.set(back).setY(0.0f).normalize();
+    flatRight.setInverse(back).cross(0.0f, 1.0f, 0.0f).normalize();
     flatUp.set(0.0f, 1.0f, 0.0f);
-    // flat down
-    flatDown.setInverse(flatUp);
+    
+    position = ray.getPosition(lag);
 }

+ 5 - 24
client/math/Camera.h

@@ -1,55 +1,36 @@
 #ifndef CAMERA3D_H
 #define CAMERA3D_H
 
-#include "client/math/Vector.h"
+#include "client/math/Ray.h"
 
 class Camera final {
 public:
-    Camera();
+    Camera(const Ray& ray);
 
-    const Vector& getFront() const;
     const Vector& getBack() const;
     const Vector& getRight() const;
-    const Vector& getLeft() const;
     const Vector& getUp() const;
-    const Vector& getDown() const;
 
-    const Vector& getFlatFront() const;
     const Vector& getFlatBack() const;
     const Vector& getFlatRight() const;
-    const Vector& getFlatLeft() const;
     const Vector& getFlatUp() const;
-    const Vector& getFlatDown() const;
 
     const Vector& getPosition() const;
-    void storePosition();
-    void setPosition(const Vector& pos, float length, float width);
 
     void update(float lag);
 
 private:
-    Vector oldPosition;
-    Vector position;
-    float oldLengthAngle;
-    float lengthAngle;
-    float oldWidthAngle;
-    float widthAngle;
-
-    Vector interPosition;
+    const Ray& ray;
 
-    Vector front;
     Vector back;
     Vector right;
-    Vector left;
     Vector up;
-    Vector down;
 
-    Vector flatFront;
     Vector flatBack;
     Vector flatRight;
-    Vector flatLeft;
     Vector flatUp;
-    Vector flatDown;
+
+    Vector position;
 };
 
 #endif

+ 1 - 1
client/math/Frustum.h

@@ -3,7 +3,7 @@
 
 #include "client/math/Matrix.h"
 
-class Frustum {
+class Frustum final {
 public:
     Frustum(float fovY, float nearClip, float farClip);
     void setProjection(Matrix& m, int width, int height);

+ 29 - 0
client/math/Ray.cpp

@@ -0,0 +1,29 @@
+#include "client/math/Ray.h"
+#include "client/Utils.h"
+
+Ray::Ray() : lastLengthAngle(0), lengthAngle(0), lastWidthAngle(0), widthAngle(0) {
+}
+
+void Ray::store() {
+    lastPosition = position;
+    lastLengthAngle = lengthAngle;
+    lastWidthAngle = widthAngle;
+}
+
+void Ray::set(const Vector& position, float lengthAngle, float widthAngle) {
+    this->position = position;
+    this->lengthAngle = lengthAngle;
+    this->widthAngle = widthAngle;
+}
+
+Vector Ray::getPosition(float lag) const {
+    Vector pos(lastPosition);
+    pos.addMul(position, lag).addMul(lastPosition, -lag);
+    return pos;
+}
+
+Vector Ray::getDirection(float lag) const {
+    Vector direction;
+    direction.setAngles(interpolate(lag, lastLengthAngle, lengthAngle), interpolate(lag, lastWidthAngle, widthAngle));
+    return direction;
+}

+ 27 - 0
client/math/Ray.h

@@ -0,0 +1,27 @@
+#ifndef RAY_H
+#define RAY_H
+
+#include "client/math/Vector.h"
+
+class Ray final {
+public:
+    Ray();
+    
+    void store();
+    void set(const Vector& position, float lengthAngle, float widthAngle);
+
+    Vector getPosition(float lag) const;
+    Vector getDirection(float lag) const;
+
+private:
+    Vector lastPosition;
+    Vector position;
+
+    float lastLengthAngle;
+    float lengthAngle;
+
+    float lastWidthAngle;
+    float widthAngle;
+};
+
+#endif

+ 34 - 17
client/math/Vector.cpp

@@ -20,63 +20,77 @@ float Vector::getZ() const {
     return z;
 }
 
-void Vector::setX(float ix) {
+Vector& Vector::setX(float ix) {
     x = ix;
+    return *this;
 }
 
-void Vector::setY(float iy) {
+Vector& Vector::setY(float iy) {
     y = iy;
+    return *this;
 }
 
-void Vector::setZ(float iz) {
+Vector& Vector::setZ(float iz) {
     z = iz;
+    return *this;
 }
 
-void Vector::set(float ix, float iy, float iz) {
+Vector& Vector::set(const Vector& v) {
+    return set(v.x, v.y, v.z);
+}
+
+Vector& Vector::set(float ix, float iy, float iz) {
     x = ix;
     y = iy;
     z = iz;
+    return *this;
 }
 
-void Vector::setInverse(const Vector& v) {
+Vector& Vector::setInverse(const Vector& v) {
     x = -v.x;
     y = -v.y;
     z = -v.z;
+    return *this;
 }
 
-void Vector::setMul(const Vector& v, float f) {
+Vector& Vector::setMul(const Vector& v, float f) {
     x = v.x * f;
     y = v.y * f;
     z = v.z * f;
+    return *this;
 }
 
-void Vector::setAngles(float lengthAngle, float widthAngle) {
+Vector& Vector::setAngles(float lengthAngle, float widthAngle) {
     lengthAngle = lengthAngle * M_PI / 180.0f;
     widthAngle = widthAngle * M_PI / 180.0f;
     x = cosf(widthAngle) * sinf(lengthAngle);
     y = sinf(widthAngle);
     z = cosf(widthAngle) * cosf(lengthAngle);
+    return *this;
 }
 
-void Vector::add(const Vector& v) {
+Vector& Vector::add(const Vector& v) {
     x += v.x;
     y += v.y;
     z += v.z;
+    return *this;
 }
 
-void Vector::sub(const Vector& v) {
+Vector& Vector::sub(const Vector& v) {
     x -= v.x;
     y -= v.y;
     z -= v.z;
+    return *this;
 }
 
-void Vector::mul(float f) {
+Vector& Vector::mul(float f) {
     x *= f;
     y *= f;
     z *= f;
+    return *this;
 }
 
-void Vector::mul(const Matrix& m) {
+Vector& Vector::mul(const Matrix& m) {
     const float* d = m.getValues();
     const float w = 1.0f;
     float nx = x * d[0] + y * d[4] + z * d[8] + w * d[12];
@@ -84,27 +98,30 @@ void Vector::mul(const Matrix& m) {
     float nz = x * d[2] + y * d[6] + z * d[10] + w * d[14];
     float nw = x * d[3] + y * d[7] + z * d[11] + w * d[15];
     set(nx / nw, ny / nw, nz / nw);
+    return *this;
 }
 
-void Vector::addMul(const Vector& v, float f) {
+Vector& Vector::addMul(const Vector& v, float f) {
     x += v.x * f;
     y += v.y * f;
     z += v.z * f;
+    return *this;
 }
 
-void Vector::cross(float ix, float iy, float iz) {
-    set(y * iz - z * iy, z * ix - x * iz, x * iy - y * ix);
+Vector& Vector::cross(float ix, float iy, float iz) {
+    return set(y * iz - z * iy, z * ix - x * iz, x * iy - y * ix);
 }
 
-void Vector::cross(const Vector& v) {
-    set(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
+Vector& Vector::cross(const Vector& v) {
+    return set(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
 }
 
-void Vector::normalize() {
+Vector& Vector::normalize() {
     float f = 1.0f / sqrtf(squareLength());
     x *= f;
     y *= f;
     z *= f;
+    return *this;
 }
 
 float Vector::squareLength() const {

+ 20 - 19
client/math/Vector.h

@@ -14,25 +14,26 @@ public:
     float getY() const;
     float getZ() const;
 
-    void setX(float ix);
-    void setY(float iy);
-    void setZ(float iz);
-
-    void set(float ix, float iy, float iz);
-    void setInverse(const Vector& v);
-    void setMul(const Vector& v, float f);
-    void setAngles(float lengthAngle, float widthAngle);
-
-    void add(const Vector& v);
-    void sub(const Vector& v);
-    void mul(float f);
-    void mul(const Matrix& m);
-    void addMul(const Vector& v, float f);
-
-    void cross(float ix, float iy, float iz);
-    void cross(const Vector& v);
-
-    void normalize();
+    Vector& setX(float ix);
+    Vector& setY(float iy);
+    Vector& setZ(float iz);
+
+    Vector& set(const Vector& v);
+    Vector& set(float ix, float iy, float iz);
+    Vector& setInverse(const Vector& v);
+    Vector& setMul(const Vector& v, float f);
+    Vector& setAngles(float lengthAngle, float widthAngle);
+
+    Vector& add(const Vector& v);
+    Vector& sub(const Vector& v);
+    Vector& mul(float f);
+    Vector& mul(const Matrix& m);
+    Vector& addMul(const Vector& v, float f);
+
+    Vector& cross(float ix, float iy, float iz);
+    Vector& cross(const Vector& v);
+
+    Vector& normalize();
     float squareLength() const;
 
     float dot(const Vector& v) const;

+ 1 - 1
client/rendering/Framebuffers.h

@@ -4,7 +4,7 @@
 #include "client/rendering/WindowSize.h"
 #include "client/rendering/wrapper/Framebuffer.h"
 
-struct Framebuffers {
+struct Framebuffers final {
     Framebuffers(const WindowSize& size);
     void resize(uint width, uint height);
     bool hasError() const;

+ 1 - 1
client/rendering/Shaders.h

@@ -3,7 +3,7 @@
 
 #include "client/rendering/wrapper/Shader.h"
 
-struct Shaders {
+struct Shaders final {
     Shaders();
     bool hasError() const;
 

+ 1 - 1
client/rendering/WindowSize.h

@@ -1,7 +1,7 @@
 #ifndef WINDOWSIZE_H
 #define WINDOWSIZE_H
 
-struct WindowSize {
+struct WindowSize final {
     WindowSize(int width, int height);
     
     int width;

+ 25 - 0
client/utils/Clock.cpp

@@ -0,0 +1,25 @@
+#include "client/utils/Clock.h"
+#include "client/rendering/wrapper/GLFWWrapper.h"
+
+#include <iostream>
+
+Clock::Clock() : last(GLFWWrapper::getTimeNanos()), index(0), sum(0), time(0) {
+}
+
+u64 Clock::update() {
+    index = (index + 1) & (length - 1);
+    u64 current = GLFWWrapper::getTimeNanos();
+    sum -= time[index];
+    time[index] = current - last;
+    sum += time[index];
+    last = current;
+    return time[index];
+}
+
+u64 Clock::getLength() const {
+    return length;
+}
+
+float Clock::getUpdatesPerSecond() const {
+    return length * (1000000000.0f / sum);
+}

+ 23 - 0
client/utils/Clock.h

@@ -0,0 +1,23 @@
+#ifndef CLOCK_H
+#define CLOCK_H
+
+#include "common/utils/Types.h"
+#include "common/utils/Array.h"
+
+class Clock final {
+public:
+    Clock();
+    u64 update();
+    u64 getLength() const;
+    float getUpdatesPerSecond() const;
+
+private:
+    static constexpr u64 bits = 7;
+    static constexpr u64 length = 1 << bits;
+    u64 last;
+    u64 index;
+    s64 sum;
+    Array<u64, length> time;
+};
+
+#endif

+ 6 - 6
common/utils/Array.h

@@ -3,29 +3,29 @@
 
 #include "common/utils/Types.h"
 
-template<typename T, size_t N>
+template<typename T, u64 N>
 class Array final {
 public:
 
     Array(const T& t) {
-        for(uint i = 0; i < N; i++) {
+        for(u64 i = 0; i < N; i++) {
             data[i] = t;
         }
     }
 
-    const T& operator[](size_t index) const {
+    const T& operator[](u64 index) const {
         return data[index];
     }
 
-    T& operator[](size_t index) {
+    T& operator[](u64 index) {
         return data[index];
     }
 
-    const T* operator+(size_t index) const {
+    const T* operator+(u64 index) const {
         return data + index;
     }
 
-    T* operator+(size_t index) {
+    T* operator+(u64 index) {
         return data + index;
     }
 

+ 1 - 1
meson.build

@@ -4,7 +4,7 @@ sourcesCommon = ['common/block/BlockRegistry.cpp', 'common/block/Block.cpp', 'co
 
 sourcesServer = ['server/GameServer.cpp', 'server/commands/CommandUtils.cpp', 'server/commands/ServerCommands.cpp', 'server/commands/CommandManager.cpp', 'server/network/Server.cpp', 'server/Main.cpp']
 
-sourcesClient = ['client/Main.cpp', 'client/rendering/WindowSize.cpp', 'client/math/Frustum.cpp', 'client/rendering/Framebuffers.cpp', 'client/rendering/wrapper/GLFWWrapper.cpp', 'client/rendering/wrapper/Window.cpp', 'client/Engine.cpp', 'client/input/Keys.cpp', 'client/rendering/wrapper/Shader.cpp', 'client/rendering/Shaders.cpp', 'client/Utils.cpp', 'client/rendering/Mesh.cpp', 'client/math/Matrix.cpp', 'client/math/MatrixStack.cpp', 'client/math/Vector.cpp', 'client/math/Camera.cpp', 'client/math/Plane.cpp', 'client/Game.cpp', 'client/input/MouseButtons.cpp', 'client/rendering/Texture.cpp', 'client/rendering/FontRenderer.cpp', 'client/rendering/wrapper/Framebuffer.cpp', 'client/rendering/NoiseTexture.cpp']
+sourcesClient = ['client/Main.cpp', 'client/rendering/WindowSize.cpp', 'client/math/Frustum.cpp', 'client/math/Ray.cpp', 'client/rendering/Framebuffers.cpp', 'client/rendering/wrapper/GLFWWrapper.cpp', 'client/rendering/wrapper/Window.cpp', 'client/Engine.cpp', 'client/input/Keys.cpp', 'client/rendering/wrapper/Shader.cpp', 'client/rendering/Shaders.cpp', 'client/Utils.cpp', 'client/rendering/Mesh.cpp', 'client/math/Matrix.cpp', 'client/math/MatrixStack.cpp', 'client/math/Vector.cpp', 'client/math/Camera.cpp', 'client/math/Plane.cpp', 'client/Game.cpp', 'client/input/MouseButtons.cpp', 'client/rendering/Texture.cpp', 'client/rendering/FontRenderer.cpp', 'client/rendering/wrapper/Framebuffer.cpp', 'client/rendering/NoiseTexture.cpp', 'client/utils/Clock.cpp']
 
 sourcesTest = ['tests/Main.cpp', 'server/commands/CommandUtils.cpp']