Completely reorganize file structure, delete unused imports,
clean all imports, surpress useless CLion warnings, clean codemaster
parent
5ebf737f20
commit
4346f45c1c
|
@ -2,6 +2,9 @@
|
|||
<project version="4">
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
<component name="CidrRootsConfiguration">
|
||||
<sourceRoots>
|
||||
<file path="$PROJECT_DIR$/zeus" />
|
||||
</sourceRoots>
|
||||
<excludeRoots>
|
||||
<file path="$PROJECT_DIR$/Libraries" />
|
||||
<file path="$PROJECT_DIR$/lib" />
|
||||
|
|
140
CMakeLists.txt
140
CMakeLists.txt
|
@ -18,80 +18,80 @@ link_directories(lib/glew/lib)
|
|||
|
||||
add_executable(zeus
|
||||
zeus/Main.cpp
|
||||
zeus/engine/graphics/Mesh.cpp
|
||||
zeus/engine/graphics/Mesh.h
|
||||
zeus/engine/PerlinNoise.cpp
|
||||
zeus/engine/PerlinNoise.h
|
||||
zeus/engine/Entity.cpp
|
||||
zeus/engine/Entity.h
|
||||
zeus/engine/graphics/Shader.cpp
|
||||
zeus/engine/graphics/Shader.h
|
||||
zeus/engine/Window.cpp
|
||||
zeus/engine/Window.h
|
||||
zeus/engine/Camera.cpp
|
||||
zeus/engine/Camera.h
|
||||
zeus/engine/graphics/Texture.cpp
|
||||
zeus/engine/graphics/Texture.h
|
||||
zeus/mesh/MeshGenerator.cpp
|
||||
zeus/mesh/MeshGenerator.h
|
||||
zeus/engine/Timer.cpp
|
||||
zeus/engine/Timer.h
|
||||
zeus/blocks/BlockAtlas.cpp
|
||||
zeus/blocks/BlockAtlas.h
|
||||
zeus/blocks/BlockDef.cpp
|
||||
zeus/blocks/BlockDef.h
|
||||
zeus/mesh/MeshPart.cpp
|
||||
zeus/mesh/MeshPart.h
|
||||
zeus/mesh/MeshMod.h
|
||||
zeus/mesh/Vertex.cpp
|
||||
zeus/mesh/Vertex.h
|
||||
zeus/mesh/BlockModel.cpp
|
||||
zeus/mesh/BlockModel.h
|
||||
zeus/engine/TextureAtlas.cpp
|
||||
zeus/engine/TextureAtlas.h
|
||||
zeus/game/world/World.cpp
|
||||
zeus/game/world/World.h
|
||||
zeus/blocks/BlockChunk.cpp
|
||||
zeus/blocks/BlockChunk.h
|
||||
zeus/engine/helpers/ArrayTrans3D.h
|
||||
zeus/mesh/MeshChunk.cpp
|
||||
zeus/mesh/MeshChunk.h
|
||||
zeus/game/GameScene.cpp
|
||||
zeus/game/GameScene.h
|
||||
zeus/engine/graphics/Renderer.cpp
|
||||
zeus/engine/graphics/Renderer.h
|
||||
zeus/lua_api/LuaParser.cpp
|
||||
zeus/lua_api/LuaParser.h
|
||||
zeus/lua_api/l_register_block.cpp
|
||||
zeus/lua_api/l_register_block.h
|
||||
zeus/engine/graphics/TextBuilder.cpp
|
||||
zeus/engine/graphics/TextBuilder.h
|
||||
zeus/engine/graphics/TextBuilder.cpp
|
||||
zeus/engine/graphics/HudText.cpp
|
||||
zeus/engine/graphics/HudText.h
|
||||
zeus/game/gui/DebugGui.cpp
|
||||
zeus/game/gui/DebugGui.h
|
||||
zeus/game/world/Player.cpp
|
||||
zeus/game/world/Player.h
|
||||
zeus/engine/Ray.cpp
|
||||
zeus/engine/Ray.h
|
||||
zeus/lua_api/l_register_blockmodel.cpp
|
||||
zeus/lua_api/l_register_blockmodel.h
|
||||
zeus/lua_api/LuaApi.cpp
|
||||
zeus/lua_api/LuaApi.h
|
||||
zeus/client/engine/graphics/Mesh.cpp
|
||||
zeus/client/engine/graphics/Mesh.h
|
||||
zeus/generic/helpers/PerlinNoise.cpp
|
||||
zeus/generic/helpers/PerlinNoise.h
|
||||
zeus/client/engine/Entity.cpp
|
||||
zeus/client/engine/Entity.h
|
||||
zeus/client/engine/graphics/Shader.cpp
|
||||
zeus/client/engine/graphics/Shader.h
|
||||
zeus/client/engine/Window.cpp
|
||||
zeus/client/engine/Window.h
|
||||
zeus/client/engine/Camera.cpp
|
||||
zeus/client/engine/Camera.h
|
||||
zeus/client/engine/graphics/Texture.cpp
|
||||
zeus/client/engine/graphics/Texture.h
|
||||
zeus/client/graphics/mesh/MeshGenerator.cpp
|
||||
zeus/client/graphics/mesh/MeshGenerator.h
|
||||
zeus/client/engine/Timer.cpp
|
||||
zeus/client/engine/Timer.h
|
||||
zeus/generic/blocks/BlockAtlas.cpp
|
||||
zeus/generic/blocks/BlockAtlas.h
|
||||
zeus/generic/blocks/BlockDef.cpp
|
||||
zeus/generic/blocks/BlockDef.h
|
||||
zeus/generic/blocks/MeshPart.cpp
|
||||
zeus/generic/blocks/MeshPart.h
|
||||
zeus/generic/blocks/MeshMod.h
|
||||
zeus/client/graphics/mesh/Vertex.cpp
|
||||
zeus/client/graphics/mesh/Vertex.h
|
||||
zeus/generic/blocks/BlockModel.cpp
|
||||
zeus/generic/blocks/BlockModel.h
|
||||
zeus/generic/blocks/TextureAtlas.cpp
|
||||
zeus/generic/blocks/TextureAtlas.h
|
||||
zeus/client/gameworld/World.cpp
|
||||
zeus/client/gameworld/World.h
|
||||
zeus/generic/blocks/BlockChunk.cpp
|
||||
zeus/generic/blocks/BlockChunk.h
|
||||
zeus/generic/helpers/ArrayTrans3D.h
|
||||
zeus/client/graphics/mesh/MeshChunk.cpp
|
||||
zeus/client/graphics/mesh/MeshChunk.h
|
||||
zeus/client/graphics/scene/GameScene.cpp
|
||||
zeus/client/graphics/scene/GameScene.h
|
||||
zeus/client/engine/graphics/Renderer.cpp
|
||||
zeus/client/engine/graphics/Renderer.h
|
||||
zeus/client/lua/LuaParser.cpp
|
||||
zeus/client/lua/LuaParser.h
|
||||
zeus/client/lua/l_register_block.cpp
|
||||
zeus/client/lua/l_register_block.h
|
||||
zeus/client/engine/graphics/TextBuilder.cpp
|
||||
zeus/client/engine/graphics/TextBuilder.h
|
||||
zeus/client/engine/graphics/TextBuilder.cpp
|
||||
zeus/client/engine/graphics/HudText.cpp
|
||||
zeus/client/engine/graphics/HudText.h
|
||||
zeus/client/graphics/gui/DebugGui.cpp
|
||||
zeus/client/graphics/gui/DebugGui.h
|
||||
zeus/client/gameworld/Player.cpp
|
||||
zeus/client/gameworld/Player.h
|
||||
zeus/client/engine/Ray.cpp
|
||||
zeus/client/engine/Ray.h
|
||||
zeus/client/lua/l_register_blockmodel.cpp
|
||||
zeus/client/lua/l_register_blockmodel.h
|
||||
zeus/client/lua/LuaApi.cpp
|
||||
zeus/client/lua/LuaApi.h
|
||||
zeus/client/Client.cpp
|
||||
zeus/client/Client.h
|
||||
zeus/client/SceneManager.cpp
|
||||
zeus/client/SceneManager.h
|
||||
zeus/client/Scene.h
|
||||
zeus/client/engine/scene/SceneManager.cpp
|
||||
zeus/client/engine/scene/SceneManager.h
|
||||
zeus/client/engine/scene/Scene.h
|
||||
zeus/client/ClientState.h
|
||||
zeus/game/MenuScene.cpp
|
||||
zeus/game/MenuScene.h
|
||||
zeus/client/graphics/scene/MenuScene.cpp
|
||||
zeus/client/graphics/scene/MenuScene.h
|
||||
zeus/server/Server.cpp
|
||||
zeus/server/Server.h
|
||||
zeus/server/ClientConnection.cpp
|
||||
zeus/server/ClientConnection.h
|
||||
zeus/server/Packet.cpp
|
||||
zeus/server/Packet.h zeus/server/ServerPlayer.cpp zeus/server/ServerPlayer.h zeus/client/ServerConnection.cpp zeus/client/ServerConnection.h)
|
||||
zeus/server/network/ClientConnection.cpp
|
||||
zeus/server/network/ClientConnection.h
|
||||
zeus/generic/network/Packet.cpp
|
||||
zeus/generic/network/Packet.h zeus/server/ServerPlayer.cpp zeus/server/ServerPlayer.h zeus/client/network/ServerConnection.cpp zeus/client/network/ServerConnection.h zeus/client/gameworld/WorldThreadDefs.cpp zeus/client/gameworld/WorldThreadDefs.h)
|
||||
|
||||
target_link_libraries(zeus ${OPENGL_gl_LIBRARY} glfw libGLEW.so pthread lua dl)
|
||||
|
|
|
@ -331,7 +331,7 @@ zeus.register_blockmodel("default:block_side_foliage", {
|
|||
|
||||
**Block Creation**
|
||||
|
||||
The function zeus.register_block creates a block in the game.
|
||||
The function zeus.register_block creates a block in the scene.
|
||||
The first argument is the name of the block, which should be prefixed by the mod name and a colon.
|
||||
The next argument is a table of properties. These are the following accepted properties:
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#pragma clang diagnostic pop
|
||||
|
||||
#include "client/Client.h"
|
||||
#include "server/Server.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::string start = "client";
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
// Created by aurailus on 06/01/19.
|
||||
//
|
||||
|
||||
//TODO: Move the forking code to main
|
||||
#include <zconf.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "Client.h"
|
||||
#include "../server/Packet.h"
|
||||
#include <asio.hpp>
|
||||
|
||||
using asio::ip::udp;
|
||||
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
#ifndef ZEUS_CLIENT_H
|
||||
#define ZEUS_CLIENT_H
|
||||
|
||||
#include "../engine/graphics/Renderer.h"
|
||||
#include "../engine/Timer.h"
|
||||
#include "SceneManager.h"
|
||||
#include "engine/graphics/Renderer.h"
|
||||
#include "ClientState.h"
|
||||
#include "../game/GameScene.h"
|
||||
#include "../game/MenuScene.h"
|
||||
#include "engine/scene/SceneManager.h"
|
||||
|
||||
#include "graphics/scene/GameScene.h"
|
||||
#include "graphics/scene/MenuScene.h"
|
||||
|
||||
#include "engine/Timer.h"
|
||||
|
||||
class Client {
|
||||
public:
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
#ifndef ZEUS_CLIENTSTATE_H
|
||||
#define ZEUS_CLIENTSTATE_H
|
||||
|
||||
|
||||
#include "../engine/graphics/Renderer.h"
|
||||
#include "engine/graphics/Renderer.h"
|
||||
|
||||
struct ClientState {
|
||||
Renderer* renderer;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Created by aurailus on 25/11/18.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "Entity.h"
|
||||
|
||||
Entity::Entity() {
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <glm.hpp>
|
||||
#include <gtc/matrix_transform.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "graphics/Mesh.h"
|
||||
#include "graphics/Texture.h"
|
|
@ -8,7 +8,8 @@
|
|||
#include <vec3.hpp>
|
||||
#include <cmath>
|
||||
#include <glm.hpp>
|
||||
#include "../game/world/Player.h"
|
||||
|
||||
#include "../gameworld/Player.h"
|
||||
|
||||
class Ray {
|
||||
public:
|
|
@ -2,7 +2,6 @@
|
|||
// Created by aurailus on 26/11/18.
|
||||
//
|
||||
|
||||
#include <cstdio>
|
||||
#include "Window.h"
|
||||
|
||||
Window::Window() : Window(800, 600) {};
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <cstdio>
|
||||
|
||||
class Window {
|
||||
public:
|
|
@ -5,7 +5,6 @@
|
|||
//
|
||||
|
||||
#include "HudText.h"
|
||||
#include "TextBuilder.h"
|
||||
|
||||
HudText::HudText() = default;
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
#include "../Entity.h"
|
||||
#include "TextBuilder.h"
|
||||
|
||||
class HudText : public Entity {
|
||||
public:
|
|
@ -6,7 +6,6 @@
|
|||
#define GLPROJECT_MESH_H
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
class Mesh {
|
|
@ -9,6 +9,7 @@
|
|||
#include "../Window.h"
|
||||
#include "../Camera.h"
|
||||
#include "../Entity.h"
|
||||
|
||||
#include <ext.hpp>
|
||||
|
||||
class Renderer {
|
|
@ -2,7 +2,6 @@
|
|||
// Created by aurailus on 26/11/18.
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
#include "Shader.h"
|
||||
|
||||
Shader::Shader() {
|
|
@ -5,12 +5,13 @@
|
|||
#ifndef GLPROJECT_SHADER_H
|
||||
#define GLPROJECT_SHADER_H
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
class Shader {
|
||||
public:
|
||||
Shader();
|
|
@ -2,6 +2,9 @@
|
|||
// Created by aurailus on 25/12/18.
|
||||
//
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "bugprone-integer-division"
|
||||
|
||||
#include "TextBuilder.h"
|
||||
|
||||
Mesh* TextBuilder::build(std::string text) {
|
||||
|
@ -56,3 +59,4 @@ Mesh* TextBuilder::build(std::string text) {
|
|||
return m;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef ZEUS_TEXTBUILDER_H
|
||||
#define ZEUS_TEXTBUILDER_H
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "Mesh.h"
|
||||
|
||||
class TextBuilder {
|
|
@ -2,7 +2,6 @@
|
|||
// Created by aurailus on 29/11/18.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "Texture.h"
|
||||
|
||||
Texture::Texture() = default;
|
|
@ -6,6 +6,7 @@
|
|||
#define GLPROJECT_TEXTURE_H
|
||||
|
||||
#include <glew.h>
|
||||
#include <iostream>
|
||||
#include <stb_image.h>
|
||||
|
||||
class Texture {
|
|
@ -5,7 +5,8 @@
|
|||
#ifndef ZEUS_SCENE_H
|
||||
#define ZEUS_SCENE_H
|
||||
|
||||
#include "ClientState.h"
|
||||
#include "../../ClientState.h"
|
||||
#include <iostream>
|
||||
|
||||
class Scene {
|
||||
public:
|
|
@ -5,9 +5,7 @@
|
|||
#ifndef ZEUS_SCENEMANAGER_H
|
||||
#define ZEUS_SCENEMANAGER_H
|
||||
|
||||
|
||||
#include "Scene.h"
|
||||
#include "ClientState.h"
|
||||
|
||||
class SceneManager {
|
||||
public:
|
|
@ -2,9 +2,7 @@
|
|||
// Created by aurailus on 28/12/18.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "Player.h"
|
||||
#include "../../engine/Timer.h"
|
||||
|
||||
Player::Player() {
|
||||
pos = glm::vec3(0, 0, 0);
|
|
@ -6,8 +6,11 @@
|
|||
#define ZEUS_PLAYER_H
|
||||
|
||||
|
||||
#include "../../engine/Camera.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "World.h"
|
||||
#include "../engine/Camera.h"
|
||||
#include "../engine/Timer.h"
|
||||
|
||||
class Player {
|
||||
public:
|
|
@ -6,8 +6,6 @@
|
|||
#pragma clang diagnostic ignored "-Wmissing-noreturn"
|
||||
|
||||
#include "World.h"
|
||||
#include "../../engine/PerlinNoise.h"
|
||||
#include "../../engine/helpers/ArrayTrans3D.h"
|
||||
|
||||
World::World(BlockAtlas *atlas) {
|
||||
blockAtlas = atlas;
|
||||
|
@ -119,15 +117,8 @@ std::vector<bool>* World::getAdjacentsCull(glm::vec3 pos) {
|
|||
}
|
||||
|
||||
void World::update() {
|
||||
Timer world("World update");
|
||||
|
||||
//Create / Finalize BlockChunks
|
||||
handleChunkGenQueue();
|
||||
|
||||
//Create / Finalize MeshChunks
|
||||
handleMeshGenQueue();
|
||||
|
||||
// game.printElapsedMs();
|
||||
}
|
||||
|
||||
int World::getBlock(glm::vec3 pos) {
|
||||
|
@ -209,7 +200,7 @@ void World::handleChunkGenQueue() {
|
|||
//Function that runs on each ChunkGenThread in the chunk generation threadpool.
|
||||
//Takes a threadDef object which contains a vector of tasks to do, and infinitely loops, completing tasks and
|
||||
//re-inserting them into the vector to be further manipulated by the main thread.
|
||||
void World::chunkGenThread(World::ChunkThreadDef* threadDef) {
|
||||
void World::chunkGenThread(ChunkThreadDef* threadDef) {
|
||||
PerlinNoise p(9);
|
||||
PerlinNoise p2(9);
|
||||
|
||||
|
@ -219,7 +210,7 @@ void World::chunkGenThread(World::ChunkThreadDef* threadDef) {
|
|||
lock.lock();
|
||||
|
||||
//Find the first unfinished task
|
||||
World::ChunkThreadData* data = nullptr;
|
||||
ChunkThreadData* data = nullptr;
|
||||
for (auto iter = threadDef->tasks.begin(); iter != threadDef->tasks.end(); ) {
|
||||
if (!(*iter)->done) {
|
||||
data = (*iter);
|
||||
|
@ -276,7 +267,7 @@ void World::chunkGenThread(World::ChunkThreadDef* threadDef) {
|
|||
lock.unlock();
|
||||
}
|
||||
|
||||
this_thread::sleep_for(0.5ms);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,7 +338,7 @@ void World::meshGenThread(MeshThreadDef* threadDef) {
|
|||
lock.lock();
|
||||
|
||||
//Find the first unfinished task
|
||||
World::MeshThreadData* data = nullptr;
|
||||
MeshThreadData* data = nullptr;
|
||||
for (auto iter = threadDef->tasks.begin(); iter != threadDef->tasks.end(); ) {
|
||||
if (!(*iter)->done) {
|
||||
data = (*iter);
|
||||
|
@ -368,63 +359,10 @@ void World::meshGenThread(MeshThreadDef* threadDef) {
|
|||
lock.unlock();
|
||||
}
|
||||
|
||||
this_thread::sleep_for(0.5ms);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<glm::vec3, MeshChunk*, World::vec3cmp>* World::getMeshChunks() {
|
||||
return &meshChunks;
|
||||
}
|
||||
|
||||
//Constructors and Destructors for the MeshThreadData / ChunkThreadData structs.
|
||||
|
||||
World::ChunkThreadData::ChunkThreadData(glm::vec3 pos, BlockAtlas *atlas) {
|
||||
this->pos = pos;
|
||||
this->atlas = atlas;
|
||||
this->done = false;
|
||||
this->chunk = nullptr;
|
||||
}
|
||||
|
||||
World::ChunkThreadDef::ChunkThreadDef() {
|
||||
thread = new std::thread(chunkGenThread, this);
|
||||
|
||||
sched_param sch_params{};
|
||||
sch_params.sched_priority = 1;
|
||||
pthread_setschedparam(thread->native_handle(), SCHED_RR, &sch_params);
|
||||
|
||||
thread->detach();
|
||||
}
|
||||
|
||||
World::ChunkThreadDef::~ChunkThreadDef() {
|
||||
delete thread;
|
||||
}
|
||||
|
||||
World::MeshThreadData::MeshThreadData(glm::vec3 pos, BlockChunk *chunk, std::vector<bool>* adjacents, BlockAtlas *atlas) {
|
||||
this->pos = pos;
|
||||
this->chunk = chunk;
|
||||
this->atlas = atlas;
|
||||
this->adjacents = adjacents;
|
||||
this->done = false;
|
||||
this->vertices = new std::vector<float>();
|
||||
this->indices = new std::vector<unsigned int>();
|
||||
}
|
||||
|
||||
World::MeshThreadData::~MeshThreadData() {
|
||||
delete vertices;
|
||||
delete indices;
|
||||
delete adjacents;
|
||||
}
|
||||
|
||||
World::MeshThreadDef::MeshThreadDef() {
|
||||
thread = new std::thread(meshGenThread, this);
|
||||
|
||||
sched_param sch_params{};
|
||||
sch_params.sched_priority = 1;
|
||||
pthread_setschedparam(thread->native_handle(), SCHED_RR, &sch_params);
|
||||
|
||||
thread->detach();
|
||||
}
|
||||
|
||||
World::MeshThreadDef::~MeshThreadDef() {
|
||||
delete thread;
|
||||
}
|
|
@ -5,25 +5,22 @@
|
|||
#ifndef GLPROJECT_WORLD_H
|
||||
#define GLPROJECT_WORLD_H
|
||||
|
||||
#include <unordered_set>
|
||||
#include <iostream>
|
||||
#include <gtc/type_ptr.hpp>
|
||||
#include <vec3.hpp>
|
||||
#include <thread>
|
||||
#include <unordered_set>
|
||||
#include <bits/unordered_map.h>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <vec3.hpp>
|
||||
#include <gtc/type_ptr.hpp>
|
||||
|
||||
#include "../../blocks/BlockChunk.h"
|
||||
#include "../../mesh/MeshChunk.h"
|
||||
#include "../../blocks/BlockAtlas.h"
|
||||
#include "WorldThreadDefs.h"
|
||||
#include "../../generic/helpers/PerlinNoise.h"
|
||||
#include "../../generic/helpers/ArrayTrans3D.h"
|
||||
#include "../../generic/blocks/BlockAtlas.h"
|
||||
#include "../../generic/blocks/BlockChunk.h"
|
||||
#include "../graphics/mesh/MeshChunk.h"
|
||||
|
||||
class World {
|
||||
private:
|
||||
//Predeclare structs
|
||||
struct MeshThreadData;
|
||||
struct MeshThreadDef;
|
||||
struct ChunkThreadData;
|
||||
struct ChunkThreadDef;
|
||||
public:
|
||||
//Hashing function for glm::vec3 in maps and lists
|
||||
struct vec3cmp {
|
||||
|
@ -63,7 +60,7 @@ public:
|
|||
}
|
||||
|
||||
static glm::vec3 chunkVec(glm::vec3 globalVec) {
|
||||
return glm::vec3(floor(globalVec.x / 16), floor(globalVec.y / 16), floor(globalVec.z / 16));
|
||||
return glm::vec3(std::floor(globalVec.x / 16), std::floor(globalVec.y / 16), std::floor(globalVec.z / 16));
|
||||
}
|
||||
|
||||
static glm::vec3 localVec(glm::vec3 globalVec) {
|
||||
|
@ -113,53 +110,6 @@ private:
|
|||
std::vector<MeshThreadData*> finishedMesh;
|
||||
|
||||
BlockAtlas* blockAtlas;
|
||||
|
||||
//Structs for the thread pool implementations
|
||||
struct MeshThreadData {
|
||||
MeshThreadData(glm::vec3 pos, BlockChunk* chunk, std::vector<bool>* adjacents, BlockAtlas* atlas);
|
||||
|
||||
glm::vec3 pos;
|
||||
BlockChunk* chunk;
|
||||
BlockAtlas* atlas;
|
||||
std::vector<bool>* adjacents;
|
||||
|
||||
bool done;
|
||||
|
||||
std::vector<float>* vertices;
|
||||
std::vector<unsigned int>* indices;
|
||||
|
||||
~MeshThreadData();
|
||||
};
|
||||
|
||||
struct MeshThreadDef {
|
||||
MeshThreadDef();
|
||||
|
||||
std::thread* thread;
|
||||
std::mutex lock;
|
||||
std::vector<MeshThreadData*> tasks;
|
||||
|
||||
~MeshThreadDef();
|
||||
};
|
||||
|
||||
struct ChunkThreadData {
|
||||
ChunkThreadData(glm::vec3 pos, BlockAtlas* atlas);
|
||||
|
||||
glm::vec3 pos;
|
||||
BlockAtlas* atlas;
|
||||
|
||||
bool done;
|
||||
BlockChunk* chunk;
|
||||
};
|
||||
|
||||
struct ChunkThreadDef {
|
||||
ChunkThreadDef();
|
||||
|
||||
std::thread* thread;
|
||||
std::mutex lock;
|
||||
std::vector<ChunkThreadData*> tasks;
|
||||
|
||||
~ChunkThreadDef();
|
||||
};
|
||||
};
|
||||
|
||||
#endif //GLPROJECT_WORLD_H
|
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// Created by aurailus on 22/01/19.
|
||||
//
|
||||
|
||||
#include "WorldThreadDefs.h"
|
||||
#include "World.h"
|
||||
|
||||
ChunkThreadData::ChunkThreadData(glm::vec3 pos, BlockAtlas *atlas) {
|
||||
this->pos = pos;
|
||||
this->atlas = atlas;
|
||||
this->done = false;
|
||||
this->chunk = nullptr;
|
||||
}
|
||||
|
||||
ChunkThreadDef::ChunkThreadDef() {
|
||||
thread = new std::thread(World::chunkGenThread, this);
|
||||
|
||||
sched_param sch_params{};
|
||||
sch_params.sched_priority = 1;
|
||||
pthread_setschedparam(thread->native_handle(), SCHED_RR, &sch_params);
|
||||
|
||||
thread->detach();
|
||||
}
|
||||
|
||||
ChunkThreadDef::~ChunkThreadDef() {
|
||||
delete thread;
|
||||
}
|
||||
|
||||
MeshThreadData::MeshThreadData(glm::vec3 pos, BlockChunk *chunk, std::vector<bool>* adjacents, BlockAtlas *atlas) {
|
||||
this->pos = pos;
|
||||
this->chunk = chunk;
|
||||
this->atlas = atlas;
|
||||
this->adjacents = adjacents;
|
||||
this->done = false;
|
||||
this->vertices = new std::vector<float>();
|
||||
this->indices = new std::vector<unsigned int>();
|
||||
}
|
||||
|
||||
MeshThreadData::~MeshThreadData() {
|
||||
delete vertices;
|
||||
delete indices;
|
||||
delete adjacents;
|
||||
}
|
||||
|
||||
MeshThreadDef::MeshThreadDef() {
|
||||
thread = new std::thread(World::meshGenThread, this);
|
||||
|
||||
sched_param sch_params{};
|
||||
sch_params.sched_priority = 1;
|
||||
pthread_setschedparam(thread->native_handle(), SCHED_RR, &sch_params);
|
||||
|
||||
thread->detach();
|
||||
}
|
||||
|
||||
MeshThreadDef::~MeshThreadDef() {
|
||||
delete thread;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// Created by aurailus on 22/01/19.
|
||||
//
|
||||
|
||||
#ifndef ZEUS_WORLDTHREADDEFS_H
|
||||
#define ZEUS_WORLDTHREADDEFS_H
|
||||
|
||||
#include <vec3.hpp>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
#include "../../generic/blocks/BlockChunk.h"
|
||||
#include "../../generic/blocks/BlockAtlas.h"
|
||||
|
||||
//Structs for storing the threads used in World, and passing data to and from them.
|
||||
|
||||
struct MeshThreadData {
|
||||
MeshThreadData(glm::vec3 pos, BlockChunk* chunk, std::vector<bool>* adjacents, BlockAtlas* atlas);
|
||||
|
||||
glm::vec3 pos;
|
||||
BlockChunk* chunk;
|
||||
BlockAtlas* atlas;
|
||||
std::vector<bool>* adjacents;
|
||||
|
||||
bool done;
|
||||
|
||||
std::vector<float>* vertices;
|
||||
std::vector<unsigned int>* indices;
|
||||
|
||||
~MeshThreadData();
|
||||
};
|
||||
|
||||
struct MeshThreadDef {
|
||||
MeshThreadDef();
|
||||
|
||||
std::thread* thread;
|
||||
std::mutex lock;
|
||||
std::vector<MeshThreadData*> tasks;
|
||||
|
||||
~MeshThreadDef();
|
||||
};
|
||||
|
||||
struct ChunkThreadData {
|
||||
ChunkThreadData(glm::vec3 pos, BlockAtlas* atlas);
|
||||
|
||||
glm::vec3 pos;
|
||||
BlockAtlas* atlas;
|
||||
|
||||
bool done;
|
||||
BlockChunk* chunk;
|
||||
};
|
||||
|
||||
struct ChunkThreadDef {
|
||||
ChunkThreadDef();
|
||||
|
||||
std::thread* thread;
|
||||
std::mutex lock;
|
||||
std::vector<ChunkThreadData*> tasks;
|
||||
|
||||
~ChunkThreadDef();
|
||||
};
|
||||
|
||||
|
||||
#endif //ZEUS_WORLDTHREADDEFS_H
|
|
@ -48,7 +48,7 @@ void DebugGui::fpsHistUpdate() {
|
|||
|
||||
for (double num : fpsHistory) {
|
||||
float h = (float)num * height;
|
||||
float sev = round(9 - (float)max(60 - num, 0.0)/6) / 10.0f;
|
||||
float sev = (float)std::round(9 - std::max(60 - num, 0.0)/6) / 10.0f;
|
||||
|
||||
auto columnVerts = std::vector<float> {
|
||||
xOffset, -h, 0, sev , sev, 0, 0, 0,
|
||||
|
@ -125,6 +125,7 @@ void DebugGui::update(Player* player, World* world, Window* window, BlockAtlas*
|
|||
fpsText->set(string_double(fps) + " FPS");
|
||||
fpsHistUpdate();
|
||||
|
||||
using namespace std; //Temporary, delete when refactoring this
|
||||
playerText->set(
|
||||
"Chunk: " + to_string(world->lastGenUpdates) + ", Mesh: " + to_string(world->lastMeshUpdates) + "\n" +
|
||||
"W: " + to_string((int)player->getPos()->x) + "," + to_string((int)player->getPos()->y) + "," + to_string((int)player->getPos()->z) + "\n" +
|
|
@ -6,10 +6,9 @@
|
|||
#define ZEUS_DEBUGGUI_H
|
||||
|
||||
#include "../../engine/graphics/HudText.h"
|
||||
#include "../world/World.h"
|
||||
#include "../world/Player.h"
|
||||
#include "../../engine/Window.h"
|
||||
#include "../../engine/Ray.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
class DebugGui {
|
|
@ -6,8 +6,7 @@
|
|||
#define GLPROJECT_MESHCHUNK_H
|
||||
|
||||
|
||||
#include "../blocks/BlockChunk.h"
|
||||
#include "../engine/Entity.h"
|
||||
#include "../../engine/Entity.h"
|
||||
#include "MeshGenerator.h"
|
||||
|
||||
class MeshChunk : public Entity {
|
|
@ -3,7 +3,6 @@
|
|||
//
|
||||
|
||||
#include "MeshGenerator.h"
|
||||
#include "../engine/helpers/ArrayTrans3D.h"
|
||||
|
||||
MeshGenerator::MeshGenerator() {
|
||||
indOffset = 0;
|
|
@ -2,18 +2,25 @@
|
|||
// Created by aurailus on 01/12/18.
|
||||
//
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
||||
|
||||
#ifndef GLPROJECT_MESHGENERATOR_H
|
||||
#define GLPROJECT_MESHGENERATOR_H
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
|
||||
#include "BlockModel.h"
|
||||
#include <vector>
|
||||
#include <gtx/normal.hpp>
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
#include "../engine/Timer.h"
|
||||
#include "../blocks/BlockAtlas.h"
|
||||
#include "../blocks/BlockChunk.h"
|
||||
|
||||
#include "../../engine/Timer.h"
|
||||
#include "../../../generic/blocks/BlockDef.h"
|
||||
#include "../../../generic/blocks/BlockChunk.h"
|
||||
#include "../../../generic/blocks/BlockAtlas.h"
|
||||
#include "../../../generic/helpers/ArrayTrans3D.h"
|
||||
#include "../../../generic/blocks/BlockModel.h"
|
||||
#include "Vertex.h"
|
||||
|
||||
const int CHUNK_SIZE = 16;
|
||||
|
||||
|
@ -33,3 +40,5 @@ private:
|
|||
};
|
||||
|
||||
#endif //GLPROJECT_MESHGENERATOR_H
|
||||
|
||||
#pragma clang diagnostic pop
|
|
@ -3,8 +3,10 @@
|
|||
//
|
||||
|
||||
#include "GameScene.h"
|
||||
#include "../lua_api/l_register_block.h"
|
||||
#include "../lua_api/l_register_blockmodel.h"
|
||||
|
||||
//TODO: Fix this
|
||||
#include "../../lua/l_register_block.h"
|
||||
#include "../../lua/l_register_blockmodel.h"
|
||||
|
||||
GameScene::GameScene(ClientState* state) : Scene(state) {
|
||||
server = new ServerConnection("127.0.0.1", 12345);
|
||||
|
@ -22,7 +24,7 @@ GameScene::GameScene(ClientState* state) : Scene(state) {
|
|||
|
||||
p.doFile("../lua/file.lua");
|
||||
|
||||
//The game requires the blockAtlas for meshing and handling inputs.
|
||||
//The scene requires the blockAtlas for meshing and handling inputs.
|
||||
world = new World(blockAtlas);
|
||||
|
||||
int SIZE = 12;
|
|
@ -6,20 +6,19 @@
|
|||
#define SRC_GAMEWORLD_H
|
||||
|
||||
|
||||
#include "world/World.h"
|
||||
#include "../engine/Camera.h"
|
||||
#include "../engine/Window.h"
|
||||
#include "../engine/PerlinNoise.h"
|
||||
#include "../engine/graphics/Renderer.h"
|
||||
#include "../engine/helpers/ArrayTrans3D.h"
|
||||
#include "../lua_api/LuaParser.h"
|
||||
#include "../engine/graphics/HudText.h"
|
||||
#include "gui/DebugGui.h"
|
||||
#include "world/Player.h"
|
||||
#include "../engine/Ray.h"
|
||||
#include "../client/Scene.h"
|
||||
#include "../server/Server.h"
|
||||
#include "../client/ServerConnection.h"
|
||||
#include "../../engine/scene/Scene.h"
|
||||
#include "../../engine/graphics/Renderer.h"
|
||||
#include "../gui/DebugGui.h"
|
||||
|
||||
#include "../../lua/LuaParser.h"
|
||||
|
||||
#include "../../gameworld/World.h"
|
||||
#include "../../gameworld/Player.h"
|
||||
|
||||
#include "../../network/ServerConnection.h"
|
||||
|
||||
#include "../../../generic/blocks/TextureAtlas.h"
|
||||
#include "../../../generic/blocks/BlockAtlas.h"
|
||||
|
||||
class GameScene : public Scene {
|
||||
public:
|
||||
|
@ -37,7 +36,7 @@ public:
|
|||
TextureAtlas* textureAtlas;
|
||||
BlockAtlas* blockAtlas;
|
||||
|
||||
//Entities to be drawn with world shaders
|
||||
//Entities to be drawn with gameworld shaders
|
||||
std::vector<Entity*> entities;
|
||||
|
||||
//GUI Related things
|
|
@ -3,7 +3,6 @@
|
|||
//
|
||||
|
||||
#include "MenuScene.h"
|
||||
#include "../engine/graphics/HudText.h"
|
||||
|
||||
MenuScene::MenuScene(ClientState *state) : Scene(state) {
|
||||
fontTexture = new Texture((char*)"../tex/gui/font.png");
|
|
@ -6,8 +6,9 @@
|
|||
#define ZEUS_MENUSCENE_H
|
||||
|
||||
|
||||
#include "../client/ClientState.h"
|
||||
#include "../client/Scene.h"
|
||||
#include "../../ClientState.h"
|
||||
#include "../../engine/scene/Scene.h"
|
||||
#include "../../engine/graphics/HudText.h"
|
||||
|
||||
class MenuScene : public Scene {
|
||||
public:
|
|
@ -5,9 +5,8 @@
|
|||
#ifndef ZEUS_LUAAPI_H
|
||||
#define ZEUS_LUAAPI_H
|
||||
|
||||
|
||||
#include "../game/GameScene.h"
|
||||
#include "LuaParser.h"
|
||||
#include "../graphics/scene/GameScene.h"
|
||||
|
||||
class LuaApi {
|
||||
public:
|
|
@ -2,13 +2,8 @@
|
|||
// Created by aurailus on 17/12/18.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "LuaParser.h"
|
||||
|
||||
//double LuaParser::average(int a, int b, int c) {
|
||||
// return (a + b + c) / (double)(3);
|
||||
//}
|
||||
|
||||
void LuaParser::init() {
|
||||
L.open_libraries(sol::lib::base, sol::lib::package, sol::lib::string);
|
||||
|
|
@ -5,11 +5,9 @@
|
|||
#ifndef ZEUS_LUAPARSER_H
|
||||
#define ZEUS_LUAPARSER_H
|
||||
|
||||
//Should give tracebacks if there's a segfault
|
||||
//#define SOL_CHECK_ARGUMENTS
|
||||
|
||||
#include <string>
|
||||
#include <sol.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class LuaParser {
|
||||
public:
|
||||
|
@ -29,4 +27,4 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#endif //ZEUS_LUAPARSER_H
|
||||
#endif //ZEUS_LUAPARSER_H
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "l_register_block.h"
|
||||
|
||||
//Add a block to the game.
|
||||
//Add a block to the scene.
|
||||
//The first variable is the identifer, which is used internally and by mods to reference the block.
|
||||
//The second variable is a table containing all the block's data. This is used to define properties of the nodeblock.
|
||||
void l_register_block::api(std::string identifier, sol::table data) {
|
|
@ -6,10 +6,12 @@
|
|||
#define ZEUS_SERVERCONNECTION_H
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vec3.hpp>
|
||||
#include <asio.hpp>
|
||||
|
||||
#include "../../generic/network/Packet.h"
|
||||
#include "../engine/Timer.h"
|
||||
#include "../server/Packet.h"
|
||||
|
||||
struct ServerConfig {
|
||||
glm::vec3 playerPos;
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
#include "BlockAtlas.h"
|
||||
|
||||
BlockAtlas::BlockAtlas() {
|
||||
textureAtlas = nullptr;
|
||||
}
|
||||
|
||||
BlockAtlas::BlockAtlas(TextureAtlas *textureAtlas) {
|
||||
this->textureAtlas = textureAtlas;
|
||||
}
|
|
@ -6,12 +6,13 @@
|
|||
#define GLPROJECT_BLOCKATLAS_H
|
||||
|
||||
|
||||
#include "../mesh/BlockModel.h"
|
||||
#include <vector>
|
||||
#include "BlockDef.h"
|
||||
#include "TextureAtlas.h"
|
||||
|
||||
class BlockAtlas {
|
||||
public:
|
||||
BlockAtlas() = default;
|
||||
BlockAtlas();
|
||||
explicit BlockAtlas(TextureAtlas* textureAtlas);
|
||||
|
||||
void registerBlock(BlockDef* def);
|
|
@ -2,9 +2,7 @@
|
|||
// Created by aurailus on 14/12/18.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "BlockChunk.h"
|
||||
#include "../engine/helpers/ArrayTrans3D.h"
|
||||
|
||||
BlockChunk::BlockChunk(std::vector<int>* blocks) {
|
||||
this->blocks = blocks;
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <vec3.hpp>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "../helpers/ArrayTrans3D.h"
|
||||
|
||||
class BlockChunk {
|
||||
public:
|
|
@ -1,5 +1,3 @@
|
|||
#include <utility>
|
||||
|
||||
//
|
||||
// Created by aurailus on 02/12/18.
|
||||
//
|
|
@ -5,7 +5,8 @@
|
|||
#ifndef GLPROJECT_BLOCKDEF_H
|
||||
#define GLPROJECT_BLOCKDEF_H
|
||||
|
||||
#include "../mesh/BlockModel.h"
|
||||
#include <string>
|
||||
#include "BlockModel.h"
|
||||
|
||||
class BlockDef {
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
// Created by aurailus on 04/12/18.
|
||||
//
|
||||
|
||||
#include <utility>
|
||||
#include "BlockModel.h"
|
||||
|
||||
BlockModel::BlockModel(bool culls, bool visible) {
|
|
@ -8,6 +8,7 @@
|
|||
#include <vector>
|
||||
#include <sol.hpp>
|
||||
#include "MeshPart.h"
|
||||
#include "../../client/graphics/mesh/Vertex.h"
|
||||
|
||||
using namespace std; //Just to preserve my sanity
|
||||
|
|
@ -2,17 +2,21 @@
|
|||
// Created by aurailus on 02/12/18.
|
||||
//
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
||||
|
||||
#ifndef GLPROJECT_MESHPART_H
|
||||
#define GLPROJECT_MESHPART_H
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
|
||||
#include <vector>
|
||||
#include <vec4.hpp>
|
||||
#include <gtx/normal.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include "MeshMod.h"
|
||||
#include "Vertex.h"
|
||||
#include "../engine/TextureAtlas.h"
|
||||
#include "TextureAtlas.h"
|
||||
#include "../../client/graphics/mesh/Vertex.h"
|
||||
|
||||
class MeshVertexIter;
|
||||
class MeshIndexIter;
|
||||
|
@ -67,3 +71,5 @@ private:
|
|||
|
||||
|
||||
#endif //GLPROJECT_MESHPART_H
|
||||
|
||||
#pragma clang diagnostic pop
|
|
@ -2,6 +2,9 @@
|
|||
// Created by aurailus on 06/12/18.
|
||||
//
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
||||
|
||||
#define CUTE_FILES_IMPLEMENTATION
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
|
||||
|
@ -145,4 +148,5 @@ glm::vec4* TextureAtlas::getUVs(std::string* texture) {
|
|||
throw std::exception();
|
||||
}
|
||||
return &textures.at(*texture);
|
||||
}
|
||||
}
|
||||
#pragma clang diagnostic pop
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
#include <glew.h>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <vec4.hpp>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#include "graphics/Texture.h"
|
||||
#include "../../client/engine/graphics/Texture.h"
|
||||
|
||||
class TextureAtlas {
|
||||
public:
|
|
@ -2,6 +2,9 @@
|
|||
// Created by aurailus on 14/12/18.
|
||||
//
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "bugprone-integer-division"
|
||||
|
||||
#ifndef GLPROJECT_ARRAYTRANS3D_H
|
||||
#define GLPROJECT_ARRAYTRANS3D_H
|
||||
|
||||
|
@ -37,3 +40,5 @@ public:
|
|||
|
||||
|
||||
#endif //GLPROJECT_ARRAYTRANS3D_H
|
||||
|
||||
#pragma clang diagnostic pop
|
|
@ -1,15 +1,13 @@
|
|||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
|
||||
#include "PerlinNoise.h"
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
// THIS IS A DIRECT TRANSLATION TO C++11 FROM THE REFERENCE
|
||||
// JAVA IMPLEMENTATION OF THE IMPROVED PERLIN FUNCTION (see http://mrl.nyu.edu/~perlin/noise/)
|
||||
// THE ORIGINAL JAVA IMPLEMENTATION IS COPYRIGHT 2002 KEN PERLIN
|
||||
|
||||
// I ADDED AN EXTRA METHOD THAT GENERATES A NEW PERMUTATION VECTOR (THIS IS NOT PRESENT IN THE ORIGINAL IMPLEMENTATION)
|
||||
|
||||
// Initialize with the reference values for the permutation vector
|
||||
PerlinNoise::PerlinNoise() {
|
||||
|
||||
|
@ -92,3 +90,5 @@ double PerlinNoise::grad(int hash, double x, double y, double z) {
|
|||
v = h < 4 ? y : h == 12 || h == 14 ? x : z;
|
||||
return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
|
@ -1,3 +1,6 @@
|
|||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
|
||||
// THIS CLASS IS A TRANSLATION TO C++11 FROM THE REFERENCE
|
||||
|
||||
// JAVA IMPLEMENTATION OF THE IMPROVED PERLIN FUNCTION (see http://mrl.nyu.edu/~perlin/noise/)
|
||||
|
@ -8,6 +11,10 @@
|
|||
#define PERLINNOISE_H
|
||||
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
class PerlinNoise {
|
||||
// The permutation vector
|
||||
|
@ -16,7 +23,7 @@ public:
|
|||
// Initialize with the reference values for the permutation vector
|
||||
PerlinNoise();
|
||||
// Generate a new permutation vector based on the value of seed
|
||||
PerlinNoise(unsigned int seed);
|
||||
explicit PerlinNoise(unsigned int seed);
|
||||
// Get a noise value, for 2D images z can have any value
|
||||
double noise(double x, double y, double z);
|
||||
private:
|
||||
|
@ -26,3 +33,5 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic pop
|
|
@ -2,7 +2,6 @@
|
|||
// Created by aurailus on 10/01/19.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "Packet.h"
|
||||
|
||||
Packet::Packet(Packet::PacketType p) {
|
|
@ -8,6 +8,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <asio.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class Packet {
|
||||
public:
|
|
@ -3,7 +3,6 @@
|
|||
//
|
||||
|
||||
#include "Server.h"
|
||||
#include "../game/world/Player.h"
|
||||
|
||||
Server::Server() = default;
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include "../engine/Timer.h"
|
||||
#include "ClientConnection.h"
|
||||
#include "Packet.h"
|
||||
#include "ServerPlayer.h"
|
||||
#include <iostream>
|
||||
#include <asio.hpp>
|
||||
#include "ServerPlayer.h"
|
||||
#include "network/ClientConnection.h"
|
||||
#include "../generic/network/Packet.h"
|
||||
#include "../client/engine/Timer.h"
|
||||
|
||||
using asio::ip::udp;
|
||||
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
#include "ServerPlayer.h"
|
||||
|
||||
ServerPlayer::ServerPlayer() {
|
||||
this->connection = nullptr;
|
||||
}
|
||||
|
||||
ServerPlayer::ServerPlayer(ClientConnection *connection, glm::vec3 pos) {
|
||||
this->pos = pos;
|
||||
this->connection = connection;
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
|
||||
|
||||
#include <vec3.hpp>
|
||||
#include "ClientConnection.h"
|
||||
#include "network/ClientConnection.h"
|
||||
|
||||
class ServerPlayer {
|
||||
public:
|
||||
ServerPlayer() = default;
|
||||
ServerPlayer();
|
||||
ServerPlayer(ClientConnection* connection, glm::vec3 pos);
|
||||
|
||||
ClientConnection* connection;
|
||||
glm::vec3 pos;
|
||||
glm::vec3 pos = glm::vec3(0, 0, 0);
|
||||
|
||||
std::vector<glm::vec3> requestedChunks;
|
||||
};
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#ifndef ZEUS_CLIENTCONNECTION_H
|
||||
#define ZEUS_CLIENTCONNECTION_H
|
||||
|
||||
|
||||
#include <asio.hpp>
|
||||
|
||||
class ClientConnection {
|
Loading…
Reference in New Issue