Make Changed, Mutated and Added work on Queries#625
Make Changed, Mutated and Added work on Queries#625DJMcNab wants to merge 4 commits intobevyengine:masterfrom
Conversation
|
I dig it! I think this is probably the right call / the general pattern we should use for single-component Query pointers. I'll do a full review soon. |
|
I was also thinking about make a I haven't done this for resources because I'm planning on unifying the resource query system with the component one (systems/local resources map one to one to entities/components with a global entity for global resources) |
There was a problem hiding this comment.
I like these changes in general, but I do want to address the extra hashing this method introduces before merging. Not<Q> is definitely interesting, but I'd rather do that in a later PR because it does require some thought to make sure it won't break anything.
crates/bevy_ecs/hecs/src/query.rs
Outdated
| ) | ||
| }) | ||
| Some(Self( | ||
| <Q::Fetch as Fetch<'a>>::get(archetype, offset)?, |
There was a problem hiding this comment.
lets eliminate the multiple get_type_state calls here to avoid doing redundant (and relatively expensive) work. Its worth calling out that even after resolving the redundant lookup here, this new approach forces us to do an extra hash for these pointer types (one hash for the Fetch::get() call and one hash for retrieving modified/added state).
We might be able to hack around this by making SingleTypeFetch expose a method that returns the Fetch result and the type state. Its a little cumbersome, but for hot-spot code like this i think its worth doing.
There was a problem hiding this comment.
That makes sense - it also should avoid the extra derefs if we use SingleTypeFetch::Whatever
I'll probably look into this over the weekend
Also make the type parameters have better names
|
@cart I think this is done again, if CI likes it |
|
Superceded by #834. |
This allows you to use
Changed<&mut T>, for example.In theory, Changed, Added and Mutated could be abstracted over
but the savings in typing is probably counteracted by the
amount of added complexity.