Skip to content

Commit

Permalink
Fix outdated docs in Queries.md and Manual.md
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Aug 22, 2023
1 parent 323f9dd commit ce3c825
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 0 additions & 2 deletions docs/Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,6 @@ Component disabling can be used to temporarily suspend and resume a component va
#### Limitations
Component disabling does not work for components not matched with the entity. If a query matches with a component from a base (prefab) or parent entity and the component is disabled for that entity, the query will not take this into account. If entities with disabled components from a base or parent entity need to be skipped. a query should manually check this.

Because component disabling is implemented with a type role, it cannot be used together with other type roles. This means that it is not possible to disable, for example, tags with `SWITCH` or `CASE` roles. Additionally since relationships rely on a role, it is currently not possible to disable relationships such as `(ChildOf, parent)` or `(IsA, prefab)`.

Another limitation is that currently the query NOT (!) operator does not take into account disabled entities. The optional operator (?) technically works, but a query is unable to see whether a component has been set or not as both the enabled and disabled values are returned to the application in a single array.

## Tagging
Expand Down
12 changes: 8 additions & 4 deletions docs/Queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -1147,10 +1147,12 @@ while (ecs_filter_next(&it)) {

ecs_id_t vs_id = ecs_field_id(&it, 2);
if (vs_id == ecs_id(Velocity)) {
Velocity *v = ecs_field(&it, Velocity, 2);
// We can only use ecs_field if the field type is the same for all results,
// but we can get the table column directly.
Velocity *v = ecs_table_get_id(word, it.table, ecs_id(Velocity), it.offset);
// iterate as usual
} else if (vs_id == ecs_id(Speed)) {
Speed *s = ecs_field(&it, Speed, 2);
Speed *s = ecs_table_get_id(word, it.table, ecs_id(Speed), it.offset);
// iterate as usual
}
}
Expand All @@ -1174,10 +1176,12 @@ f.iter([&](flecs::iter& it) {

flecs::id vs_id = it.id(2);
if (vs_id == world.id<Velocity>()) {
auto v = it.field<Velocity>(2);
// We can only use ecs_field if the field type is the same for all results,
// but we can use range() to get the table column directly.
auto v = it.range().get<Velocity>();
// iterate as usual
} else if (vs_id == world.id<Speed>()) {
auto s = it.field<Speed>(2);
auto s = it.range().get<Speed>();
// iterate as usual
}
});
Expand Down
4 changes: 3 additions & 1 deletion flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -33336,6 +33336,7 @@ void flecs_rest_parse_json_ser_iter_params(
flecs_rest_bool_param(req, "term_ids", &desc->serialize_term_ids);
flecs_rest_bool_param(req, "term_labels", &desc->serialize_term_labels);
flecs_rest_bool_param(req, "ids", &desc->serialize_ids);
flecs_rest_bool_param(req, "id_labels", &desc->serialize_id_labels);
flecs_rest_bool_param(req, "sources", &desc->serialize_sources);
flecs_rest_bool_param(req, "variables", &desc->serialize_variables);
flecs_rest_bool_param(req, "is_set", &desc->serialize_is_set);
Expand Down Expand Up @@ -51538,6 +51539,7 @@ void flecs_json_serialize_id_label(
flecs_json_next(buf);
flecs_json_label(buf, world, obj);
}
flecs_json_array_pop(buf);
}

static
Expand Down Expand Up @@ -51691,7 +51693,7 @@ void flecs_json_serialize_iter_result_id_labels(
const ecs_iter_t *it,
ecs_strbuf_t *buf)
{
flecs_json_memberl(buf, "ids");
flecs_json_memberl(buf, "id_labels");
flecs_json_array_push(buf);

for (int i = 0; i < it->field_count; i ++) {
Expand Down

0 comments on commit ce3c825

Please sign in to comment.