bevy_ggrs
bevy_ggrs copied to clipboard
Avoid triggering `Added` and `Changed` queries on all rollbacks?
When a rollback is triggered, bevy_ggrs
restores a saved world snapshot. It updates components by first removing them, and then adding them again. This triggers all queries with Added<Component>
or Changed<Component>
in it, regardless of whether the component was already there and whether it changed.
https://github.com/gschup/bevy_ggrs/blob/b730a0b1a765bca2cb79466c36d86cac08ae1a12/src/world_snapshot.rs#L177
Sometimes systems have queries that react to other components being added or changed, triggering changes on every rollback. Sometimes, this just causes a small performance hit, other times, it leads to buggy behavior because setup code runs multiple times.
Describe the solution you'd like Perhaps it's possible to only update the component if it's different?
Additional context In regular game code, this is usually quite easy to fix or work around, but sometimes the affected code belongs to 3rd party crates, which are a lot harder to solve.