Skip to content
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

[WIP] Query random access APIs #32

Closed
wants to merge 3 commits into from

Conversation

caelunshun
Copy link
Contributor

@caelunshun caelunshun commented Nov 12, 2019

Adds random access APIs for Query and extends random access support using a new EntityAccessor type.

  • New EntityAccessor and EntityAccessorMut APIs, which can be created using World::get_accessor() or Query::find_accessor(), allow accessing arbitrary components of an entity. This can be useful for passing an entity and its components to a function without needing access to the World.
  • Query::find() attempts to find component data within a query space for a given entity.
let (mut position, velocity) = <(Write<Position>, Read<Velocity>)>::query()
    .find(entity, &mut world)
    .expect("entity not within query space");

Resolves #19.

Note that this depends on the merging of #27.

TomGillen and others added 3 commits November 9, 2019 14:58
Refactored world and query APIs to require &mut World in safe APIs and added _unchecked alternatives.
@caelunshun
Copy link
Contributor Author

caelunshun commented Nov 21, 2019

Having a bit of difficulty determining whether an entity matches the query. I see View has associated filter types which have an is_match function, but I'm not sure how to pass the entity to these functions. Any tips?

@TomGillen

@caelunshun
Copy link
Contributor Author

There is now a random access API in Legion through the SubWorld API, although I feel the EntityAccessor feature in this PR could be of some use. Also, the alternative random access design in this PR—accessing components through queries rather than a single SubWorld—is a solution to #67. Any thoughts on this?

@caelunshun
Copy link
Contributor Author

I'll close this as #115 provides the EntityAccessor API in the form of World::entity() and World::entity_mut().

@caelunshun caelunshun closed this Mar 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query random access APIs
2 participants