Skip to content

Commit

Permalink
update with UTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubpa committed Feb 22, 2021
1 parent ae27608 commit fc56ee8
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 25 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(UECS VERSION 0.15.0)
project(UECS VERSION 0.15.1)
message(STATUS "[Project] ${PROJECT_NAME}")

include(cmake/InitUCMake.cmake)
Ubpa_InitUCMake(VERSION 0.6.4)

Ubpa_InitProject()

Ubpa_AddDep(UTemplate 0.6.0)
Ubpa_AddDep(UGraphviz 0.2.0)
Ubpa_AddDep(UTemplate 0.7.1)
Ubpa_AddDep(UGraphviz 0.2.0)

Ubpa_AddSubDirsRec(include)
Ubpa_AddSubDirsRec(src)
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@

**U**bpa **E**ntity-**C**omponent-**S**ystem in Unity3D-style

## Environment
## Compiler compatibility

- Compiler
- MSVC: >=1926
- GCC: >= 10
- Clang: >= 10
- C++ 20
- Clang/LLVM >= 10.0
- GCC >= 10.0
- MSVC >= 1926

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion include/UECS/AccessTypeID.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "details/Util.h"

#include <UTemplate/TypeID.h>
#include <UTemplate/Type.h>

#include <set>

Expand Down
6 changes: 3 additions & 3 deletions include/UECS/CmptTag.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace Ubpa::UECS {
// 6. Latest<Singleton<Cmpt>>

enum class AccessMode : std::size_t {
LAST_FRAME = 0b000, // LastFrame<Cmpt>
WRITE = 0b001, // Write<Cmpt> / Cmpt*
LATEST = 0b010, // Latest<Cmpt> / const Cmpt*
LAST_FRAME = 0b000, // LastFrame<Cmpt>
WRITE = 0b001, // Write<Cmpt> / Cmpt*
LATEST = 0b010, // Latest<Cmpt> / const Cmpt*
};

template<typename Cmpt>
Expand Down
6 changes: 3 additions & 3 deletions include/UECS/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Ubpa::UECS {

// Cache-Lines size is (typically) 64 bytes
// it has to be an exponent of 2 and >= 16
constexpr std::size_t CHUNK_ALIGNMENT = 64;
constexpr std::size_t ChunkAlignment = 64;

// 16384 bytes : 16 KB
// it has to be a multiple of UECS_CHUNK_ALIGNMENT and an exponent of 2
constexpr std::size_t CHUNK_SIZE = 16384;
// it has to be a multiple of ChunkAlignment and an exponent of 2
constexpr std::size_t ChunkSize = 16384;
}

8 changes: 4 additions & 4 deletions include/UECS/details/Archetype.inl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Ubpa::UECS {
types(GenTypeIDSet<Cmpts...>()),
chunkAllocator{ chunkAllocator }
{
static_assert(IsSet_v<TypeList<Entity, Cmpts...>>,
static_assert(IsUnique_v<TypeList<Entity, Cmpts...>>,
"<Cmpts>... must be different");
cmptTraits.Register<Entity>();
(cmptTraits.Register<Cmpts>(), ...);
Expand All @@ -19,7 +19,7 @@ namespace Ubpa::UECS {
template<typename... Cmpts>
Archetype* Archetype::Add(const Archetype* from) {
static_assert(sizeof...(Cmpts) > 0);
static_assert(IsSet_v<TypeList<Entity, Cmpts...>>,
static_assert(IsUnique_v<TypeList<Entity, Cmpts...>>,
"<Cmpts>... must be different");
assert(!(from->types.Contains(TypeID_of<Cmpts>) &&...));

Expand All @@ -39,7 +39,7 @@ namespace Ubpa::UECS {
std::tuple<std::size_t, std::tuple<Cmpts *...>> Archetype::Create(Entity e) {
static_assert((std::is_constructible_v<Cmpts> &&...),
"<Cmpts> isn't constructible");
static_assert(IsSet_v<TypeList<Entity, Cmpts...>>,
static_assert(IsUnique_v<TypeList<Entity, Cmpts...>>,
"<Cmpts>... must be different");

assert((types.Contains(TypeID_of<Cmpts>) &&...) && types.data.size() == 1 + sizeof...(Cmpts));
Expand All @@ -58,7 +58,7 @@ namespace Ubpa::UECS {
template<typename... Cmpts>
TypeIDSet Archetype::GenTypeIDSet() {
if constexpr (sizeof...(Cmpts) > 0) {
static_assert(IsSet_v<TypeList<Entity, Cmpts...>>,
static_assert(IsUnique_v<TypeList<Entity, Cmpts...>>,
"<Cmpts>... must be different");

constexpr std::array types = { TypeID_of<Cmpts>... };
Expand Down
4 changes: 2 additions & 2 deletions include/UECS/details/Chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace Ubpa::UECS {
using byte = uint8_t;
static_assert(sizeof(byte) == 1);
struct alignas(CHUNK_ALIGNMENT) Chunk {
static constexpr std::size_t size = CHUNK_SIZE;
struct alignas(ChunkAlignment) Chunk {
static constexpr std::size_t size = ChunkSize;

struct Layout {
std::size_t capacity;
Expand Down
2 changes: 1 addition & 1 deletion include/UECS/details/SystemFunc.inl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace Ubpa::UECS::details {
using ArgList = FuncTraits_ArgList<Func>;

using DecayedArgList = Transform_t<ArgList, DecayArg>;
static_assert(IsSet_v<DecayedArgList>, "details::System_::Pack: <Func>'s argument types must be a set");
static_assert(IsUnique_v<DecayedArgList>, "details::System_::Pack: <Func>'s argument types must be a set");

using TaggedCmptList = Filter_t<ArgList, IsTaggedCmpt>;

Expand Down
2 changes: 1 addition & 1 deletion include/UECS/details/Util.inl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <UTemplate/TypeID.h>
#include <UTemplate/Type.h>

namespace Ubpa::UECS {
constexpr std::size_t hash_combine(std::size_t x, std::size_t y) noexcept {
Expand Down
2 changes: 1 addition & 1 deletion src/app/CmptHashCode/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <UTemplate/TypeID.h>
#include <UTemplate/Type.h>

#include <iostream>

Expand Down
12 changes: 12 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
list(APPEND c_options "-pthread")
endif()

set(c_options_private "")
if(MSVC)
list(APPEND c_options_private "/MP")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
#
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
#
endif()

set(l_options "")
if(MSVC)
#..
Expand All @@ -27,6 +37,8 @@ Ubpa_AddTarget(
"${PROJECT_SOURCE_DIR}/include"
C_OPTION
${c_options}
C_OPTION_PRIVATE
${c_options_private}
L_OPTION
${l_options}
)
Expand Down

0 comments on commit fc56ee8

Please sign in to comment.