Browse Source

integration of gaming core lib, removal of old deprecated classes

Kajetan Johannes Hammerle 3 years ago
parent
commit
1d81f662cd

+ 2 - 2
Game.cpp

@@ -1,7 +1,7 @@
 #include "Game.h"
 #include "rendering/Renderer.h"
 #include "rendering/wrapper/GLFW.h"
-#include "utils/String.h"
+#include "utils/StringBuffer.h"
 
 float x = 0.0f;
 float y = 0.0f;
@@ -67,7 +67,7 @@ void Game::render(float lag, Renderer& renderer) const {
     renderer.translateTo(0.0f, 0.0f).update();
     renderer.drawRectangle(lastX + (x - lastX) * lag, lastY + (y - lastY) * lag, playerWidth, playerHeight, 0xFF0000FF);
     renderer.translateTo(0.0f, 0.0f).update();
-    String s;
+    StringBuffer<100> s;
     s.append("FPS: ").append(fps.getUpdatesPerSecond());
     float y = 0.0f;
     renderer.setStringSize(2);

+ 3 - 4
Main.cpp

@@ -3,7 +3,6 @@
 
 #include "rendering/wrapper/GLFW.h"
 #include "rendering/wrapper/GLWrapper.h"
-#include "rendering/WindowSize.h"
 #include "rendering/wrapper/Window.h"
 #include "rendering/Options.h"
 #include "utils/Clock.h"
@@ -48,7 +47,7 @@ int main(int argAmount, char* const* args) {
         return 0;
     }
 
-    WindowSize size(800, 480);
+    Size size(800, 480);
     Controller controller;
     Window window(size, controller, options);
     if(window.hasError() || initGLEW()) {
@@ -83,8 +82,8 @@ int main(int argAmount, char* const* args) {
         }
 
         Matrix view;
-        view.translate(-1.0f, 1.0f);
-        view.scale(2.0f / size.width, -2.0f / size.height);
+        view.scale(Vector3(2.0f / size.width, -2.0f / size.height, 1.0f));
+        view.translate(Vector3(-1.0f, 1.0f, 0.0f));
         shader.setMatrix("view", view.getValues());
 
         game.render(static_cast<float> (lag) / nanosPerTick, renderer);

+ 0 - 136
math/Matrix.cpp

@@ -1,136 +0,0 @@
-#include <cmath>
-#include <iomanip>
-#include <cstring>
-
-#include "math/Matrix.h"
-
-Matrix::Matrix() {
-    setToIdentity();
-}
-
-Matrix& Matrix::set(const Matrix& other) {
-    *this = other;
-    return *this;
-}
-
-Matrix& Matrix::setToIdentity() {
-    data[0] = 1.0f;
-    data[1] = 0.0f;
-    data[2] = 0.0f;
-    data[3] = 0.0f;
-    data[4] = 1.0f;
-    data[5] = 0.0f;
-    data[6] = 0.0f;
-    data[7] = 0.0f;
-    data[8] = 1.0f;
-    return *this;
-}
-
-Matrix& Matrix::set(uint index, float f) {
-    data[index] = f;
-    return *this;
-}
-
-const float* Matrix::getValues() const {
-    return data;
-}
-
-Matrix& Matrix::mul(const Matrix& m) {
-    float mNew[9];
-    mNew[0] = data[0] * m.data[0] + data[3] * m.data[1] + data[6] * m.data[2];
-    mNew[1] = data[1] * m.data[0] + data[4] * m.data[1] + data[7] * m.data[2];
-    mNew[2] = data[2] * m.data[0] + data[5] * m.data[1] + data[8] * m.data[2];
-    mNew[3] = data[0] * m.data[3] + data[3] * m.data[4] + data[6] * m.data[5];
-    mNew[4] = data[1] * m.data[3] + data[4] * m.data[4] + data[7] * m.data[5];
-    mNew[5] = data[2] * m.data[3] + data[5] * m.data[4] + data[8] * m.data[5];
-    mNew[6] = data[0] * m.data[6] + data[3] * m.data[7] + data[6] * m.data[8];
-    mNew[7] = data[1] * m.data[6] + data[4] * m.data[7] + data[7] * m.data[8];
-    mNew[8] = data[2] * m.data[6] + data[5] * m.data[7] + data[8] * m.data[8];
-    memcpy(data, mNew, sizeof (float) * 9);
-    return *this;
-}
-
-Matrix& Matrix::scale(float sx, float sy) {
-    data[0] *= sx;
-    data[1] *= sx;
-    data[2] *= sx;
-    data[3] *= sy;
-    data[4] *= sy;
-    data[5] *= sy;
-    return *this;
-}
-
-Matrix& Matrix::scale(float s) {
-    return scale(s, s);
-}
-
-Matrix& Matrix::translate(float tx, float ty) {
-    return translateX(tx).translateY(ty);
-}
-
-Matrix& Matrix::translateX(float tx) {
-    data[6] += data[0] * tx;
-    data[7] += data[1] * tx;
-    data[8] += data[2] * tx;
-    return *this;
-}
-
-Matrix& Matrix::translateY(float ty) {
-    data[6] += data[3] * ty;
-    data[7] += data[4] * ty;
-    data[8] += data[5] * ty;
-    return *this;
-}
-
-Matrix& Matrix::translateTo(float tx, float ty) {
-    data[0] = 1.0f;
-    data[1] = 0.0f;
-    data[2] = 0.0f;
-    data[3] = 0.0f;
-    data[4] = 1.0f;
-    data[5] = 0.0f;
-    data[6] = tx;
-    data[7] = ty;
-    data[8] = 1.0f;
-    return *this;
-}
-
-Matrix& Matrix::rotate(float degrees) {
-    degrees *= M_PIf32 / 180.0f;
-    float sin;
-    float cos;
-    sincosf(degrees, &sin, &cos);
-     
-    float a = data[0];
-    float b = data[3];
-    data[0] = a * cos + b * sin;
-    data[3] = b * cos - a * sin;
-    
-    a = data[1];
-    b = data[4];
-    data[1] = a * cos + b * sin;
-    data[4] = b * cos - a * sin;
-    
-    a = data[2];
-    b = data[5];
-    data[2] = a * cos + b * sin;
-    data[5] = b * cos - a * sin;
-    return *this;
-}
-
-std::ostream& operator<<(std::ostream& os, const Matrix& m) {
-    const float* data = m.getValues();
-    os << "Matrix\n(\n";
-    os << std::fixed << std::setprecision(5);
-    for(int i = 0; i < 3; i++) {
-        os << std::setw(15);
-        os << data[i] << ", ";
-        os << std::setw(15);
-        os << data[i + 3] << ", ";
-        os << std::setw(15);
-        os << data[i + 6] << "\n";
-    }
-    os << std::defaultfloat;
-    os << ")";
-    return os;
-}

+ 0 - 34
math/Matrix.h

@@ -1,34 +0,0 @@
-#ifndef MATRIX_H
-#define MATRIX_H
-
-#include <iostream>
-
-class Matrix final {
-public:
-    Matrix();
-
-    Matrix& set(const Matrix& other);
-    Matrix& setToIdentity();
-    Matrix& set(uint index, float f);
-
-    const float* getValues() const;
-
-    Matrix& mul(const Matrix& m);
-
-    Matrix& scale(float sx, float sy);
-    Matrix& scale(float s);
-
-    Matrix& translate(float tx, float ty);
-    Matrix& translateX(float tx);
-    Matrix& translateY(float ty);
-    Matrix& translateTo(float tx, float ty);
-
-    Matrix& rotate(float degrees);
-
-private:
-    float data[9];
-};
-
-std::ostream& operator<<(std::ostream& os, const Matrix& m);
-
-#endif

+ 0 - 23
math/MatrixStack.cpp

@@ -1,23 +0,0 @@
-#include <cassert>
-
-#include "math/MatrixStack.h"
-
-void MatrixStack::pop() {
-    assert(index > 0);
-    index--;
-}
-
-void MatrixStack::push() {
-    assert(index < stack.size() - 1);
-    index++;
-    stack[index] = stack[index - 1];
-}
-
-Matrix& MatrixStack::get() {
-    return stack[index];
-}
-
-void MatrixStack::clear() {
-    index = 0;
-    stack[0].setToIdentity();
-}

+ 0 - 20
math/MatrixStack.h

@@ -1,20 +0,0 @@
-#ifndef MATRIXSTACK_H
-#define MATRIXSTACK_H
-
-#include <array>
-
-#include "math/Matrix.h"
-
-class MatrixStack final {
-public:
-    void pop();
-    void push();
-    Matrix& get();
-    void clear();
-
-private:
-    std::array<Matrix, 10> stack;
-    size_t index = 0;
-};
-
-#endif

+ 0 - 141
math/Vector.cpp

@@ -1,141 +0,0 @@
-#include <cmath>
-
-#include "math/Vector.h"
-
-Vector::Vector() : x(0), y(0), z(0) {
-}
-
-Vector::Vector(float ix, float iy, float iz) : x(ix), y(iy), z(iz) {
-}
-
-float Vector::getX() const {
-    return x;
-}
-
-float Vector::getY() const {
-    return y;
-}
-
-float Vector::getZ() const {
-    return z;
-}
-
-Vector& Vector::setX(float ix) {
-    x = ix;
-    return *this;
-}
-
-Vector& Vector::setY(float iy) {
-    y = iy;
-    return *this;
-}
-
-Vector& Vector::setZ(float iz) {
-    z = iz;
-    return *this;
-}
-
-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;
-}
-
-Vector& Vector::setInverse(const Vector& v) {
-    x = -v.x;
-    y = -v.y;
-    z = -v.z;
-    return *this;
-}
-
-Vector& Vector::setMul(const Vector& v, float f) {
-    x = v.x * f;
-    y = v.y * f;
-    z = v.z * f;
-    return *this;
-}
-
-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;
-}
-
-Vector& Vector::add(const Vector& v) {
-    x += v.x;
-    y += v.y;
-    z += v.z;
-    return *this;
-}
-
-Vector& Vector::sub(const Vector& v) {
-    x -= v.x;
-    y -= v.y;
-    z -= v.z;
-    return *this;
-}
-
-Vector& Vector::mul(float f) {
-    x *= f;
-    y *= f;
-    z *= f;
-    return *this;
-}
-
-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];
-    float ny = x * d[1] + y * d[5] + z * d[9] + w * d[13];
-    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;
-}
-
-Vector& Vector::addMul(const Vector& v, float f) {
-    x += v.x * f;
-    y += v.y * f;
-    z += v.z * f;
-    return *this;
-}
-
-Vector& Vector::cross(float ix, float iy, float iz) {
-    return set(y * iz - z * iy, z * ix - x * iz, x * iy - y * ix);
-}
-
-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);
-}
-
-Vector& Vector::normalize() {
-    float f = 1.0f / sqrtf(squareLength());
-    x *= f;
-    y *= f;
-    z *= f;
-    return *this;
-}
-
-float Vector::squareLength() const {
-    return x * x + y * y + z * z;
-}
-
-float Vector::dot(const Vector& v) const {
-    return x * v.x + y * v.y + z * v.z;
-}
-
-float Vector::dotInverse(const Vector& v) const {
-    return x * (-v.x) + y * (-v.y) + z * (-v.z);
-}
-
-std::ostream& operator<<(std::ostream& os, const Vector& v) {
-    return os << "Vector(x = " << v.getX() << ", y = " << v.getY() << ", z = " << v.getZ() << ")";
-}

+ 0 - 50
math/Vector.h

@@ -1,50 +0,0 @@
-#ifndef VECTOR_H
-#define VECTOR_H
-
-#include <iostream>
-
-#include "math/Matrix.h"
-
-class Vector final {
-public:
-    Vector();
-    Vector(float ix, float iy, float iz);
-
-    float getX() const;
-    float getY() const;
-    float getZ() const;
-
-    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;
-    float dotInverse(const Vector& v) const;
-
-private:
-    float x;
-    float y;
-    float z;
-};
-
-std::ostream& operator<<(std::ostream& os, const Vector& v);
-
-#endif

+ 5 - 6
meson.build

@@ -3,7 +3,7 @@ project('pigine', 'cpp')
 sources = [
     'Main.cpp', 
     'rendering/wrapper/GLFW.cpp', 
-    'rendering/WindowSize.cpp', 
+    'gaming-core/utils/Size.cpp', 
     'rendering/wrapper/Window.cpp', 
     'utils/Clock.cpp', 
     'rendering/wrapper/Shader.cpp', 
@@ -12,11 +12,10 @@ sources = [
     'input/Controller.cpp',
     'input/Button.cpp',
     'rendering/Renderer.cpp',
-    'math/Vector.cpp',
-    'math/Matrix.cpp',
-    'math/MatrixStack.cpp',
+    'gaming-core/math/Matrix.cpp',
+    'gaming-core/math/Quaternion.cpp',
+    'gaming-core/math/Vector.cpp',
     'utils/PNGReader.cpp',
-    'utils/Utils.cpp',
     'rendering/wrapper/StreamBuffer.cpp',
     'rendering/wrapper/Texture.cpp',
     'rendering/wrapper/VertexBuffer.cpp',
@@ -24,7 +23,6 @@ sources = [
     'rendering/ColorRenderer.cpp',
     'rendering/FontRenderer.cpp',
     'rendering/Mesh.cpp',
-    'utils/String.cpp',
     'rendering/Options.cpp'
 ]
 
@@ -35,6 +33,7 @@ pngDep = dependency('libpng')
 executable('pigine', 
     sources: sources,
     dependencies : [glewDep, glfwDep, pngDep],
+    include_directories : include_directories('gaming-core'),
     cpp_args: ['-Wall', '-Wextra', '-pedantic', '-Werror'])
     
 

+ 1 - 1
rendering/Mesh.cpp

@@ -18,7 +18,7 @@ void Mesh::clear() {
 
 void Mesh::build() {
     vertexBuffer.bind();
-    vertexBuffer.setData(sizeof (VertexData) * buffer.getLength(), buffer.getData());
+    vertexBuffer.setData(sizeof (VertexData) * buffer.getLength(), &(buffer[0]));
 }
 
 void Mesh::draw() const {

+ 9 - 9
rendering/Renderer.cpp

@@ -1,7 +1,7 @@
 #include "rendering/Renderer.h"
 #include "rendering/wrapper/GLWrapper.h"
 
-Renderer::Renderer(const WindowSize& size, Shader& shader) : size(size), shader(shader), texture(true), color(true) {
+Renderer::Renderer(const Size& size, Shader& shader) : size(size), shader(shader), texture(true), color(true) {
     shader.use();
     GLWrapper::enableBlending();
     setTextureMode(false);
@@ -17,41 +17,41 @@ void Renderer::push() {
 }
 
 void Renderer::update() {
-    shader.setMatrix("model", stack.get().getValues());
+    shader.setMatrix("model", stack.peek().getValues());
 }
 
 Renderer& Renderer::scale(float sx, float sy) {
-    stack.get().scale(sx, sy);
+    stack.peek().scale(Vector3(sx, sy, 1.0f));
     return *this;
 }
 
 Renderer& Renderer::scale(float s) {
-    stack.get().scale(s);
+    stack.peek().scale(s);
     return *this;
 }
 
 Renderer& Renderer::translate(float tx, float ty) {
-    stack.get().translate(tx, ty);
+    stack.peek().translateX(tx).translateY(ty);
     return *this;
 }
 
 Renderer& Renderer::translateX(float tx) {
-    stack.get().translateX(tx);
+    stack.peek().translateX(tx);
     return *this;
 }
 
 Renderer& Renderer::translateY(float ty) {
-    stack.get().translateY(ty);
+    stack.peek().translateY(ty);
     return *this;
 }
 
 Renderer& Renderer::translateTo(float tx, float ty) {
-    stack.get().translateTo(tx, ty);
+    stack.peek().translateTo(Vector3(tx, ty, 0.0f));
     return *this;
 }
 
 Renderer& Renderer::rotate(float degrees) {
-    stack.get().rotate(degrees);
+    stack.peek().rotateZ(degrees);
     return *this;
 }
 

+ 4 - 4
rendering/Renderer.h

@@ -2,14 +2,14 @@
 #define RENDERER_H
 
 #include "rendering/wrapper/Shader.h"
-#include "rendering/WindowSize.h"
+#include "utils/Size.h"
 #include "math/MatrixStack.h"
 #include "rendering/FontRenderer.h"
 #include "rendering/ColorRenderer.h"
 
 class Renderer final {
 public:
-    Renderer(const WindowSize& size, Shader& shader);
+    Renderer(const Size& size, Shader& shader);
 
     void pop();
     void push();
@@ -36,11 +36,11 @@ private:
     void setTextureMode(bool b);
     void setColorMode(bool b);
     
-    const WindowSize& size;
+    const Size& size;
     Shader& shader;
     bool texture;
     bool color;
-    MatrixStack stack;
+    MatrixStack<10> stack;
     FontRenderer fontRenderer;
     ColorRenderer colorRenderer;
 };

+ 0 - 4
rendering/WindowSize.cpp

@@ -1,4 +0,0 @@
-#include "rendering/WindowSize.h"
-
-WindowSize::WindowSize(int width, int height) : width(width), height(height) {
-}

+ 0 - 11
rendering/WindowSize.h

@@ -1,11 +0,0 @@
-#ifndef WINDOWSIZE_H
-#define WINDOWSIZE_H
-
-struct WindowSize final {
-    WindowSize(int width, int height);
-    
-    int width;
-    int height;
-};
-
-#endif

+ 1 - 1
rendering/wrapper/GLFW.cpp

@@ -4,7 +4,7 @@
 
 bool GLFW::init() {
     if(glfwInit()) {
-        std::atexit([]() {
+        atexit([]() {
             glfwTerminate();
         });
         return false;

+ 1 - 1
rendering/wrapper/Shader.cpp

@@ -77,7 +77,7 @@ void Shader::use() const {
 }
 
 void Shader::setMatrix(const GLchar* name, const GLfloat* data) const {
-    glUniformMatrix3fv(glGetUniformLocation(program, name), 1, GL_FALSE, data);
+    glUniformMatrix4fv(glGetUniformLocation(program, name), 1, GL_TRUE, data);
 }
 
 void Shader::setInt(const GLchar* name, GLint data) const {

+ 1 - 1
rendering/wrapper/Window.cpp

@@ -2,7 +2,7 @@
 
 #include "rendering/wrapper/Window.h"
 
-Window::Window(WindowSize& size, Controller& controller, const Options& options) : window(nullptr), size(size),
+Window::Window(Size& size, Controller& controller, const Options& options) : window(nullptr), size(size),
 controller(controller) {
     glfwDefaultWindowHints();
     glfwWindowHint(GLFW_VISIBLE, 0);

+ 3 - 3
rendering/wrapper/Window.h

@@ -4,17 +4,17 @@
 #include <GL/glew.h>
 #include <GLFW/glfw3.h>
 
-#include "rendering/WindowSize.h"
+#include "utils/Size.h"
 #include "input/Controller.h"
 #include "rendering/Options.h"
 
 class Window final {
     GLFWwindow* window;
-    WindowSize& size;
+    Size& size;
     Controller& controller;
 
 public:
-    Window(WindowSize& size, Controller& controller, const Options& options);
+    Window(Size& size, Controller& controller, const Options& options);
     ~Window();
 
     Window(const Window&) = delete;

+ 3 - 3
resources/shader/vertex.vs

@@ -6,8 +6,8 @@ layout (location = 0) in vec2 position;
 layout (location = 1) in vec2 tex;
 layout (location = 2) in vec4 color;
 
-uniform mat3 view;
-uniform mat3 model;
+uniform mat4 view;
+uniform mat4 model;
 
 out vec2 varTex;
 out vec4 varColor;
@@ -15,5 +15,5 @@ out vec4 varColor;
 void main() { 
     varTex = tex; 
     varColor = color; 
-    gl_Position = vec4(view * model * vec3(position, 1.0), 1.0);
+    gl_Position = view * model * vec4(position, 0.0, 1.0);
 }

+ 0 - 54
utils/Array.h

@@ -1,54 +0,0 @@
-#ifndef ARRAY_H
-#define ARRAY_H
-
-template<typename T, int N>
-class Array final {
-    T data[N];
-
-public:
-    Array() = default;
-
-    Array(const T& t) {
-        for(int i = 0; i < N; i++) {
-            data[i] = t;
-        }
-    }
-
-    const T& operator[](int index) const {
-        return data[index];
-    }
-
-    T& operator[](int index) {
-        return data[index];
-    }
-
-    const T* operator+(int index) const {
-        return data + index;
-    }
-
-    T* operator+(int index) {
-        return data + index;
-    }
-
-    T* begin() {
-        return data;
-    }
-
-    const T* begin() const {
-        return data;
-    }
-
-    T* end() {
-        return data + N;
-    }
-
-    const T* end() const {
-        return data + N;
-    }
-
-    constexpr int getLength() const {
-        return N;
-    }
-};
-
-#endif

+ 0 - 97
utils/HashMap.h

@@ -1,97 +0,0 @@
-#ifndef HASHMAP_H
-#define HASHMAP_H
-
-#include "common/utils/Types.h"
-
-template<typename K, typename V, uint L>
-class HashMap final {
-public:
-
-    HashMap(K emptyKey, V emptyValue) : entries(0), emptyKey(emptyKey), emptyValue(emptyValue) {
-        for(uint i = 0; i < LENGTH; i++) {
-            data[i].key = emptyKey;
-            data[i].value = emptyValue;
-        }
-    }
-
-    static constexpr uint getCapacity() {
-        return LENGTH;
-    }
-
-    void add(const K key, const V value) {
-        if(entries >= L) {
-            return;
-        }
-        uint hash = hashCode(key) % LENGTH;
-        while(true) {
-            if(data[hash].key == key) {
-                data[hash].value = value;
-                return;
-            } else if(data[hash].key == emptyKey) {
-                data[hash].key = key;
-                data[hash].value = value;
-                entries++;
-                return;
-            }
-            hash = (hash + 1) % LENGTH;
-        }
-    }
-
-    V search(const K key) const {
-        uint hash = hashCode(key) % LENGTH;
-        while(true) {
-            if(data[hash].key == key) {
-                return data[hash].value;
-            } else if(data[hash].key == emptyKey) {
-                return emptyValue;
-            }
-            hash = (hash + 1) % LENGTH;
-        }
-    }
-
-    void forEach(void (*f)(const K&, V&)) {
-        for(uint i = 0; i < LENGTH; i++) {
-            if(data[i].key != emptyKey) {
-                f(data[i].key, data[i].value);
-            }
-        }
-    }
-
-private:
-
-    static constexpr uint getLength() {
-        constexpr uint SIZE_TABLE[] = {
-            2, 3, 7, 11, 23, 43, 89, 173, 347, 683, 1367, 2731, 5471, 10937, 21851, 43691, 87383, 174763, 349529, 699053,
-            1398107, 2796203, 5592407, 11184829, 22369661, 44739259, 89478503, 178956983, 357913951, 715827883, 1431655777,
-            2863311551
-        };
-        uint i = 0;
-        while(SIZE_TABLE[i] < L) {
-            i++;
-        }
-        return SIZE_TABLE[i];
-    }
-
-    template<typename H>
-    uint hashCode(const H& h) const {
-        return h.hashCode();
-    }
-
-    uint hashCode(const uint& h) const {
-        return h;
-    }
-
-    static constexpr uint LENGTH = getLength();
-
-    uint entries;
-    K emptyKey;
-    V emptyValue;
-
-    struct KeyValuePair {
-        K key;
-        V value;
-    };
-    KeyValuePair data[LENGTH];
-};
-
-#endif

+ 0 - 29
utils/HashedString.cpp

@@ -1,29 +0,0 @@
-#include "common/utils/HashedString.h"
-
-HashedString::HashedString() : length(0), hash(0) {
-    data[length] = '\0';
-}
-
-HashedString::HashedString(const char* str) : length(0), hash(0) {
-    for(; length < LENGTH - 1 && str[length] != '\0'; length++) {
-        data[length] = str[length];
-        hash = hash * 257 + str[length];
-    }
-    data[length] = '\0';
-}
-
-bool HashedString::operator==(const HashedString& other) const {
-    return hash == other.hash && length == other.length;
-}
-
-bool HashedString::operator!=(const HashedString& other) const {
-    return !(*this == other);
-}
-
-HashedString::operator const char*() const {
-    return data;
-}
-
-u32 HashedString::hashCode() const {
-    return hash;
-}

+ 0 - 24
utils/HashedString.h

@@ -1,24 +0,0 @@
-#ifndef HASHEDSTRING_H
-#define HASHEDSTRING_H
-
-#include "common/utils/Types.h"
-
-class HashedString final {
-public:
-    HashedString();
-    HashedString(const char* str);
-
-    bool operator==(const HashedString& other) const;
-    bool operator!=(const HashedString& other) const;
-    operator const char*() const;
-
-    u32 hashCode() const;
-
-private:
-    static constexpr uint LENGTH = 32 - sizeof (u8) - sizeof (u32);
-    char data[LENGTH];
-    u8 length;
-    u32 hash;
-};
-
-#endif

+ 0 - 64
utils/List.h

@@ -1,64 +0,0 @@
-#ifndef LIST_H
-#define LIST_H
-
-template<typename T, int L>
-class List final {
-    int entries;
-    T data[L];
-
-public:
-
-    List() : entries(0) {
-    }
-
-    List& add(const T& t) {
-        if(entries >= L) {
-            return *this;
-        }
-        data[entries++] = t;
-        return *this;
-    }
-
-    List& clear() {
-        entries = 0;
-        return *this;
-    }
-
-    int getLength() const {
-        return entries;
-    }
-
-    constexpr int getCapacity() const {
-        return L;
-    }
-
-    T& operator[](int index) {
-        return data[index];
-    }
-
-    const T& operator[](int index) const {
-        return data[index];
-    }
-
-    const T* getData() {
-        return data;
-    }
-
-    T* begin() {
-        return data;
-    }
-
-    const T* begin() const {
-        return data;
-    }
-
-    T* end() {
-        return data + entries;
-    }
-
-    const T* end() const {
-        return data + entries;
-    }
-};
-
-#endif

+ 0 - 26
utils/Random.cpp

@@ -1,26 +0,0 @@
-#include <chrono>
-
-#include "common/utils/Random.h"
-
-Random::Random() : seed(std::chrono::steady_clock::now().time_since_epoch().count()) {
-}
-
-Random::Random(u64 seed) : seed(seed) {
-}
-
-u32 Random::next() {
-    return nextSeed() >> 24;
-}
-
-u32 Random::next(uint bound) {
-    return next() % bound;
-}
-
-float Random::nextFloat() {
-    return next() * (1.0f / (0xFFFFFF + 1.0f));
-}
-
-u64 Random::nextSeed() {
-    seed = (seed * 0x5DEECE66DL + 0xBL) & 0xFFFFFFFFFFFF;
-    return seed;
-}

+ 0 - 21
utils/Random.h

@@ -1,21 +0,0 @@
-#ifndef RANDOM_H
-#define RANDOM_H
-
-#include "common/utils/Types.h"
-
-class Random {
-public:
-    Random();
-    Random(u64 seed);
-
-    u32 next();
-    u32 next(uint bound);
-    float nextFloat();
-
-private:
-    u64 nextSeed();
-
-    u64 seed;
-};
-
-#endif

+ 0 - 31
utils/RingBuffer.h

@@ -1,31 +0,0 @@
-#ifndef RINGBUFFER_H
-#define RINGBUFFER_H
-
-#include "common/utils/Array.h"
-
-template<typename T, uint N>
-class RingBuffer final {
-public:
-
-    void write(const T& t) {
-        data[writeIndex] = t;
-        writeIndex = (writeIndex + 1) % N;
-    }
-
-    bool canRead() const {
-        return writeIndex != readIndex;
-    }
-
-    T read() {
-        T& t = data[readIndex];
-        readIndex = (readIndex + 1) % N;
-        return t;
-    }
-
-private:
-    Array<T, N> data;
-    uint writeIndex = 0;
-    uint readIndex = 0;
-};
-
-#endif

+ 0 - 44
utils/SplitString.cpp

@@ -1,44 +0,0 @@
-#include "common/utils/SplitString.h"
-
-SplitString::SplitString(const char* str) : entries(0) {
-    for(uint i = 0; str[i] != '\0'; i++) {
-        if(str[i] == '"') {
-            if(i >= 1 && str[i - 1] != ' ') {
-                return;
-            }
-            data += '"';
-            i++;
-            while(str[i] != '"') {
-                if(str[i] == '\0') {
-                    return;
-                }
-                data += str[i++];
-            }
-            if(str[i + 1] != '\0' && str[i + 1] != ' ') {
-                return;
-            }
-            data += '\0';
-            continue;
-        }
-        data += (str[i] == ' ' ? '\0' : str[i]);
-    }
-    uint last = 0;
-    for(uint i = 0; i < data.getLength() + 1; i++) {
-        if(data[i] != '\0' && data[i] != '"') {
-            continue;
-        }
-        if(i - last > 0 || (i >= 1 && data[i - 1] == '"')) {
-            starts[entries++] = last;
-        }
-        last = i + 1;
-    }
-}
-
-uint SplitString::getLength() const {
-    return entries;
-}
-
-const char* SplitString::operator[](uint index) const {
-    return data + starts[index];
-}
-

+ 0 - 19
utils/SplitString.h

@@ -1,19 +0,0 @@
-#ifndef SPLITSTRING_H
-#define SPLITSTRING_H
-
-#include "common/utils/String.h"
-
-class SplitString final {
-public:
-    SplitString(const char* str);
-    
-    uint getLength() const;
-    const char* operator[](uint index) const;
-
-private:
-    String data;
-    uint entries;
-    u8 starts[String::MAX_LENGTH];
-};
-
-#endif

+ 0 - 69
utils/String.cpp

@@ -1,69 +0,0 @@
-#include <cstring>
-#include <cstdio>
-
-#include "utils/String.h"
-
-String::String() : length(0) {
-    data[0] = '\0';
-}
-
-String::String(const char* str) : length(0) {
-    for(; length < MAX_LENGTH - 1 && str[length] != '\0'; length++) {
-        data[length] = str[length];
-    }
-    data[length] = '\0';
-}
-
-bool String::operator==(const String& other) const {
-    return length == other.length && strcmp(data, other.data) == 0;
-}
-
-bool String::operator!=(const String& other) const {
-    return !(*this == other);
-}
-
-String::operator const char*() const {
-    return data;
-}
-
-char String::operator[](int index) const {
-    return data[index];
-}
-
-int String::getLength() const {
-    return length;
-}
-
-String& String::clear() {
-    length = 0;
-    data[0] = '\0';
-    return *this;
-}
-
-String& String::append(char c) {
-    if(length < MAX_LENGTH - 1) {
-        data[length++] = c;
-        data[length] = '\0';
-    }
-    return *this;
-}
-
-String& String::append(const char* str) {
-    for(int i = 0; length < MAX_LENGTH - 1 && str[i] != '\0'; length++, i++) {
-        data[length] = str[i];
-    }
-    data[length] = '\0';
-    return *this;
-}
-
-String& String::append(int i) {
-    return append("%d", i);
-}
-
-String& String::append(float f) {
-    return append("%.2f", f);
-}
-
-String& String::append(bool b) {
-    return append(b ? "true" : "false");
-}

+ 0 - 40
utils/String.h

@@ -1,40 +0,0 @@
-#ifndef STRING_H
-#define STRING_H
-
-class String final {
-public:
-    String();
-    String(const char* str);
-
-    bool operator==(const String& other) const;
-    bool operator!=(const String& other) const;
-    operator const char*() const;
-    char operator[](int index) const;
-    int getLength() const;
-    String& clear();
-
-    template<typename T>
-    String& append(const char* format, const T& t) {
-        int left = MAX_LENGTH - length;
-        int written = snprintf(data + length, left, format, t);
-        if(written < left) {
-            length += written;
-        } else {
-            length = MAX_LENGTH;
-        }
-        return *this;
-    }
-
-    String& append(char c);
-    String& append(const char* str);
-    String& append(int i);
-    String& append(float f);
-    String& append(bool b);
-
-private:
-    static constexpr int MAX_LENGTH = 256 - sizeof(int);
-    int length;
-    char data[MAX_LENGTH];
-};
-
-#endif

+ 0 - 5
utils/Utils.cpp

@@ -1,5 +0,0 @@
-#include "utils/Utils.h"
-
-float interpolate(float lag, float from, float to) {
-    return from + lag * (to - from);
-}

+ 0 - 6
utils/Utils.h

@@ -1,6 +0,0 @@
-#ifndef UTILS_H
-#define UTILS_H
-
-float interpolate(float lag, float from, float to);
-
-#endif