Gitlab CI
This commit is contained in:
parent
f7c2f7069e
commit
f5c46d5b46
|
@ -0,0 +1,29 @@
|
||||||
|
image: gcc
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get install -y --no-install-recommends cmake libssl-dev libvulkan-dev xorg-dev doxygen graphviz
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- mkdir build # compile
|
||||||
|
- cd build
|
||||||
|
- cmake ..
|
||||||
|
- make -j2 univerxel univerxel-client univerxel-server docs
|
||||||
|
- mkdir -p ../out/full ../out/client ../out/server/content # package artifacts
|
||||||
|
- cp -r univerxel content ../out/full
|
||||||
|
- cp -r univerxel-client content ../out/client
|
||||||
|
- rm ../out/client/content/cert.pem ../out/client/content/key.pem ../out/client/content/zstd.dict
|
||||||
|
- cp univerxel-server ../out/server
|
||||||
|
- cp content/cert.pem content/key.pem content/zstd.dict ../out/server/content
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- out/full
|
||||||
|
- out/client
|
||||||
|
- out/server
|
||||||
|
- build/docs
|
||||||
|
expire_in: 1 week
|
||||||
|
# cache:
|
||||||
|
# paths:
|
||||||
|
# - "*.o"
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* \file server.cpp
|
* \file client.cpp
|
||||||
* \brief Univerxel client
|
* \brief Univerxel client
|
||||||
* \author Maelys Bois
|
* \author Maelys Bois
|
||||||
* \version 0.0.1
|
* \version 0.0.1
|
||||||
|
|
|
@ -24,6 +24,7 @@ inline std::string toHexa(const glm::vec4& rgb) {
|
||||||
return sstr.str();
|
return sstr.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Client side configuration
|
||||||
struct options {
|
struct options {
|
||||||
public:
|
public:
|
||||||
options(toml::node_view<toml::node> config) {
|
options(toml::node_view<toml::node> config) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ enum queue: uint8_t {
|
||||||
count
|
count
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Network client
|
||||||
class Client final: public Context, public Connection {
|
class Client final: public Context, public Connection {
|
||||||
public:
|
public:
|
||||||
Client(const address& ct,
|
Client(const address& ct,
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
class Window;
|
class Window;
|
||||||
class Camera;
|
class Camera;
|
||||||
|
/// Graphics pipeline
|
||||||
namespace render {
|
namespace render {
|
||||||
class Model;
|
class Model;
|
||||||
class LodModel;
|
class LodModel;
|
||||||
|
|
|
@ -323,7 +323,7 @@ UI::Actions UI::draw(config::client::options &options, state::state &state, cons
|
||||||
const auto flags = ImGuiInputTextFlags_EnterReturnsTrue;
|
const auto flags = ImGuiInputTextFlags_EnterReturnsTrue;
|
||||||
// | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory;
|
// | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory;
|
||||||
ImGui::GetColumnWidth();
|
ImGui::GetColumnWidth();
|
||||||
if (ImGui::InputText("", state.console.buffer.data(), state.console.buffer.size(), flags /*, TODO: callback, context*/) && strlen(state.console.buffer.data()) > 0)
|
if (ImGui::InputText("", state.console.buffer.data(), state.console.buffer.size(), flags /*TODO: completion (, callback, context)*/) && strlen(state.console.buffer.data()) > 0)
|
||||||
actions |= Actions::Message;
|
actions |= Actions::Message;
|
||||||
|
|
||||||
// Auto-focus on window apparition
|
// Auto-focus on window apparition
|
||||||
|
|
|
@ -65,7 +65,7 @@ std::optional<Image::properties> Image::Read(const std::string& imagepath, std::
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
//FIXME: miplevels with size < block size (2 last) are corrupted
|
//WONT-FIX: miplevels with size < block size (2 last) are corrupted
|
||||||
const uint maxMipmapLevels = 1 + std::floor(std::log2(std::max(info.size.height, info.size.width))) - 2;
|
const uint maxMipmapLevels = 1 + std::floor(std::log2(std::max(info.size.height, info.size.width))) - 2;
|
||||||
info.mipmapLevels = std::min(maxMipmapLevels, info.mipmapLevels);
|
info.mipmapLevels = std::min(maxMipmapLevels, info.mipmapLevels);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "api/Images.hpp"
|
#include "api/Images.hpp"
|
||||||
|
|
||||||
struct windowOptions;
|
struct windowOptions;
|
||||||
|
/// OpenGL graphics pipeline
|
||||||
namespace render::gl {
|
namespace render::gl {
|
||||||
|
|
||||||
/// OpenGL rendering
|
/// OpenGL rendering
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace render {
|
||||||
namespace render::gl {
|
namespace render::gl {
|
||||||
class Renderer;
|
class Renderer;
|
||||||
}
|
}
|
||||||
/// OpenGL programs
|
|
||||||
namespace pass {
|
namespace pass {
|
||||||
/// OpenGL shaders pipeline
|
/// OpenGL shaders pipeline
|
||||||
class Program {
|
class Program {
|
||||||
|
|
|
@ -188,7 +188,7 @@ bool Renderer::Load(Window& window, const renderOptions& opt, const windowOption
|
||||||
appInfo.applicationVersion = VK_MAKE_VERSION(0, 0, 1);
|
appInfo.applicationVersion = VK_MAKE_VERSION(0, 0, 1);
|
||||||
appInfo.pEngineName = "No Engine";
|
appInfo.pEngineName = "No Engine";
|
||||||
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
|
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||||
appInfo.apiVersion = VK_API_VERSION_1_2;
|
appInfo.apiVersion = VK_MAKE_VERSION(1, 2, 0);
|
||||||
|
|
||||||
VkInstanceCreateInfo createInfo{};
|
VkInstanceCreateInfo createInfo{};
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "forward.hpp"
|
#include "forward.hpp"
|
||||||
|
|
||||||
struct windowOptions;
|
struct windowOptions;
|
||||||
|
/// Vulkan graphics pipeline
|
||||||
namespace render::vk {
|
namespace render::vk {
|
||||||
class Allocator;
|
class Allocator;
|
||||||
class SwapChain;
|
class SwapChain;
|
||||||
|
|
|
@ -40,7 +40,7 @@ void DistantUniverse::update(voxel_pos pos, float deltaTime) {
|
||||||
if (glm::length2(diff - it_c->first) > glm::pow2(keepDistance)) {
|
if (glm::length2(diff - it_c->first) > glm::pow2(keepDistance)) {
|
||||||
it_c = chunks.erase(it_c);
|
it_c = chunks.erase(it_c);
|
||||||
} else {
|
} else {
|
||||||
if(const auto neighbors = std::dynamic_pointer_cast<world::client::EdittableChunk>(it_c->second)->update(deltaTime, true /*FIXME: rnd from contouring*/)) {
|
if(const auto neighbors = std::dynamic_pointer_cast<world::client::EdittableChunk>(it_c->second)->update(deltaTime, true /*MAYBE: random update*/)) {
|
||||||
contouring->onUpdate(std::make_pair(area.first, it_c->first), diff, chunks, neighbors.value());
|
contouring->onUpdate(std::make_pair(area.first, it_c->first), diff, chunks, neighbors.value());
|
||||||
}
|
}
|
||||||
++it_c;
|
++it_c;
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
|
|
||||||
namespace data {
|
namespace data {
|
||||||
|
|
||||||
|
/// File loader
|
||||||
class file_content: public std::vector<char> {
|
class file_content: public std::vector<char> {
|
||||||
public:
|
public:
|
||||||
// Read first
|
/// Read first
|
||||||
file_content(const std::vector<std::string>& paths, data::out_view prefix = data::out_view(nullptr, 0)):
|
file_content(const std::vector<std::string>& paths, data::out_view prefix = data::out_view(nullptr, 0)):
|
||||||
std::vector<char>(), prefix_size(prefix.size())
|
std::vector<char>(), prefix_size(prefix.size())
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
/// Generation indexing and containers (index, generation)
|
||||||
namespace data::generational {
|
namespace data::generational {
|
||||||
|
/// Generation element identifier
|
||||||
struct id {
|
struct id {
|
||||||
id(size_t index, size_t generation = 0): index(index), generation(generation) { }
|
id(size_t index, size_t generation = 0): index(index), generation(generation) { }
|
||||||
id(): id(0) { }
|
id(): id(0) { }
|
||||||
|
@ -14,6 +16,7 @@ namespace data::generational {
|
||||||
bool operator==(const id &i) const { return index == i.index && generation == i.generation; }
|
bool operator==(const id &i) const { return index == i.index && generation == i.generation; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Closed generational allocator
|
||||||
class allocator {
|
class allocator {
|
||||||
public:
|
public:
|
||||||
allocator() { }
|
allocator() { }
|
||||||
|
@ -68,6 +71,7 @@ namespace data::generational {
|
||||||
std::vector<size_t> freed;
|
std::vector<size_t> freed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Generational container accessible by id
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class vector {
|
class vector {
|
||||||
public:
|
public:
|
||||||
|
@ -229,6 +233,7 @@ namespace data::generational {
|
||||||
std::vector<size_t> freed;
|
std::vector<size_t> freed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Dummy generational container without allocation nor validation. A view to vector
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class view_vector: public std::vector<std::optional<T>> {
|
class view_vector: public std::vector<std::optional<T>> {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -7,12 +7,14 @@
|
||||||
|
|
||||||
namespace data {
|
namespace data {
|
||||||
|
|
||||||
|
/// Map vector to istream
|
||||||
struct vec_istream: std::streambuf {
|
struct vec_istream: std::streambuf {
|
||||||
vec_istream(std::vector<char> &vec) {
|
vec_istream(std::vector<char> &vec) {
|
||||||
this->setg(&vec[0], &vec[0], &vec[0] + vec.size());
|
this->setg(&vec[0], &vec[0], &vec[0] + vec.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Abstract data with moving cursor
|
||||||
struct view {
|
struct view {
|
||||||
view(size_t size): siz(size) { }
|
view(size_t size): siz(size) { }
|
||||||
|
|
||||||
|
@ -22,6 +24,7 @@ struct view {
|
||||||
constexpr size_t size() const { return siz; }
|
constexpr size_t size() const { return siz; }
|
||||||
constexpr bool isDone() const { return cur >= siz; }
|
constexpr bool isDone() const { return cur >= siz; }
|
||||||
};
|
};
|
||||||
|
/// Vector with in_view interface
|
||||||
struct in_vector {
|
struct in_vector {
|
||||||
/// 512 Mébibits
|
/// 512 Mébibits
|
||||||
static constexpr size_t MAX_SIZE = 1ul << 26;
|
static constexpr size_t MAX_SIZE = 1ul << 26;
|
||||||
|
@ -41,6 +44,7 @@ struct in_vector {
|
||||||
memcpy(writeTo(len), data, len);
|
memcpy(writeTo(len), data, len);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
// Abstract data writer
|
||||||
struct in_view: view {
|
struct in_view: view {
|
||||||
in_view(uint8_t *ptr, size_t size): view(size), ptr(ptr) {
|
in_view(uint8_t *ptr, size_t size): view(size), ptr(ptr) {
|
||||||
assert(ptr != nullptr);
|
assert(ptr != nullptr);
|
||||||
|
@ -57,6 +61,7 @@ struct in_view: view {
|
||||||
memcpy(writeTo(len), data, len);
|
memcpy(writeTo(len), data, len);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// Abstract data reader
|
||||||
struct out_view: view {
|
struct out_view: view {
|
||||||
out_view(): out_view(nullptr, 0) { }
|
out_view(): out_view(nullptr, 0) { }
|
||||||
out_view(const uint8_t *ptr, size_t size): view(size), ptr(ptr) { }
|
out_view(const uint8_t *ptr, size_t size): view(size), ptr(ptr) { }
|
||||||
|
@ -75,7 +80,9 @@ struct out_view: view {
|
||||||
constexpr const uint8_t* data() const { return ptr; }
|
constexpr const uint8_t* data() const { return ptr; }
|
||||||
constexpr size_t remaining() const { return size() - cur; }
|
constexpr size_t remaining() const { return size() - cur; }
|
||||||
};
|
};
|
||||||
|
/// Pointer to opaque owned memory
|
||||||
using handle_t = std::shared_ptr<const void>;
|
using handle_t = std::shared_ptr<const void>;
|
||||||
|
/// out_view with owned data
|
||||||
struct out_buffer: out_view {
|
struct out_buffer: out_view {
|
||||||
out_buffer(): out_view() { }
|
out_buffer(): out_view() { }
|
||||||
out_buffer(const out_view& view, const handle_t& handle):
|
out_buffer(const out_view& view, const handle_t& handle):
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
namespace net {
|
namespace net {
|
||||||
|
|
||||||
|
/// Abstract stream
|
||||||
struct stream_ctx {
|
struct stream_ctx {
|
||||||
stream_ctx(uint64_t id): stream_id(id) { }
|
stream_ctx(uint64_t id): stream_id(id) { }
|
||||||
uint64_t stream_id;
|
uint64_t stream_id;
|
||||||
|
@ -17,6 +18,7 @@ struct stream_ctx {
|
||||||
|
|
||||||
friend bool operator==(const stream_ctx &a, const stream_ctx &b) { return a.stream_id == b.stream_id; }
|
friend bool operator==(const stream_ctx &a, const stream_ctx &b) { return a.stream_id == b.stream_id; }
|
||||||
};
|
};
|
||||||
|
/// Outgoing stream
|
||||||
struct out_stream_ctx: stream_ctx {
|
struct out_stream_ctx: stream_ctx {
|
||||||
out_stream_ctx(uint64_t id, uint8_t queue_id, const data::out_buffer& buf):
|
out_stream_ctx(uint64_t id, uint8_t queue_id, const data::out_buffer& buf):
|
||||||
stream_ctx(id), buffer(buf), queue_id(queue_id) { }
|
stream_ctx(id), buffer(buf), queue_id(queue_id) { }
|
||||||
|
@ -24,10 +26,12 @@ struct out_stream_ctx: stream_ctx {
|
||||||
data::out_buffer buffer;
|
data::out_buffer buffer;
|
||||||
uint8_t queue_id;
|
uint8_t queue_id;
|
||||||
};
|
};
|
||||||
|
/// Incoming stream
|
||||||
struct in_stream_ctx: stream_ctx {
|
struct in_stream_ctx: stream_ctx {
|
||||||
in_stream_ctx(uint64_t id): stream_ctx(id) { }
|
in_stream_ctx(uint64_t id): stream_ctx(id) { }
|
||||||
data::in_vector buffer;
|
data::in_vector buffer;
|
||||||
};
|
};
|
||||||
|
/// Informations about packets
|
||||||
enum class PacketFlags {
|
enum class PacketFlags {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
DATAGRAM = 1 << 0,
|
DATAGRAM = 1 << 0,
|
||||||
|
@ -156,7 +160,6 @@ private:
|
||||||
std::forward_list<in_stream_ctx> incoming;
|
std::forward_list<in_stream_ctx> incoming;
|
||||||
|
|
||||||
// MAYBE: add bidirectional streams
|
// MAYBE: add bidirectional streams
|
||||||
// TODO: premanant streams: background, priority
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,11 +4,13 @@
|
||||||
#include "../utils/logger.hpp"
|
#include "../utils/logger.hpp"
|
||||||
#include <picoquic/picosocks.h>
|
#include <picoquic/picosocks.h>
|
||||||
|
|
||||||
|
/// Network protocol
|
||||||
namespace net {
|
namespace net {
|
||||||
|
|
||||||
/// Application Protocol Negotiation
|
/// Application Protocol Negotiation
|
||||||
constexpr auto ALPN = "univerxel_quic";
|
constexpr auto ALPN = "univerxel_quic";
|
||||||
|
|
||||||
|
/// Reasons for client server connection to break
|
||||||
enum class disconnect_reason: uint16_t {
|
enum class disconnect_reason: uint16_t {
|
||||||
UNEXPECTED = 0,
|
UNEXPECTED = 0,
|
||||||
// Client quit
|
// Client quit
|
||||||
|
@ -20,6 +22,7 @@ enum class disconnect_reason: uint16_t {
|
||||||
PROTOCOL_VIOLATION = 15,
|
PROTOCOL_VIOLATION = 15,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Packets from server to client
|
||||||
enum class server_packet_type: uint8_t {
|
enum class server_packet_type: uint8_t {
|
||||||
/// MAYBE: HELLO = 0,
|
/// MAYBE: HELLO = 0,
|
||||||
|
|
||||||
|
@ -50,7 +53,6 @@ enum class server_packet_type: uint8_t {
|
||||||
|
|
||||||
/// Update entities instances position and velocity
|
/// Update entities instances position and velocity
|
||||||
/// {size_t(entity), size_t(count), {size_t(index), ifvec3(pos), vec3(velocity)}[]}[]
|
/// {size_t(entity), size_t(count), {size_t(index), ifvec3(pos), vec3(velocity)}[]}[]
|
||||||
/// FIXME: fromat to fit PICOQUIC_MAX_PACKET_SIZE
|
|
||||||
ENTITIES = 21,
|
ENTITIES = 21,
|
||||||
|
|
||||||
/// World compression dictionary
|
/// World compression dictionary
|
||||||
|
@ -64,6 +66,7 @@ enum class server_packet_type: uint8_t {
|
||||||
/// char[] (not null terminated)
|
/// char[] (not null terminated)
|
||||||
MESSAGE = 29,
|
MESSAGE = 29,
|
||||||
};
|
};
|
||||||
|
/// Packets from client to server
|
||||||
enum class client_packet_type: uint8_t {
|
enum class client_packet_type: uint8_t {
|
||||||
/// Interact with voxels
|
/// Interact with voxels
|
||||||
/// actions::FillShape
|
/// actions::FillShape
|
||||||
|
@ -84,6 +87,7 @@ enum class client_packet_type: uint8_t {
|
||||||
|
|
||||||
constexpr auto MAX_PENDING_CHUNK_COUNT = 256;
|
constexpr auto MAX_PENDING_CHUNK_COUNT = 256;
|
||||||
|
|
||||||
|
/// Server address as name(ip or dns name) and port
|
||||||
struct address {
|
struct address {
|
||||||
std::string host;
|
std::string host;
|
||||||
int port;
|
int port;
|
||||||
|
@ -103,9 +107,12 @@ struct address {
|
||||||
return os << ct.host << ':' << ct.port;
|
return os << ct.host << ':' << ct.port;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// Server properties
|
||||||
struct exposure: address {
|
struct exposure: address {
|
||||||
uint32_t max_connections;
|
uint32_t max_connections;
|
||||||
|
/// TLS private key
|
||||||
std::string key;
|
std::string key;
|
||||||
|
/// TLS public key
|
||||||
std::string cert;
|
std::string cert;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace net {
|
||||||
|
|
||||||
//TODO: preallocate static data pool
|
//TODO: preallocate static data pool
|
||||||
|
|
||||||
/// Write allocated packets
|
/// Helper to write allocated packets
|
||||||
class PacketWriter final {
|
class PacketWriter final {
|
||||||
public:
|
public:
|
||||||
PacketWriter(size_t size): buffer((uint8_t*)malloc(size), size) { }
|
PacketWriter(size_t size): buffer((uint8_t*)malloc(size), size) { }
|
||||||
|
@ -100,6 +100,7 @@ private:
|
||||||
data::in_view buffer;
|
data::in_view buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Helper to read out_view
|
||||||
class PacketReader final {
|
class PacketReader final {
|
||||||
public:
|
public:
|
||||||
PacketReader(const data::out_view& buf): buffer(buf) { }
|
PacketReader(const data::out_view& buf): buffer(buf) { }
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "world/actions.hpp"
|
#include "world/actions.hpp"
|
||||||
#include "geometry/Faces.hpp"
|
#include "geometry/Faces.hpp"
|
||||||
|
|
||||||
|
/// Link between world::server::SharedUniverse and world::client::LocalUniverse
|
||||||
struct server_handle {
|
struct server_handle {
|
||||||
bool running = false;
|
bool running = false;
|
||||||
const world::client::area_map *areas;
|
const world::client::area_map *areas;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
namespace config::server {
|
namespace config::server {
|
||||||
|
|
||||||
|
/// Server side configuration
|
||||||
struct options {
|
struct options {
|
||||||
public:
|
public:
|
||||||
options(toml::node_view<toml::node> config): world() {
|
options(toml::node_view<toml::node> config): world() {
|
||||||
|
|
Loading…
Reference in New Issue