From fc18d248d960d98481c42bd2ea27dffb1f701230 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Wed, 1 Jul 2026 14:15:13 -0700 Subject: [PATCH 1/2] feat(core): add fast path api for copying registries --- ecsact_rt_entt/runtime/ecsact_rt_entt_core.cc | 16 ++++++++++++++++ ecsact_runtime/ecsact/runtime/core.h | 11 +++++++++++ ecsact_runtime/ecsact/runtime/core.hh | 5 +++++ 3 files changed, 32 insertions(+) diff --git a/ecsact_rt_entt/runtime/ecsact_rt_entt_core.cc b/ecsact_rt_entt/runtime/ecsact_rt_entt_core.cc index b91f39b..17d585e 100644 --- a/ecsact_rt_entt/runtime/ecsact_rt_entt_core.cc +++ b/ecsact_rt_entt/runtime/ecsact_rt_entt_core.cc @@ -40,6 +40,22 @@ auto ecsact_clone_registry( // return cloned_reg_id; } +void ecsact_copy_registry( + ecsact_registry_id src_id, + ecsact_registry_id dst_id +) { + auto& src_reg = ecsact::entt::get_registry(src_id); + auto& dst_reg = ecsact::entt::get_registry(dst_id); + dst_reg = {}; + ecsact::entt::ecsact_init_registry_storage(dst_reg); + for(auto&& [entity_id] : src_reg.template storage().each()) { + [[maybe_unused]] auto cloned_entity_id = dst_reg.create(entity_id); + assert(cloned_entity_id == entity_id); + } + ecsact::entt::copy_components(src_reg, dst_reg); +} + + auto ecsact_hash_registry(ecsact_registry_id reg_id) -> uint64_t { auto& reg = ecsact::entt::get_registry(reg_id); return ecsact::entt::hash_registry(reg); diff --git a/ecsact_runtime/ecsact/runtime/core.h b/ecsact_runtime/ecsact/runtime/core.h index 2a0fa5f..d9e58a4 100644 --- a/ecsact_runtime/ecsact/runtime/core.h +++ b/ecsact_runtime/ecsact/runtime/core.h @@ -57,6 +57,16 @@ ECSACT_CORE_API_FN(ecsact_registry_id, ecsact_clone_registry) ecsact_registry_id registry, const char* registry_name); +/** + * Copies all entities and components from a source registry to a destination registry. + * The destination registry is cleared before copy. + */ +ECSACT_CORE_API_FN(void, ecsact_copy_registry) +( // + ecsact_registry_id src_registry, + ecsact_registry_id dest_registry); + + /** * Creates a hash of current state of the registry. The algorithm is * implementation defined, but must represent both user state and internal @@ -295,6 +305,7 @@ ECSACT_CORE_API_FN(ecsact_stream_error, ecsact_stream) fn(ecsact_create_registry, __VA_ARGS__); \ fn(ecsact_destroy_registry, __VA_ARGS__); \ fn(ecsact_clone_registry, __VA_ARGS__); \ + fn(ecsact_copy_registry, __VA_ARGS__); \ fn(ecsact_hash_registry, __VA_ARGS__); \ fn(ecsact_clear_registry, __VA_ARGS__); \ fn(ecsact_create_entity, __VA_ARGS__); \ diff --git a/ecsact_runtime/ecsact/runtime/core.hh b/ecsact_runtime/ecsact/runtime/core.hh index f35a200..2d9fd9e 100644 --- a/ecsact_runtime/ecsact/runtime/core.hh +++ b/ecsact_runtime/ecsact/runtime/core.hh @@ -648,6 +648,11 @@ public: return cloned_registry; } + ECSACT_ALWAYS_INLINE auto copy_to(const registry& dest) const -> void { + ecsact_copy_registry(_id, dest.id()); + } + + ECSACT_ALWAYS_INLINE auto hash() const -> uint64_t { return ecsact_hash_registry(_id); } From 10bf6c8c6c136ff7cc5af2fc05ac460338931ac4 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Wed, 1 Jul 2026 15:05:19 -0700 Subject: [PATCH 2/2] chore: formatting --- ecsact_runtime/ecsact/runtime/core.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ecsact_runtime/ecsact/runtime/core.h b/ecsact_runtime/ecsact/runtime/core.h index d9e58a4..8222ddc 100644 --- a/ecsact_runtime/ecsact/runtime/core.h +++ b/ecsact_runtime/ecsact/runtime/core.h @@ -52,20 +52,19 @@ ECSACT_CORE_API_FN(void, ecsact_destroy_registry) * If `ecsact_hash_registry` is defined then the cloned registry hash must * match the original registry. */ -ECSACT_CORE_API_FN(ecsact_registry_id, ecsact_clone_registry) -( // +ECSACT_CORE_API_FN(ecsact_registry_id, ecsact_clone_registry)( ecsact_registry_id registry, - const char* registry_name); + const char* registry_name +); /** - * Copies all entities and components from a source registry to a destination registry. - * The destination registry is cleared before copy. + * Copies all entities and components from a source registry to a destination + * registry. The destination registry is cleared before copy. */ -ECSACT_CORE_API_FN(void, ecsact_copy_registry) -( // +ECSACT_CORE_API_FN(void, ecsact_copy_registry)( ecsact_registry_id src_registry, - ecsact_registry_id dest_registry); - + ecsact_registry_id dest_registry +); /** * Creates a hash of current state of the registry. The algorithm is