update to entt v3.9.0

This commit is contained in:
2021-12-13 18:42:22 +01:00
parent 494912ce8a
commit 81043264d2
12 changed files with 66 additions and 34 deletions

View File

@ -129,11 +129,19 @@ public:
if (registry.valid(e)) {
ImGui::SameLine();
// clone would go here
//if (ImGui::Button("Clone")) {
//auto old_e = e;
//e = registry.create();
//}
if (ImGui::Button("Clone")) {
auto old_e = e;
e = registry.create();
// create a copy of an entity component by component
for (auto &&curr: registry.storage()) {
if (auto &storage = curr.second; storage.contains(old_e)) {
// TODO: do something with the return value. returns false on failure.
storage.emplace(e, storage.get(old_e));
}
}
}
ImGui::SameLine();
ImGui::Dummy({10, 0}); // space destroy a bit, to not accidentally click it
ImGui::SameLine();
@ -229,8 +237,10 @@ public:
if (comp_list.empty()) {
ImGui::Text("Orphans:");
registry.orphans([&registry](auto e){
MM_IEEE_ENTITY_WIDGET(e, registry, false);
registry.each([&registry](auto e){
if (registry.orphan(e)) {
MM_IEEE_ENTITY_WIDGET(e, registry, false);
}
});
} else {
auto view = registry.runtime_view(comp_list.begin(), comp_list.end());

View File

@ -1,4 +1,4 @@
#include "entity.hpp"
#include "./entity.hpp"
#include <mm/imgui/imgui_entt_entity_editor.hpp>
@ -15,9 +15,9 @@ void Entity(MM::Entity& e, MM::Scene& ecs, bool dropTarget) {
if (ecs.valid(e)) {
if (ecs.all_of<MM::Components::Name>(e)) {
ImGui::Text(ICON_II_CUBE "E: %d v%d (%s)", entt::to_integral(ecs.entity(e)), ecs.version(e), ecs.get<MM::Components::Name>(e).str.c_str());
ImGui::Text(ICON_II_CUBE "E: %d v%d (%s)", entt::to_entity(e), entt::to_version(e), ecs.get<MM::Components::Name>(e).str.c_str());
} else {
ImGui::Text(ICON_II_CUBE "E: %d v%d", entt::to_integral(ecs.entity(e)), ecs.version(e));
ImGui::Text(ICON_II_CUBE "E: %d v%d", entt::to_entity(e), entt::to_version(e));
}
} else {
ImGui::Text(ICON_II_CUBE "E: invalid");
@ -26,7 +26,7 @@ void Entity(MM::Entity& e, MM::Scene& ecs, bool dropTarget) {
if (ecs.valid(e)) {
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAllowNullID)) {
ImGui::SetDragDropPayload(MM_IEEE_IMGUI_PAYLOAD_TYPE_ENTITY, &e, sizeof(e));
ImGui::Text(ICON_II_CUBE "E: %d v%d", entt::to_integral(ecs.entity(e)), ecs.version(e));
ImGui::Text(ICON_II_CUBE "E: %d v%d", entt::to_entity(e), entt::to_version(e));
ImGui::EndDragDropSource();
}
}

View File

@ -112,7 +112,11 @@ namespace MM::Services {
ImGui::Text("size: %lu", scene.size());
ImGui::Text("alive: %lu", scene.alive());
size_t orphans = 0;
scene.orphans([&](auto) { orphans++; });
scene.each([&orphans, &scene](auto entity) {
if (scene.orphan(entity)) {
orphans++;
}
});
ImGui::Text("orphans: %lu", orphans);
}
ImGui::End();

View File

@ -28,7 +28,7 @@ using namespace entt::literals;
const char* argv0;
void update_spritesheet_animation(entt::view<entt::exclude_t<>, MM::OpenGL::SpriteSheetRenderable> view, float& accu, const MM::Components::TimeDelta& td) {
void update_spritesheet_animation(entt::view<entt::get_t<MM::OpenGL::SpriteSheetRenderable>> view, float& accu, const MM::Components::TimeDelta& td) {
accu += td.tickDelta;
if (accu >= 1.f/10) {

View File

@ -24,7 +24,7 @@
using namespace entt::literals;
void update_spritesheet_animation(entt::view<entt::exclude_t<>, MM::OpenGL::SpriteSheetRenderable> view, float& accu, const MM::Components::TimeDelta& td) {
void update_spritesheet_animation(entt::view<entt::get_t<MM::OpenGL::SpriteSheetRenderable>> view, float& accu, const MM::Components::TimeDelta& td) {
accu += td.tickDelta;
if (accu >= 1.f/10) {