Skip to content

Commit

Permalink
fix: Let tag components call get_component, add missing export
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelwan committed Aug 9, 2024
1 parent c88cc16 commit 49a25c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ ecsact_build_recipe(
exports = [
# core
"ecsact_execute_systems",
"ecsact_create_registry",
"ecsact_destroy_registry",
"ecsact_clear_registry",
"ecsact_create_entity",
Expand Down Expand Up @@ -163,6 +164,8 @@ ecsact_build_recipe(
],
)

exports_files(["build_recipe.yml"])

ecsact_build_recipe_bundle(
name = "ecsact_rt_entt",
recipes = [":ecsact_rt_entt_recipe"],
Expand Down
4 changes: 4 additions & 0 deletions ecsact/entt/wrapper/core.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ inline auto get_component(
[[maybe_unused]] ecsact_component_id component_id,
...
) -> const void* {
if constexpr(std::is_empty_v<C>) {
static C emptyVal;
return &emptyVal;
}
auto& reg = ecsact::entt::get_registry(registry_id);
auto entity = ecsact::entt::entity_id{entity_id};
assert(C::id == component_id);
Expand Down
10 changes: 2 additions & 8 deletions rt_entt_codegen/rt_entt_codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,13 @@ void ecsact_codegen_plugin(
return;
}

auto non_tag_component_ids =
details.all_components |
std::views::filter([&](ecsact_component_id comp_id) -> bool {
return !ecsact::meta::get_field_ids(comp_id).empty();
});

ctx.write(
"result.reserve(",
std::ranges::distance(non_tag_component_ids),
std::ranges::distance(details.all_components),
");\n"
);

for(auto comp_id : non_tag_component_ids) {
for(auto comp_id : details.all_components) {
auto cpp_comp_name = cpp_identifier(decl_full_name(comp_id));
ctx.write(
"result.insert({::",
Expand Down

0 comments on commit 49a25c4

Please sign in to comment.