You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to add customized serialization support for our flecs-based system and one of the functions is basically a variation on ecs_world_to_json_buf() but for our serialization approach. I would prefer to do this in C++. The function is invoked by a system during the progress update if that is relevant.
I feel like I'm stupid because nothing that I try for this works. I appear to only end up with one of two options:
The iteration / each produces absolutely nothing.
It crashes in some bizarre way (have tried dozens of permutations).
I have even tried basically cutting/pasting the parts of ecs_world_to_json_buf() in C into the function that gets called and this also simply crashes with a null table.
ecs_query_desc_t query_desc = {0};
query_desc.terms[0].id = ecs_pair(EcsChildOf, EcsFlecs);
query_desc.terms[0].oper = EcsNot;
query_desc.terms[0].src.id = EcsSelf | EcsUp;
query_desc.flags = EcsQueryMatchDisabled | EcsQueryMatchPrefab;
ecs_query_t *qq = ecs_query_init(self.world().world_, &query_desc);
if (qq != nullptr) {
spdlog::info("Iterating query."); /* This prints out ... */
ecs_iter_t it = ecs_query_iter(self.world().world_, qq); /* Crashes right here << */
while (ecs_each_next(&it)) {
spdlog::info("Iterator Count {}", it.count);
for (int ii = 0; ii < it.count; ii++) {
spdlog::info("Entity: {}", ecs_get_name(self.world().world_, it.entities[ii]));
}
}
}
Crashes with:
ecs_table_count (table=table@entry=0x0) at /<path>/src/flecs/src/storage/table.c:2437 2437 return table->data.count;
So I feel like I'm really missing some understanding. I would have thought (for example) that this would have just worked:
But it seems like nothing works and I'm reading/reverse-engineering source code and wondering if there is some basic incantation that will "iterate the world" for these utility/meta style functions in a nice way in C++?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I need to add customized serialization support for our flecs-based system and one of the functions is basically a variation on ecs_world_to_json_buf() but for our serialization approach. I would prefer to do this in C++. The function is invoked by a system during the progress update if that is relevant.
I feel like I'm stupid because nothing that I try for this works. I appear to only end up with one of two options:
I have even tried basically cutting/pasting the parts of ecs_world_to_json_buf() in C into the function that gets called and this also simply crashes with a null table.
Crashes with:
ecs_table_count (table=table@entry=0x0) at /<path>/src/flecs/src/storage/table.c:2437 2437 return table->data.count;
So I feel like I'm really missing some understanding. I would have thought (for example) that this would have just worked:
world.each([](flecs::entity id) { // Iterate everything here. });
At least some variation of the above?
But it seems like nothing works and I'm reading/reverse-engineering source code and wondering if there is some basic incantation that will "iterate the world" for these utility/meta style functions in a nice way in C++?
Beta Was this translation helpful? Give feedback.
All reactions