JoJoJet / bevy-trait-query

adds trait queries to the bevy game engine
Apache License 2.0
90 stars 16 forks source link

Add queries that filter based on change detection #42

Closed JoJoJet closed 1 year ago

JoJoJet commented 1 year ago

Rebase of #30. Resolves #23.

Adds support for trait queries that filter based on change detection.

TODO: describe the different kinds of query supported

bzm3r commented 1 year ago

The sysinfo crate is failing miri? https://github.com/JoJoJet/bevy-trait-query/actions/runs/5294385777/jobs/9583666769?pr=42#step:6:344

JoJoJet commented 1 year ago

The sysinfo crate is failing miri? https://github.com/JoJoJet/bevy-trait-query/actions/runs/5294385777/jobs/9583666769?pr=42#step:6:344

This seems to be an issue with Miri, it's been going on for a couple of months. I need to look into this further, and maybe just remove Miri from CI if a fix doesn't seem to be on the horizon.

JoJoJet commented 1 year ago

I've removed much of the code duplication by turning the All filters into iterator adapters over the standard All form. This keeps mostly the same API while removing many lines of code. There's still a bit more deduplication that can be done (specifically in the actual WorldQuery impls), but I think this is an improvement. I still need to think of some approaches for improving the One adapters (maybe even by just removing them as mentioned previously).

I'd appreciate another look @bzm3r :). Also, I think that your idea of removing the added/changed WorldQuerys in favor of just adding methods to ReadTraits and WriteTraits is attractive in its simplicity, though I haven't tried it yet.

JoJoJet commented 1 year ago

I've slimmed down the API for the One filters, and renamed ChangedAll back to AllChanged, since I think it reads better. I originally asked @bzm3r to rename them, but I think I was being a bit too particular.

JoJoJet commented 1 year ago

I took @bzm3r's suggestion of removing the iterator filters in favor of simple iter_added() and iter_changed() methods, which remove a lot of bloat from this PR. I plan on merging this soon.