rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

Removed query filter

Open alice-i-cecile opened this issue 2 years ago • 2 comments

RENDERED

Addresses https://github.com/bevyengine/bevy/issues/2148 by proposing a Removed<C> query filter.

This works exactly as you might hope, using reliable change detection semantics and mechanisms. Full credit to @maniwani (Joy) for the core idea of just storing another component with the change tick.

Some notes:

  1. We can't fully remove RemovedComponents, since this doesn't work for despawned entities, since they no longer exist to be queried for.
  2. The current design is opt-in, using the machinery from #27, to avoid pointless performance overhead.

alice-i-cecile avatar Nov 17 '21 16:11 alice-i-cecile

It was actually written with derive(Component) in mind, but yes, this is a little stale. Let me take a look :)

alice-i-cecile avatar Jul 16 '22 13:07 alice-i-cecile

One more question this RFC should address is, "What happens to LastRemoved<T> if you insert T again?"

Also, I'm thinking there should be a way to rig this internally so that the options are:

  • no removal detection
  • ticks only
  • ticks + data

Also if the strategy stays as described, I think "no removal detection" should be default if you can't auto-detect it from queries, since LastRemoved<T> being a component will fragment archetypes.

maniwani avatar Aug 11 '22 23:08 maniwani