@@ -11198,17 +11198,20 @@ ecs_term_t* flecs_filter_or_other_type(
1119811198 if (f->terms[t].oper != EcsOr) {
1119911199 break;
1120011200 }
11201+
1120111202 first = &f->terms[t];
1120211203 }
1120311204
1120411205 if (first) {
1120511206 ecs_world_t *world = f->world;
1120611207 const ecs_type_info_t *first_type;
11208+
1120711209 if (first->idr) {
1120811210 first_type = first->idr->type_info;
1120911211 } else {
1121011212 first_type = ecs_get_type_info(world, first->id);
1121111213 }
11214+
1121211215 const ecs_type_info_t *term_type;
1121311216 if (term->idr) {
1121411217 term_type = term->idr->type_info;
@@ -11219,6 +11222,7 @@ ecs_term_t* flecs_filter_or_other_type(
1121911222 if (first_type == term_type) {
1122011223 return NULL;
1122111224 }
11225+
1122211226 return first;
1122311227 } else {
1122411228 return NULL;
@@ -11328,7 +11332,9 @@ int ecs_filter_finalize(
1132811332 ecs_term_t *first = flecs_filter_or_other_type(f, i);
1132911333 if (first) {
1133011334 if (first == &term[-1]) {
11331- filter_terms ++;
11335+ if (!(term[-1].flags & EcsTermNoData)) {
11336+ filter_terms ++;
11337+ }
1133211338 }
1133311339 filter_term = true;
1133411340 }
@@ -12206,6 +12212,7 @@ bool flecs_term_match_table(
1220612212 bool first,
1220712213 ecs_flags32_t iter_flags)
1220812214{
12215+ ecs_assert(term != NULL, ECS_INTERNAL_ERROR, NULL);
1220912216 const ecs_term_id_t *src = &term->src;
1221012217 ecs_oper_kind_t oper = term->oper;
1221112218 const ecs_table_t *match_table = table;
@@ -13297,9 +13304,11 @@ bool ecs_filter_next_instanced(
1329713304
1329813305 /* Match the remainder of the terms */
1329913306 int32_t skip_term = pivot_term;
13300- if (ecs_id_is_wildcard(filter->terms[pivot_term].id)) {
13301- skip_term = -1;
13302- iter->matches_left = 1;
13307+ if (pivot_term != -1) {
13308+ if (ecs_id_is_wildcard(filter->terms[pivot_term].id)) {
13309+ skip_term = -1;
13310+ iter->matches_left = 1;
13311+ }
1330313312 }
1330413313
1330513314 match = flecs_filter_match_table(world, filter, table,
@@ -13351,18 +13360,18 @@ bool ecs_filter_next_instanced(
1335113360 }
1335213361
1335313362 int32_t t, term_count = filter->term_count;
13354- ecs_term_t *term = NULL;
13363+ ecs_term_t *cur_term = NULL;
1335513364 for (t = 0; t < term_count; t ++) {
1335613365 if (filter->terms[t].field_index == i) {
13357- term = &filter->terms[t];
13366+ cur_term = &filter->terms[t];
1335813367 break;
1335913368 }
1336013369 }
1336113370
1336213371 ecs_assert(term != NULL, ECS_INTERNAL_ERROR, NULL);
1336313372
1336413373 it->columns[i] = column + 1;
13365- flecs_term_match_table(world, term , table,
13374+ flecs_term_match_table(world, cur_term , table,
1336613375 &it->ids[i], &it->columns[i], &it->sources[i],
1336713376 &it->match_indices[i], false, it->flags);
1336813377
0 commit comments