Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a41421d867 | ||
|
|
c1f6b11f7d | ||
|
|
b2233064a0 |
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#define ENTT_VERSION_MAJOR 3
|
#define ENTT_VERSION_MAJOR 3
|
||||||
#define ENTT_VERSION_MINOR 12
|
#define ENTT_VERSION_MINOR 12
|
||||||
#define ENTT_VERSION_PATCH 0
|
#define ENTT_VERSION_PATCH 1
|
||||||
|
|
||||||
#define ENTT_VERSION \
|
#define ENTT_VERSION \
|
||||||
ENTT_XSTR(ENTT_VERSION_MAJOR) \
|
ENTT_XSTR(ENTT_VERSION_MAJOR) \
|
||||||
|
|||||||
@@ -259,7 +259,9 @@ public:
|
|||||||
if constexpr(Registry::template storage_for_type<Type>::traits_type::page_size == 0u) {
|
if constexpr(Registry::template storage_for_type<Type>::traits_type::page_size == 0u) {
|
||||||
storage.emplace(entity);
|
storage.emplace(entity);
|
||||||
} else {
|
} else {
|
||||||
archive(storage.emplace(entity));
|
Type elem{};
|
||||||
|
archive(elem);
|
||||||
|
storage.emplace(entity, std::move(elem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -466,7 +468,9 @@ public:
|
|||||||
if constexpr(Registry::template storage_for_type<Type>::traits_type::page_size == 0u) {
|
if constexpr(Registry::template storage_for_type<Type>::traits_type::page_size == 0u) {
|
||||||
storage.emplace(map(entt));
|
storage.emplace(map(entt));
|
||||||
} else {
|
} else {
|
||||||
archive(storage.emplace(map(entt)));
|
Type elem{};
|
||||||
|
archive(elem);
|
||||||
|
storage.emplace(map(entt), std::move(elem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -523,9 +527,10 @@ public:
|
|||||||
if constexpr(std::remove_reference_t<decltype(storage)>::traits_type::page_size == 0u) {
|
if constexpr(std::remove_reference_t<decltype(storage)>::traits_type::page_size == 0u) {
|
||||||
storage.emplace(map(entt));
|
storage.emplace(map(entt));
|
||||||
} else {
|
} else {
|
||||||
auto &elem = storage.emplace(map(entt));
|
typename std::remove_reference_t<decltype(storage)>::value_type elem{};
|
||||||
archive(elem);
|
archive(elem);
|
||||||
(update(elem, member), ...);
|
(update(elem, member), ...);
|
||||||
|
storage.emplace(map(entt), std::move(elem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,16 @@
|
|||||||
#include <entt/entity/entity.hpp>
|
#include <entt/entity/entity.hpp>
|
||||||
#include <entt/entity/registry.hpp>
|
#include <entt/entity/registry.hpp>
|
||||||
#include <entt/entity/snapshot.hpp>
|
#include <entt/entity/snapshot.hpp>
|
||||||
|
#include <entt/signal/sigh.hpp>
|
||||||
|
|
||||||
struct empty {};
|
struct empty {};
|
||||||
|
|
||||||
struct shadow {
|
struct shadow {
|
||||||
entt::entity target{entt::null};
|
entt::entity target{entt::null};
|
||||||
|
|
||||||
|
static void listener(entt::entity &elem, entt::registry ®istry, const entt::entity entt) {
|
||||||
|
elem = registry.get<shadow>(entt).target;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(BasicSnapshot, Constructors) {
|
TEST(BasicSnapshot, Constructors) {
|
||||||
@@ -417,6 +422,33 @@ TEST(BasicSnapshotLoader, GetTypeSparse) {
|
|||||||
ASSERT_EQ(storage.get(entities[1u]), values[1u]);
|
ASSERT_EQ(storage.get(entities[1u]), values[1u]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(BasicSnapshotLoader, GetTypeWithListener) {
|
||||||
|
using traits_type = entt::entt_traits<entt::entity>;
|
||||||
|
|
||||||
|
entt::registry registry;
|
||||||
|
entt::basic_snapshot_loader loader{registry};
|
||||||
|
entt::entity check{entt::null};
|
||||||
|
|
||||||
|
std::vector<entt::any> data{};
|
||||||
|
auto archive = [&data, pos = 0u](auto &value) mutable { value = entt::any_cast<std::remove_reference_t<decltype(value)>>(data[pos++]); };
|
||||||
|
const auto entity{traits_type::construct(1u, 1u)};
|
||||||
|
const shadow value{entity};
|
||||||
|
|
||||||
|
ASSERT_FALSE(registry.valid(entity));
|
||||||
|
ASSERT_EQ(check, static_cast<entt::entity>(entt::null));
|
||||||
|
|
||||||
|
registry.on_construct<shadow>().connect<&shadow::listener>(check);
|
||||||
|
|
||||||
|
data.emplace_back(static_cast<typename traits_type::entity_type>(1u));
|
||||||
|
data.emplace_back(entity);
|
||||||
|
data.emplace_back(value);
|
||||||
|
|
||||||
|
loader.get<shadow>(archive);
|
||||||
|
|
||||||
|
ASSERT_TRUE(registry.valid(entity));
|
||||||
|
ASSERT_EQ(check, entity);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(BasicSnapshotLoader, Orphans) {
|
TEST(BasicSnapshotLoader, Orphans) {
|
||||||
using namespace entt::literals;
|
using namespace entt::literals;
|
||||||
using traits_type = entt::entt_traits<entt::entity>;
|
using traits_type = entt::entt_traits<entt::entity>;
|
||||||
@@ -823,6 +855,33 @@ TEST(BasicContinuousLoader, GetTypeSparse) {
|
|||||||
ASSERT_EQ(storage.get(loader.map(entities[1u])), values[1u]);
|
ASSERT_EQ(storage.get(loader.map(entities[1u])), values[1u]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(BasicContinuousLoader, GetTypeWithListener) {
|
||||||
|
using traits_type = entt::entt_traits<entt::entity>;
|
||||||
|
|
||||||
|
entt::registry registry;
|
||||||
|
entt::basic_continuous_loader loader{registry};
|
||||||
|
entt::entity check{entt::null};
|
||||||
|
|
||||||
|
std::vector<entt::any> data{};
|
||||||
|
auto archive = [&data, pos = 0u](auto &value) mutable { value = entt::any_cast<std::remove_reference_t<decltype(value)>>(data[pos++]); };
|
||||||
|
const auto entity{traits_type::construct(1u, 1u)};
|
||||||
|
const shadow value{entity};
|
||||||
|
|
||||||
|
ASSERT_FALSE(registry.valid(loader.map(entity)));
|
||||||
|
ASSERT_EQ(check, static_cast<entt::entity>(entt::null));
|
||||||
|
|
||||||
|
registry.on_construct<shadow>().connect<&shadow::listener>(check);
|
||||||
|
|
||||||
|
data.emplace_back(static_cast<typename traits_type::entity_type>(1u));
|
||||||
|
data.emplace_back(entity);
|
||||||
|
data.emplace_back(value);
|
||||||
|
|
||||||
|
loader.get<shadow>(archive);
|
||||||
|
|
||||||
|
ASSERT_TRUE(registry.valid(loader.map(entity)));
|
||||||
|
ASSERT_EQ(check, entity);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(BasicContinuousLoader, Shrink) {
|
TEST(BasicContinuousLoader, Shrink) {
|
||||||
entt::registry registry;
|
entt::registry registry;
|
||||||
entt::basic_continuous_loader loader{registry};
|
entt::basic_continuous_loader loader{registry};
|
||||||
|
|||||||
Reference in New Issue
Block a user