From c8e6f15a3c1dfb736454a6a23c2e3f7c7cc12ad9 Mon Sep 17 00:00:00 2001 From: Kelwan Date: Fri, 8 Nov 2024 13:03:43 -0800 Subject: [PATCH 1/3] chore: Add prepare for stream and destroyed_entity markers --- ecsact/entt/wrapper/core.hh | 1 + rt_entt_codegen/core/init_registry_storage.cc | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ecsact/entt/wrapper/core.hh b/ecsact/entt/wrapper/core.hh index 9c53cf3..0537953 100644 --- a/ecsact/entt/wrapper/core.hh +++ b/ecsact/entt/wrapper/core.hh @@ -467,6 +467,7 @@ inline auto prepare_component(ecsact_registry_id registry_id) -> void { if constexpr(!std::is_empty_v) { reg.template storage>(); reg.template storage>(); + reg.template storage>(); } } diff --git a/rt_entt_codegen/core/init_registry_storage.cc b/rt_entt_codegen/core/init_registry_storage.cc index 6cc7365..02f6ad7 100644 --- a/rt_entt_codegen/core/init_registry_storage.cc +++ b/rt_entt_codegen/core/init_registry_storage.cc @@ -16,6 +16,11 @@ auto ecsact::rt_entt_codegen::core::print_init_registry_storage( .parameter("ecsact_registry_id", "registry_id") .return_type("void"); + ctx.write("auto& reg = ecsact::entt::get_registry(registry_id);\n"); + ctx.write( + "reg.template storage();\n\n" + ); + for(auto comp_id : details.all_components) { auto cpp_comp_name = cpp_identifier(decl_full_name(comp_id)); From bf1df61ae32100aff4e89b38a7d82093417a2bdf Mon Sep 17 00:00:00 2001 From: Kelwan Date: Sat, 9 Nov 2024 12:47:24 -0800 Subject: [PATCH 2/3] chore: Change registry prepare function to work with entt registries --- ecsact/entt/wrapper/core.hh | 14 ++++++-------- rt_entt_codegen/core/create_registry.cc | 4 +++- rt_entt_codegen/core/init_registry_storage.cc | 9 ++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ecsact/entt/wrapper/core.hh b/ecsact/entt/wrapper/core.hh index 0537953..3879dc1 100644 --- a/ecsact/entt/wrapper/core.hh +++ b/ecsact/entt/wrapper/core.hh @@ -6,6 +6,7 @@ #include "ecsact/entt/detail/internal_markers.hh" #include "ecsact/entt/event_markers.hh" #include "entt/entity/registry.hpp" +#include "entt/entt.hpp" #include "ecsact/entt/registry_util.hh" #include "ecsact/entt/error_check.hh" #include "ecsact/entt/detail/execution_events_collector.hh" @@ -452,11 +453,9 @@ inline auto clear_notify_component(ecsact_registry_id registry_id) -> void { } template -inline auto prepare_component(ecsact_registry_id registry_id) -> void { +inline auto prepare_component(::entt::registry& reg) -> void { using namespace ecsact::entt; - auto& reg = ecsact::entt::get_registry(registry_id); - reg.template storage(); reg.template storage>(); reg.template storage>(); @@ -472,13 +471,12 @@ inline auto prepare_component(ecsact_registry_id registry_id) -> void { } template -inline auto prepare_system(ecsact_registry_id registry_id) -> void { +inline auto prepare_system(::entt::registry& registry) -> void { using namespace ecsact::entt::detail; - auto& reg = ecsact::entt::get_registry(registry_id); - reg.template storage>(); - reg.template storage>(); - reg.template storage>(); + registry.template storage>(); + registry.template storage>(); + registry.template storage>(); } template diff --git a/rt_entt_codegen/core/create_registry.cc b/rt_entt_codegen/core/create_registry.cc index 41f79ec..3cf14cd 100644 --- a/rt_entt_codegen/core/create_registry.cc +++ b/rt_entt_codegen/core/create_registry.cc @@ -16,6 +16,8 @@ auto ecsact::rt_entt_codegen::core::print_create_registry( // .return_type("ecsact_registry_id"); ctx.write("auto&& [registry_id, reg] = ecsact::entt::create_registry();\n\n"); - ctx.write("ecsact_init_registry_storage(registry_id);\n"); + + ctx.write("auto& entt_reg = ecsact::entt::get_registry(registry_id);\n\n"); + ctx.write("ecsact_init_registry_storage(entt_reg);\n"); ctx.write("\nreturn registry_id;"); } diff --git a/rt_entt_codegen/core/init_registry_storage.cc b/rt_entt_codegen/core/init_registry_storage.cc index 02f6ad7..586220a 100644 --- a/rt_entt_codegen/core/init_registry_storage.cc +++ b/rt_entt_codegen/core/init_registry_storage.cc @@ -13,19 +13,18 @@ auto ecsact::rt_entt_codegen::core::print_init_registry_storage( auto printer = // method_printer{ctx, "ecsact_init_registry_storage"} - .parameter("ecsact_registry_id", "registry_id") + .parameter("entt::registry&", "registry") .return_type("void"); - ctx.write("auto& reg = ecsact::entt::get_registry(registry_id);\n"); ctx.write( - "reg.template storage();\n\n" + "registry.template storage();\n\n" ); for(auto comp_id : details.all_components) { auto cpp_comp_name = cpp_identifier(decl_full_name(comp_id)); ctx.write(std::format( - "ecsact::entt::wrapper::core::prepare_component<{}>(registry_id);\n", + "ecsact::entt::wrapper::core::prepare_component<{}>(registry);\n", cpp_comp_name )); } @@ -34,7 +33,7 @@ auto ecsact::rt_entt_codegen::core::print_init_registry_storage( auto cpp_sys_name = cpp_identifier(decl_full_name(system_id)); ctx.write(std::format( - "ecsact::entt::wrapper::core::prepare_system<{}>(registry_id);\n", + "ecsact::entt::wrapper::core::prepare_system<{}>(registry);\n", cpp_sys_name )); } From 1fc4bedd9637626ced041a42e7e9913c9cc84d60 Mon Sep 17 00:00:00 2001 From: Kelwan Date: Sat, 9 Nov 2024 13:41:04 -0800 Subject: [PATCH 3/3] chore: Expose init_registry function --- ecsact/entt/registry_util.hh | 2 ++ rt_entt_codegen/core/create_registry.cc | 2 +- rt_entt_codegen/core/init_registry_storage.cc | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ecsact/entt/registry_util.hh b/ecsact/entt/registry_util.hh index 8213c5b..629b104 100644 --- a/ecsact/entt/registry_util.hh +++ b/ecsact/entt/registry_util.hh @@ -33,4 +33,6 @@ inline auto create_registry() return {registry_id, std::ref(registry)}; } +auto ecsact_init_registry_storage(::entt::registry& registry) -> void; + } // namespace ecsact::entt diff --git a/rt_entt_codegen/core/create_registry.cc b/rt_entt_codegen/core/create_registry.cc index 3cf14cd..973617e 100644 --- a/rt_entt_codegen/core/create_registry.cc +++ b/rt_entt_codegen/core/create_registry.cc @@ -18,6 +18,6 @@ auto ecsact::rt_entt_codegen::core::print_create_registry( // ctx.write("auto&& [registry_id, reg] = ecsact::entt::create_registry();\n\n"); ctx.write("auto& entt_reg = ecsact::entt::get_registry(registry_id);\n\n"); - ctx.write("ecsact_init_registry_storage(entt_reg);\n"); + ctx.write("ecsact::entt::ecsact_init_registry_storage(entt_reg);\n"); ctx.write("\nreturn registry_id;"); } diff --git a/rt_entt_codegen/core/init_registry_storage.cc b/rt_entt_codegen/core/init_registry_storage.cc index 586220a..b0dda9a 100644 --- a/rt_entt_codegen/core/init_registry_storage.cc +++ b/rt_entt_codegen/core/init_registry_storage.cc @@ -12,8 +12,8 @@ auto ecsact::rt_entt_codegen::core::print_init_registry_storage( using ecsact::rt_entt_codegen::util::method_printer; auto printer = // - method_printer{ctx, "ecsact_init_registry_storage"} - .parameter("entt::registry&", "registry") + method_printer{ctx, "ecsact::entt::ecsact_init_registry_storage"} + .parameter("::entt::registry&", "registry") .return_type("void"); ctx.write(