@@ -2831,7 +2831,7 @@ typedef struct ecs_filter_iter_t {
28312831/** Query-iterator specific data */
28322832typedef struct ecs_query_iter_t {
28332833 ecs_query_t *query;
2834- ecs_query_table_node_t *node;
2834+ ecs_query_table_node_t *node, *prev ;
28352835 int32_t sparse_smallest;
28362836 int32_t sparse_first;
28372837 int32_t bitset_first;
@@ -6055,18 +6055,52 @@ bool ecs_query_next_instanced(
60556055 ecs_iter_t *iter);
60566056
60576057/** Returns whether the query data changed since the last iteration.
6058- * This operation must be invoked before obtaining the iterator, as this will
6059- * reset the changed state. The operation will return true after:
6058+ * The operation will return true after:
60606059 * - new entities have been matched with
6060+ * - new tables have been matched/unmatched with
60616061 * - matched entities were deleted
60626062 * - matched components were changed
60636063 *
6064- * @param query The query.
6064+ * The operation will not return true after a write-only (EcsOut) or filter
6065+ * (EcsInOutFilter) term has changed, when a term is not matched with the
6066+ * current table (This subject) or for tag terms.
6067+ *
6068+ * The changed state of a table is reset after it is iterated. If a iterator was
6069+ * not iterated until completion, tables may still be marked as changed.
6070+ *
6071+ * If no iterator is provided the operation will return the changed state of the
6072+ * all matched tables of the query.
6073+ *
6074+ * If an iterator is provided, the operation will return the changed state of
6075+ * the currently returned iterator result. The following preconditions must be
6076+ * met before using an iterator with change detection:
6077+ *
6078+ * - The iterator is a query iterator (created with ecs_query_iter)
6079+ * - The iterator must be valid (ecs_query_next must have returned true)
6080+ * - The iterator must be instanced
6081+ *
6082+ * @param query The query (optional if 'it' is provided).
6083+ * @param it The iterator result to test (optional if 'query' is provided).
60656084 * @return true if entities changed, otherwise false.
60666085 */
60676086FLECS_API
60686087bool ecs_query_changed(
6069- const ecs_query_t *query);
6088+ ecs_query_t *query,
6089+ ecs_iter_t *it);
6090+
6091+ /** Skip a table while iterating.
6092+ * This operation lets the query iterator know that a table was skipped while
6093+ * iterating. A skipped table will not reset its changed state, and the query
6094+ * will not update the dirty flags of the table for its out columns.
6095+ *
6096+ * Only valid iterators must be provided (next has to be called at least once &
6097+ * return true) and the iterator must be a query iterator.
6098+ *
6099+ * @param it The iterator result to skip.
6100+ */
6101+ FLECS_API
6102+ void ecs_query_skip(
6103+ ecs_iter_t *it);
60706104
60716105/** Returns whether query is orphaned.
60726106 * When the parent query of a subquery is deleted, it is left in an orphaned
@@ -18526,7 +18560,7 @@ struct query_base {
1852618560 * @return true if entities changed, otherwise false.
1852718561 */
1852818562 bool changed() {
18529- return ecs_query_changed(m_query);
18563+ return ecs_query_changed(m_query, 0 );
1853018564 }
1853118565
1853218566 /** Returns whether query is orphaned.
0 commit comments