bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Pass query change ticks to `QueryParIter` instead of always using change ticks from `World`.

Open chescock opened this issue 2 years ago • 1 comments

Objective

Make Changed<T> filters work reliably with Query::par_iter_mut().

While updating my game to Bevy 0.10, I had a bug where GlobalTransform was not being updated. The problem turned out to be that I was changing Transform in a system that ran after the TransformSystem::TransformPropagate set. I would have expected that to cause a one frame delay in updates, but instead it was ignoring them completely.

When #4777 introduced QueryParIter, it consolidated code in QueryState that used world.last_change_tick() and code in Query that used self.last_change_tick. The new code always uses world.last_change_tick(). This means that any system using Query::par_iter_mut() uses the last_change_tick from the end of the previous frame, and won't see any changes made by systems that ran after it did on the previous frame.

In particular, sync_simple_transforms never sees any Transform changes made by systems that run after it.

Solution

Pass last_change_tick and change_tick from Query to QueryParIter.

chescock avatar Mar 10 '23 20:03 chescock

Whoops, these types got changed by #7905 after my last fetch. Let me rebase and try again.

chescock avatar Mar 10 '23 20:03 chescock

@alice-i-cecile Not sure you are the right person, but this change has the 0.10.1 milestone label but does not appear to be included in that release.

KirmesBude avatar Apr 01 '23 12:04 KirmesBude

@cart was responsible for cherrypicking from the milestone this time.

alice-i-cecile avatar Apr 01 '23 15:04 alice-i-cecile

@cart Would this change warrant another minor release?

KirmesBude avatar Apr 10 '23 13:04 KirmesBude

I prepared the patch for the 0.10.1, and this PR depends on https://github.com/bevyengine/bevy/pull/7905 which is breaking so it couldn't be cherry picked. See https://github.com/bevyengine/bevy/pull/8029#issuecomment-1464440276

mockersf avatar Apr 10 '23 14:04 mockersf

I've cherry picked this PR on this branch, in case we are interested in another minor version. It seems like multiple people are affected by this problem so it might be a good idea.

joseph-gio avatar Apr 11 '23 14:04 joseph-gio

There are 56 days between today and the tentative Bevy 0.11 release date. That does seem like a reasonably long time for this to be broken. I've created a new 0.10.2 milestone and added this to it. Lets take a couple more days to consider other items for the release and then we can do the cut.

cart avatar Apr 11 '23 22:04 cart