-
-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offer terminating a query early #1237
Comments
Below is where it crashed in one application. mach\src\module\entities.zig:725:38: 0x68c30d in next (collision.exe.obj) I have not been able to create a small example to reproduce. |
A side not regarding the query system and archtypes. When adding components to entities all the intermediate archtypes will be created, this means the query command will return multiple empty archtypes. E.g.
Now if we query for Game.name then query will return 4 archtypes collections. There are several ways to address that, e.g. prune empty archtypes, set multiple components at a time, i.e. find/or create the archtype that can store all the components. |
The following can be used to clean up using current query interface:
The above depends on lot of the internals to check if the query is finished or not, so better to encapsulate that inside the query result struct. E.g. provide a q.finish(). As Zig provides multiple ways to exit a scope, e.g. errros, break, return, there should be some cleanup facility that can be deferred when the query result is created on the stack. Because next() panics if called after the iteration is completed, it would be useful to have a isFinished(). Alternatively, would be to have next() just return null when the iterator has reached the end. This would match how zig stdlib implements iterators. |
The ECS is queried using mach.Entities.Mod.query, which returns a QueryResult that needs to be iterated through to the end.
If that is not done it will cause errors on subsequent queries.
It would be useful to provide a cleanup function, e.g. finish(), done() that could be deferred so that even if iteration is terminates early because of an error or a user decision it would be cleaned up properly.
The text was updated successfully, but these errors were encountered: