-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add World::query_scope
API
#4157
Comments
Have we ever considered having archetypes store a Assuming the
...and just have runtime borrow-checking as the default behavior (complete with a If this sounds sane, I like it more than all previous proposals. (For context, |
I'd strongly prefer if we kept runtime panics of that sort opt-in. One of my favorite things about Rust is "if it compiles it works", and there are likely to be dark corners that are rarely run. |
Borrowing a But even before that, using queries and system states on I'm sure a (edit: could still keep the |
I agree, it should be very efficient (and we don't really care about performance checking anyways). I was mostly nervous about the possibility of introducing more code that passes the compiler, but always fails the first time it's run. On reflection though, |
I think something like this is essential for scripting components, I am currently working on a scripting plugin, and a big issue is the fact that script components live in the world. my scripting system essentially needs to iterate over all the scripts, but at the same time let them modify the world. This causes an issue since accessing the scripts already requires a world borrow, I don't see a work around for this short of using a resource to store all of the script contexts, since then I can use scoped resource access and get rid of the first world borrow. And I don't think using a non-exclusive system is a possibility, since script API's need flexible instantaneous access to everything. |
What problem does this solve or what need does it fill?
World::resource_scope
is very useful for complex access patterns in exclusive systems.However, it doesn't work with queries.
What solution would you like?
Add `fn query_scope(|q: Query<Q: WorldQuery, F: WorldQuery + FilterFetch>, world: &mut World |{}).
This temporarily removes all matching entities from the
World
, splitting the borrow.What alternative(s) have you considered?
Use #4090 or
SystemState
instead. This won't cover all use cases: there are some things that can only be done with a&mut World
.Expand
WorldCell
to support queries, per #1555. This is substantially more error prone and slower, as the borrow-checking is done at runtime instead.The text was updated successfully, but these errors were encountered: