Commit 62886065 authored by Shu's avatar Shu 🍠
Browse files

New year reboot

Switch to FastNoise2
Hierarchy including rotate
And many more
parent e8080bff
cmake_minimum_required(VERSION 3.11)
project (univerxel VERSION 0.0.1)
project (univerxel VERSION 0.0.2)
option(PROFILING "Build with profiling" 0)
option(FIXED_WINDOW "Lock window size: Force floating on i3" 0)
set(SIMD_LEVEL "avx2" CACHE STRING "SIMD processor acceleration (sse2, sse4.1, avx2, avx512f)")
option(USE_FMA "Use fma" 1)
option(LOG_DEBUG "Show debug logs" 0)
option(LOG_TRACE "Show trace logs" 0)
option(FIXED_WINDOW "Lock window size: Force floating on i3" 0)
option(RENDER_VK "Include vulkan renderer" 1)
option(NATIVE "Build with -march=native" 0)
option(IPO "Link time optimisation" 1)
option(LD_GOLD "Use gold linker" 1)
option(CCACHE "Use code cache" 1)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
else(CCACHE_FOUND)
#TODO: set(CMAKE_UNITY_BUILD ON)
endif(CCACHE_FOUND)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
add_subdirectory("deps/glfw")
add_subdirectory("deps/glm")
add_subdirectory("deps/picoquic")
add_subdirectory("deps/zstd")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
add_subdirectory("deps/FastNoise2/src")
if (CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "CCACHE enabled")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
else(CCACHE_FOUND)
#MAYBE: set(CMAKE_UNITY_BUILD ON)
endif(CCACHE_FOUND)
endif()
if(IPO)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_OK OUTPUT IPO_ERROR)
if(IPO_OK)
message(STATUS "IPO / LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO / LTO not supported: <${IPO_ERROR}>")
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_OK OUTPUT IPO_ERROR)
if(IPO_OK)
message(STATUS "IPO / LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO / LTO not supported: <${IPO_ERROR}>")
endif()
endif()
set(LD_GOLD 1)
if(LD_GOLD)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if("${LD_VERSION}" MATCHES "GNU gold")
message(STATUS "Gold linker enabled")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
endif()
endif()
if(MSVC)
add_definitions(/std:c++latest)
add_compile_definitions(WIN32_LEAN_AND_MEAN=)
else()
#FIXME: by target set(CMAKE_CXX_FLAGS "-Wall -Wextra")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_compile_definitions(FIXED_WINDOW=${FIXED_WINDOW} LOG_DEBUG=${LOG_DEBUG} LOG_TRACE=${LOG_TRACE} HN_USE_FILESYSTEM=1)
if(PROFILING)
add_compile_definitions(TRACY_ENABLE=1)
endif(PROFILING)
add_compile_definitions(TRACY_ENABLE=1)
endif()
add_compile_definitions(FIXED_WINDOW=${FIXED_WINDOW} LOG_DEBUG=${LOG_DEBUG} LOG_TRACE=${LOG_TRACE})
if(NATIVE)
add_definitions(-march=native)
endif()
if(SIMD_LEVEL EQUAL "avx2")
add_compile_definitions(FN_COMPILE_AVX2=1)
elseif(SIMD_LEVEL EQUAL "avx512f")
add_compile_definitions(FN_COMPILE_AVX512=1)
endif()
if(MSVC)
add_definitions(/arch:AVX2)
else()
add_definitions(-m${SIMD_LEVEL})
endif()
if(USE_FMA)
if(MSVC)
add_definitions(/GL /fp:fast)
else()
add_definitions(-mfma)
endif()
endif(USE_FMA)
file(GLOB_RECURSE CORE_SOURCES "src/core/*.cpp" "deps/tracy/TracyClient.cpp")
configure_file(src/version.h.in generated/version.h @ONLY)
set(CORE_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/generated" "deps/toml++" "deps/robin_hood" "deps/libguarded" "deps/tracy")
set(CORE_HEADERS "src" "${CMAKE_CURRENT_BINARY_DIR}/generated" "deps/toml++" "deps/robin_hood" "deps/tracy")
set(CORE_LIBS glm::glm_static zstd::zstd_static) # picoquic
file(GLOB_RECURSE CLIENT_SOURCES "src/client/*.cpp" "deps/imgui/*.cpp" "deps/meshoptimizer/*.cpp" "deps/gl3w/gl3w.c" "deps/volk/volk.c")
set(CLIENT_HEADERS "deps/imgui" "deps/meshoptimizer" "deps/gl3w" "deps/volk")
file(GLOB_RECURSE CLIENT_SOURCES "src/client/*.cpp" "deps/imgui/*.cpp" "deps/meshoptimizer/*.cpp" "deps/gl3w/gl3w.c")
set(CLIENT_HEADERS "deps/imgui" "deps/meshoptimizer" "deps/gl3w")
set(CLIENT_LIBS glfw)
set(CLIENT_DEFS)
if(RENDER_VK)
list(APPEND CLIENT_SOURCES "deps/volk/volk.c")
list(APPEND CLIENT_HEADERS "deps/volk")
list(APPEND CLIENT_DEFS RENDER_VK=1)
else()
file(GLOB_RECURSE CLIENT_RENDER "src/client/render/impl/vk/*.cpp")
list(REMOVE_ITEM CLIENT_SOURCE ${CLIENT_RENDER})
endif()
file(GLOB_RECURSE SERVER_SOURCES "src/server/*.cpp" "deps/FastNoiseSIMD/*.cpp")
set(SERVER_HEADERS "deps/FastNoiseSIMD")
set(SERVER_LINKED)
file(GLOB_RECURSE SERVER_SOURCES "src/server/*.cpp")
set(SERVER_HEADERS)
set(SERVER_LIBS FastNoise)
if(WIN32)
set(CLIENT_HEADERS ${CLIENT_HEADERS} $ENV{VULKAN_SDK}\\include)
find_package(OpenSSL)
set(CORE_LIBS ${CORE_LIBS} ${CMAKE_BINARY_DIR}/libs/*.lib ${OPENSSL_LIBRARIES} ws2_32)
list(APPEND CORE_LIBS ${CMAKE_BINARY_DIR}/libs/*.lib ${OPENSSL_LIBRARIES} ws2_32)
else()
set(CORE_LIBS ${CORE_LIBS} picoquic-core pthread dl)
list(APPEND CORE_LIBS picoquic-core pthread dl)
endif()
if (WIN32)
......@@ -99,32 +105,56 @@ elseif (APPLE)
set(ICON univerxel.icns)
endif()
list(APPEND CORE_HEADERS "src/modules")
list(APPEND CORE_SOURCES "src/modules/core/Core.cpp")
# All in one exec
add_executable(univerxel "src/main.cpp" ${ICON} ${CORE_SOURCES} ${CLIENT_SOURCES} ${SERVER_SOURCES})
target_compile_features(univerxel PUBLIC cxx_std_17)
target_link_libraries(univerxel ${CORE_LIBS} ${CLIENT_LIBS} ${SERVER_LIBS})
target_link_libraries(univerxel PRIVATE ${CORE_LIBS} ${CLIENT_LIBS} ${SERVER_LIBS})
target_include_directories(univerxel PRIVATE ${CORE_HEADERS} ${CLIENT_HEADERS} ${SERVER_HEADERS})
target_compile_definitions(univerxel PRIVATE ${CLIENT_DEFS})
target_compile_features(univerxel PUBLIC cxx_std_17)
target_compile_options(univerxel PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra>
$<$<CXX_COMPILER_ID:MSVC>:
/WX /W4>)
# Standalone server
add_executable(univerxel-server EXCLUDE_FROM_ALL "src/server.cpp" ${ICON} ${CORE_SOURCES} ${SERVER_SOURCES})
target_compile_features(univerxel-server PUBLIC cxx_std_17)
target_link_libraries(univerxel-server ${CORE_LIBS} ${SERVER_LIBS})
target_link_libraries(univerxel-server PRIVATE ${CORE_LIBS} ${SERVER_LIBS})
target_include_directories(univerxel-server PRIVATE ${CORE_HEADERS} ${SERVER_HEADERS})
target_compile_definitions(univerxel-server PRIVATE STANDALONE_SERVER=1)
target_compile_features(univerxel-server PUBLIC cxx_std_17)
target_compile_options(univerxel-server PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra>
$<$<CXX_COMPILER_ID:MSVC>:
/WX /W4>)
# Dumb client
add_executable(univerxel-client EXCLUDE_FROM_ALL "src/client.cpp" ${ICON} ${CORE_SOURCES} ${CLIENT_SOURCES})
target_compile_features(univerxel-client PUBLIC cxx_std_17)
target_link_libraries(univerxel-client ${CORE_LIBS} ${CLIENT_LIBS})
target_link_libraries(univerxel-client PRIVATE ${CORE_LIBS} ${CLIENT_LIBS})
target_include_directories(univerxel-client PRIVATE ${CORE_HEADERS} ${CLIENT_HEADERS})
target_compile_definitions(univerxel-client PRIVATE LIGHT_CLIENT=1 ${CLIENT_DEFS})
target_compile_features(univerxel-client PUBLIC cxx_std_17)
target_compile_options(univerxel-client PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra>
$<$<CXX_COMPILER_ID:MSVC>:
/WX /W4>)
# Resource client files + default zstd.dict
file(COPY resource/content DESTINATION ${CMAKE_BINARY_DIR})
if(RENDER_VK)
file(COPY resource/shaders/vk DESTINATION ${CMAKE_BINARY_DIR}/content/shaders)
endif()
# Serialize entity model
file(GLOB_RECURSE MODELS_SOURCES "src/client/render/api/Models.cpp")
add_executable(generate_models EXCLUDE_FROM_ALL "src/tools/generate_models.cpp" ${MODELS_SOURCES})
target_compile_features(generate_models PUBLIC cxx_std_17)
target_link_libraries(generate_models glm::glm_static)
target_link_libraries(generate_models PRIVATE glm::glm_static)
target_include_directories(generate_models PRIVATE "deps/robin_hood" "deps/meshoptimizer")
# Docs
......
......@@ -38,7 +38,7 @@ PROJECT_NAME = Univerxel
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 0.0.1
PROJECT_NUMBER = 0.0.2
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
......
......@@ -96,13 +96,13 @@ CMake options: `-DKEY=VAL`
Key | Usage | Default
--- | --- | ---
SIMD_LEVEL | SIMD processor acceleration (sse2, sse4.1, avx2, avx512f) | `avx2`
USE_FMA | Fast math | `1`
CMAKE_BUILD_TYPE | Level of optimization | `Release`
PROFILING | Tracy profiling | `0`
LOG_DEBUG | Debug logs | `0`
LOG_TRACE | Trace logs | `0`
IPO | Link time optimisation | `1`
NATIVE | Optimize for native CPU | `0`
RENDER_VK | Include Vulkan renderer | `1`
1. Compile
```sh
......
......@@ -4,15 +4,16 @@
Released as `0.0.1`: `Pre alpha 1`
- [ ] From the ground up cleanup
- [x] From the ground up cleanup
## System
- [~] Dependencies updater
- [x] Tracy
- [ ] ImGui
- [x] FastNoise
- Compile time
- [ ] Warnings
- [x] Warnings
- [ ] Unit build
- [ ] Ninga
- [ ] Clang
......@@ -28,60 +29,80 @@ Released as `0.0.1`: `Pre alpha 1`
- [ ] Review documentation
- [ ] Code cleanup
- [ ] Proper wiki
- [ ] Yaml config
- [ ] Proper logger
- [ ] I18L
## Data
- [ ] Element hierarchy
- [ ] Collide
- [~] Element hierarchy
- [x] Raycast
- [ ] Soft part break
- [ ] Relative position
- [ ] Rotate
- [ ] Merge World and Entities
- [x] Relative position
- [x] Rotate
- [ ] Bounding hierarchy
- [x] Merge World and Entities
- [ ] Galaxy
- [ ] Orbit system
- [~] Orbit system
- [x] Circular
- [ ] Elliptic
- [ ] Gravity referential
- [ ] Collisions
- [ ] Point
- [ ] Step
- [ ] Ray
- [ ] Continuous
- Bilateral advancement
- GJK
- Edits
- [ ] More shapes
- [ ] Rotate
- [ ] Anchor
- [ ] Multi-block system
- [ ] Cross chunk structure
- [ ] Lighting
- [ ] Passive chunk save
- Generation
- SIMD
- [ ] Dynamic SIMD level libs
- [ ] https://github.com/Auburn/FastNoise2/releases
- [ ] Double precision
- [ ] Surface features
- [ ] Biomes
- https://imgur.com/kM8b5Zq
- https://imgur.com/a/bh2iy
- https://speciesdevblog.files.wordpress.com/2012/11/biomemap.png
- [ ] ECS
- [x] Data oriented
- [ ] Inventory
- [ ] Octree
- [ ] Surface aware LOD
- [ ] Level converter
- [ ] Area converter
- [ ] Minecraft import
- [ ] Base unit size change
- [ ] Local generation prediction
- [ ] Modding API
- [~] Modding API
- [x] Define boundaries
- [ ] Version handling
- [ ] Client-Server negotiation
- [ ] Save file index
- [ ] List possibilities
## Graphics
- [ ] Disable VK for now
- [~] Disable VK for now
- [ ] Slash screen
- [ ] Proper UI
- [ ] Pause menu
- [ ] Start menu
- [~] Start menu
- [ ] Using texture pack
- [ ] FontAwesome (https://github.com/juliettef/IconFontCppHeaders)
- [ ] Define standard unit size
- [x] Define standard unit sizes
- Terrain (area) 1:1m
- Objects (part) 1-8:1
- Models (instance) ~16:1 manual
- Visual debug
- [ ] Chunk / Region border
- [ ] Area box
- [x] Chunk / Region border
- [x] Area box
- [ ] Collision overview
- [ ] Effective occlusion culling
- [ ] Use average
- [ ] Cast from chunk center
- Curvature
- CubeSphere
......@@ -99,11 +120,13 @@ Released as `0.0.1`: `Pre alpha 1`
- https://assetstore.unity.com/packages/tools/terrain/microsplat-96478
- https://www.youtube.com/user/slipster216/videos
- [x] Biplanar
- [ ] Fix stochastic (needs regionPosition bound in f16 range)
- [ ] Distance resampling
- [ ] Tesselation
- [ ] Better LOD selection
- Dynamic to target fps
- [ ] Planet scale LOD (using chunk level average)
- [ ] Hard shadow
- [ ] Ambiant occlusion
- [ ] World lights
- [ ] HDR
- https://www.youtube.com/watch?v=iikdcAA7cww
......@@ -116,6 +139,7 @@ Released as `0.0.1`: `Pre alpha 1`
- Bloom
- [ ] Procedural Skybox
- [ ] Deferred
- [ ] Ambiant occlusion
- [ ] Cascaded shadow maps
- [ ] Avoid transparent back-face
- [ ] Translucency
......@@ -136,3 +160,4 @@ Released as `0.0.1`: `Pre alpha 1`
- [ ] Commands
- [~] Authentication
- [ ] Clean kick
- [ ] Check certificate
From 2b251207adef7ab9b9f243d4bcfa2cfc1e515114 Mon Sep 17 00:00:00 2001
From: Shu <me@wadza.fr>
Date: Tue, 5 Jan 2021 18:11:53 +0100
Subject: [PATCH] Fix: include path
---
src/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c72a4be..f5d134e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -55,8 +55,8 @@ set(install_targets ${install_targets} FastNoise PARENT_SCOPE)
set(install_fastnoise_headers ${FastNoise_headers} PARENT_SCOPE)
set(install_fastsimd_headers ${FastSIMD_headers} PARENT_SCOPE)
-target_include_directories(FastNoise PUBLIC
- $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
+target_include_directories(FastNoise SYSTEM PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
$<INSTALL_INTERFACE:include>
)
--
2.30.0
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd $BASEDIR
git clone https://github.com/Auburn/FastNoise2 .up
cd .up
echo "Apply master"
#TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
#echo "Apply tag $TAG"
#git checkout $TAG
git apply ../.fix-include-path.patch
cp -rf src include LICENSE ..
cd ..
rm -rf .up
echo "Done"
\ No newline at end of file
MIT License
Copyright (c) 2018 Jimmie Bergmann
Copyright (c) 2020 Jordan Peck
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
#pragma once
#include <memory>
#include "FastSIMD/FastSIMD.h"
#include "FastNoise_Config.h"
#include "Generators/BasicGenerators.h"
#include "Generators/Value.h"
#include "Generators/Perlin.h"
#include "Generators/Simplex.h"
#include "Generators/Cellular.h"
#include "Generators/Fractal.h"
#include "Generators/DomainWarp.h"
#include "Generators/DomainWarpFractal.h"
#include "Generators/Modifiers.h"
#include "Generators/Blends.h"
namespace FastNoise
{
template<typename T>
inline SmartNode<T> New( FastSIMD::eLevel maxLevel = FastSIMD::Level_Null )
{
static_assert( std::is_base_of_v<Generator, T>, "Use FastSIMD::New() to create non FastNoise classes" );
return SmartNode<T>( FastSIMD::New<T>( maxLevel ) );
}
inline SmartNode<> NewFromEncodedNodeTree( const char* encodedNodeTreeString, FastSIMD::eLevel maxLevel = FastSIMD::Level_Null )
{
return Metadata::DeserialiseSmartNode( encodedNodeTreeString, maxLevel );
}
}
\ No newline at end of file
#pragma once
#include <functional>
#include <memory>
#include <type_traits>
#include <vector>
#include <cstdint>
#include "FastNoise_Config.h"
#include "FastSIMD/FastSIMD.h"
namespace FastNoise
{
class Generator;
template<typename T>
struct PerDimensionVariable;
struct NodeData;
struct Metadata
{
Metadata( const char* className )
{
name = className;
id = AddMetadataClass( this );
}
static const std::vector<const Metadata*>& GetMetadataClasses()
{
return sMetadataClasses;
}
static const Metadata* GetMetadataClass( std::uint16_t nodeId )
{
if( nodeId < sMetadataClasses.size() )
{
return sMetadataClasses[nodeId];
}
return nullptr;
}
static std::string SerialiseNodeData( NodeData* nodeData, bool fixUp = false );
static SmartNode<> DeserialiseSmartNode( const char* serialisedBase64NodeData, FastSIMD::eLevel level = FastSIMD::Level_Null );
static NodeData* DeserialiseNodeData( const char* serialisedBase64NodeData, std::vector<std::unique_ptr<NodeData>>& nodeDataOut );
struct MemberVariable
{
enum eType
{
EFloat,
EInt,
EEnum
};
union ValueUnion
{
float f;
std::int32_t i;
ValueUnion( float v = 0 )
{
f = v;
}
ValueUnion( std::int32_t v )
{
i = v;
}
operator float()
{
return f;
}
operator std::int32_t()
{
return i;
}
bool operator ==( const ValueUnion& rhs ) const
{
return i == rhs.i;
}
};
const char* name;
eType type;
int dimensionIdx = -1;
ValueUnion valueDefault, valueMin, valueMax;
std::vector<const char*> enumNames;
std::function<void( Generator*, ValueUnion )> setFunc;
};
template<typename T, typename U, typename = std::enable_if_t<!std::is_enum_v<T>>>
void AddVariable( const char* name, T defaultV, U&& func, T minV = 0, T maxV = 0 )
{
MemberVariable member;
member.name = name;
member.valueDefault = defaultV;
member.valueMin = minV;
member.valueMax = maxV;
member.type = std::is_same_v<T, float> ? MemberVariable::EFloat : MemberVariable::EInt;
member.setFunc = [func]( Generator* g, MemberVariable::ValueUnion v ) { func( dynamic_cast<GetArg<U, 0>>(g), v ); };
memberVariables.push_back( member );
}
template<typename T, typename U, typename = std::enable_if_t<!std::is_enum_v<T>>>
void AddVariable( const char* name, T defaultV, void(U::* func)(T), T minV = 0, T maxV = 0 )
{
MemberVariable member;
member.name = name;
member.valueDefault = defaultV;
member.valueMin = minV;
member.valueMax = maxV;
member.type = std::is_same_v<T, float> ? MemberVariable::EFloat : MemberVariable::EInt;
member.setFunc = [func]( Generator* g, MemberVariable::ValueUnion v ) { (dynamic_cast<U*>(g)->*func)(v); };
memberVariables.push_back( member );
}
template<typename T, typename U, typename = std::enable_if_t<std::is_enum_v<T>>, typename... NAMES>
void AddVariableEnum( const char* name, T defaultV, void(U::* func)(T), NAMES... names )
{
MemberVariable member;
member.name = name;
member.type = MemberVariable::EEnum;
member.valueDefault = (int32_t)defaultV;
member.enumNames = { names... };
member.setFunc = [func]( Generator* g, MemberVariable::ValueUnion v ) { (dynamic_cast<U*>(g)->*func)((T)v.i); };
memberVariables.push_back( member );
}
template<typename T, typename U, typename = std::enable_if_t<!std::is_enum_v<T>>>
void AddPerDimensionVariable( const char* name, T defaultV, U&& func, T minV = 0, T maxV = 0 )
{
for( int idx = 0; (size_t)idx < sizeof( PerDimensionVariable<T>::varArray ) / sizeof( *PerDimensionVariable<T>::varArray ); idx++ )
{
MemberVariable member;
member.name = name;
member.valueDefault = defaultV;
member.valueMin = minV;
member.valueMax = maxV;
member.type = std::is_same_v<T, float> ? MemberVariable::EFloat : MemberVariable::EInt;