Compare commits

..

11 Commits

Author SHA1 Message Date
Michele Caini
0e07482e26 ready to cut v3.1.1 2019-09-05 15:24:08 +02:00
Michele Caini
6bb4800ecd fix batch creation (close #305) 2019-09-05 15:24:03 +02:00
Michele Caini
37e1ac71b0 minor changes 2019-09-05 15:22:24 +02:00
Michele Caini
869f96816c updated doc 2019-09-05 15:21:45 +02:00
Michele Caini
35a7008444 added noexcept specifier 2019-09-03 23:39:38 +02:00
Michele Caini
67f80ee111 the default ctor of entt::meta_factory should be public 2019-09-03 23:31:43 +02:00
Michele Caini
083a58753b typo 2019-09-03 23:31:39 +02:00
Michele Caini
b652357a5c review: group::sort 2019-09-02 16:48:47 +02:00
Michele Caini
49a52140b0 minor changes 2019-09-02 16:34:38 +02:00
Michele Caini
e37f84a227 avoid taking the position twice 2019-09-02 16:23:11 +02:00
Nicki
50fc83d478 Update AUTHORS (#302)
He's one of contributors to the idea of nested groups!! :)
2019-08-30 09:49:46 +02:00
15 changed files with 58 additions and 37 deletions

View File

@@ -25,6 +25,7 @@ mhammerc
Milerius
morbo84
m-waka
NixAJ
Paolo-Oliverio
pgruenbacher
prowolf

View File

@@ -16,7 +16,7 @@ endif()
# Project configuration
#
project(EnTT VERSION 3.1.0)
project(EnTT VERSION 3.1.1)
include(GNUInstallDirs)
@@ -52,7 +52,7 @@ if(NOT MSVC AND USE_LIBCPP)
check_cxx_source_compiles("
#include<type_traits>
int main() { return std::is_same_v<int, int> ? 0 : 1; }
int main() { return std::is_same_v<int, char>; }
" HAS_LIBCPP)
if(NOT HAS_LIBCPP)

5
TODO
View File

@@ -18,8 +18,6 @@
* built-in support for dual (or N-) buffering
* allow for custom stomp functions
* deprecate/replace snapshot
* remove dependency
* remove prototype
TODO
* custom (decoupled) pools ==> double buffering, shared components, multi-model
@@ -27,6 +25,9 @@ TODO
- inline variables are fine here, only the head represents a problem
- we should always resolve by looking into the list of types when working across boundaries, no direct resolve
* nested groups: AB/ABC/ABCD/... (hints: sort, check functions)
* snapshot rework/deprecation
* create(hint: entity) -> force-create
* assign<T...>(first, last)
* use unordered_map for named pools and context variables:
* use direct access (pool-like) also for context variables
* improves multi-stomp

View File

@@ -2,10 +2,10 @@
#define ENTT_CONFIG_VERSION_H
#define ENTT_VERSION "3.1.0"
#define ENTT_VERSION "3.1.1"
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 1
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#endif // ENTT_CONFIG_VERSION_H

View File

@@ -839,13 +839,9 @@ public:
}
for(auto next = *length; next; --next) {
([next = next-1, curr = cpool->data()[next-1]](auto *cpool) {
const auto pos = cpool->index(curr);
if(pos != next) {
cpool->swap(next, cpool->index(curr));
}
}(std::get<pool_type<Other> *>(pools)), ...);
const auto pos = next - 1;
const auto entt = cpool->data()[pos];
(std::get<pool_type<Other> *>(pools)->swap(pos, std::get<pool_type<Other> *>(pools)->index(entt)), ...);
}
}

View File

@@ -258,7 +258,7 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = Entity;
/*! @brief Unsigned integer type. */
using size_type = typename sparse_set<Entity>::size_type;
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = typename sparse_set<Entity>::iterator_type;

View File

@@ -200,7 +200,7 @@ class basic_registry {
struct group_data {
const std::size_t extent[3];
std::unique_ptr<void, void(*)(void *)> group;
bool(* const is_same)(const component *);
bool(* const is_same)(const component *) ENTT_NOEXCEPT;
};
struct ctx_variable {
@@ -606,7 +606,8 @@ public:
});
if constexpr(sizeof...(Component) > 0) {
return std::make_tuple(assure<Component>()->batch(*this, first, last)...);
// the reverse iterators guarantee the ordering between entities and components (hint: the pools return begin())
return std::make_tuple(assure<Component>()->batch(*this, std::make_reverse_iterator(last), std::make_reverse_iterator(first))...);
}
}
@@ -615,6 +616,14 @@ public:
*
* @sa create
*
* The components must be copyable for obvious reasons. The source entity
* must be a valid one.<br/>
* If no components are provided, the registry will try to copy all the
* existing types. The non-copyable ones will be ignored.
*
* @note
* Specifying the list of components is ways faster than an opaque copy.
*
* @tparam Component Types of components to copy.
* @tparam Exclude Types of components not to be copied.
* @param src A valid entity identifier to be copied.
@@ -633,6 +642,15 @@ public:
*
* @sa create
*
* The components must be copyable for obvious reasons. The entities must be
* all valid.<br/>
* If no components are provided, the registry will try to copy all the
* existing types. The non-copyable ones will be ignored.
*
* @note
* Specifying the list of components is ways faster than an opaque copy and
* uses the batch creation under the hood.
*
* @tparam Component Types of components to copy.
* @tparam Exclude Types of components not to be copied.
* @param first An iterator to the first element of the range to generate.
@@ -1361,7 +1379,7 @@ public:
groups.push_back(group_data{
{ sizeof...(Owned), sizeof...(Get), sizeof...(Exclude) },
decltype(group_data::group){new handler_type{}, [](void *gptr) { delete static_cast<handler_type *>(gptr); }},
[](const component *other) {
[](const component *other) ENTT_NOEXCEPT {
const component ctypes[] = { type<Owned>()..., type<Get>()..., type<Exclude>()... };
return std::equal(std::begin(ctypes), std::end(ctypes), other);
}

View File

@@ -141,9 +141,9 @@ class basic_runtime_view {
public:
/*! @brief Underlying entity identifier. */
using entity_type = typename sparse_set<Entity>::entity_type;
using entity_type = Entity;
/*! @brief Unsigned integer type. */
using size_type = typename sparse_set<Entity>::size_type;
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = iterator;

View File

@@ -419,7 +419,7 @@ public:
*/
template<typename It>
void batch(It first, It last) {
std::for_each(std::make_reverse_iterator(last), std::make_reverse_iterator(first), [this, next = direct.size()](const auto entt) mutable {
std::for_each(first, last, [this, next = direct.size()](const auto entt) mutable {
ENTT_ASSERT(!has(entt));
auto [page, offset] = map(entt);
assure(page);

View File

@@ -158,9 +158,9 @@ public:
/*! @brief Type of the objects associated with the entities. */
using object_type = Type;
/*! @brief Underlying entity identifier. */
using entity_type = typename underlying_type::entity_type;
using entity_type = Entity;
/*! @brief Unsigned integer type. */
using size_type = typename underlying_type::size_type;
using size_type = std::size_t;
/*! @brief Random access iterator type. */
using iterator_type = iterator<false>;
/*! @brief Constant random access iterator type. */
@@ -597,9 +597,9 @@ public:
/*! @brief Type of the objects associated with the entities. */
using object_type = Type;
/*! @brief Underlying entity identifier. */
using entity_type = typename underlying_type::entity_type;
using entity_type = Entity;
/*! @brief Unsigned integer type. */
using size_type = typename underlying_type::size_type;
using size_type = std::size_t;
/*! @brief Random access iterator type. */
using iterator_type = iterator;

View File

@@ -191,9 +191,9 @@ class basic_view {
public:
/*! @brief Underlying entity identifier. */
using entity_type = typename sparse_set<Entity>::entity_type;
using entity_type = Entity;
/*! @brief Unsigned integer type. */
using size_type = typename sparse_set<Entity>::size_type;
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = iterator;
@@ -539,9 +539,9 @@ public:
/*! @brief Type of component iterated by the view. */
using raw_type = Component;
/*! @brief Underlying entity identifier. */
using entity_type = typename pool_type::entity_type;
using entity_type = Entity;
/*! @brief Unsigned integer type. */
using size_type = typename pool_type::size_type;
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = typename sparse_set<Entity>::iterator_type;

View File

@@ -320,9 +320,10 @@ class meta_factory {
}
}
public:
/*! @brief Default constructor. */
meta_factory() ENTT_NOEXCEPT = default;
public:
/**
* @brief Extends a meta type by assigning it an identifier and properties.
* @tparam Property Types of properties to assign to the meta type.

View File

@@ -160,7 +160,7 @@ class connection {
{}
public:
/*! Default constructor. */
/*! @brief Default constructor. */
connection() = default;
/*! @brief Default copy constructor. */
@@ -227,7 +227,7 @@ private:
* when it goes out of scope.
*/
struct scoped_connection: private connection {
/*! Default constructor. */
/*! @brief Default constructor. */
scoped_connection() = default;
/**

View File

@@ -135,9 +135,13 @@ TEST(SparseSet, BatchAdd) {
ASSERT_FALSE(set.empty());
ASSERT_EQ(set.size(), 4u);
ASSERT_EQ(set.index(entt::entity{12}), 0u);
ASSERT_EQ(set.index(entities[0]), 2u);
ASSERT_EQ(set.index(entities[1]), 1u);
ASSERT_EQ(set.index(entities[0]), 1u);
ASSERT_EQ(set.index(entities[1]), 2u);
ASSERT_EQ(set.index(entt::entity{24}), 3u);
ASSERT_EQ(set.data()[set.index(entt::entity{12})], entt::entity{12});
ASSERT_EQ(set.data()[set.index(entities[0])], entities[0]);
ASSERT_EQ(set.data()[set.index(entities[1])], entities[1]);
ASSERT_EQ(set.data()[set.index(entt::entity{24})], entt::entity{24});
}
TEST(SparseSet, Iterator) {

View File

@@ -113,8 +113,8 @@ TEST(Storage, BatchAdd) {
it[0] = 1;
it[1] = 2;
ASSERT_EQ(pool.get(entities[0]), 1);
ASSERT_EQ(pool.get(entities[1]), 2);
ASSERT_EQ(pool.get(entities[0]), 2);
ASSERT_EQ(pool.get(entities[1]), 1);
}
TEST(Storage, BatchAddByCopy) {
@@ -136,8 +136,8 @@ TEST(Storage, BatchAddByCopy) {
it[0] = 1;
it[1] = 2;
ASSERT_EQ(pool.get(entities[0]), 1);
ASSERT_EQ(pool.get(entities[1]), 2);
ASSERT_EQ(pool.get(entities[0]), 2);
ASSERT_EQ(pool.get(entities[1]), 1);
}
TEST(Storage, BatchAddEmptyType) {