bevy/crates/bevy_core/src
Stephen Martindale be46d1502b Increment FrameCount in CoreStage::Last. (#7477)
# Objective

During testing, I observed that the `FrameCount` resource (`bevy_core`) was being incremented by `FrameCountPlugin` non-deterministically, during update, subject to the whims of the execution order.

The effect was that the counter could and did change while a frame was still in flight, while user-systems were still executing.

## Solution

I have delayed the incrementing of the `FrameCount` resource to `CoreStage::Last`. The resource was described in the documentation as "*a count of rendered frames*" and, after my change, it actually will match that description.

## Changes

- `CoreStage::Last` was chosen so that the counter will be `0` during all earlier stages of the very first execution of the schedule.
- Documentation added declaring *when* the counter is incremented.
- Hint added, directing users towards `u32::wrapping_sub()` because integer overflow is reasonable to expect.

## Note

Even though this change might have a short time-to-live in light of the upcoming *Stageless* changes, I think this is worthwhile – at least as an in-code reminder that this counter should behave predictably.
2023-02-02 21:06:29 +00:00
..
lib.rs Increment FrameCount in CoreStage::Last. (#7477) 2023-02-02 21:06:29 +00:00
name.rs Convenience method for entity naming (#7186) 2023-01-30 20:50:46 +00:00
serde.rs Add serialize feature to bevy_core (#6423) 2022-10-31 21:20:57 +00:00
task_pool_options.rs Break CorePlugin into TaskPoolPlugin, TypeRegistrationPlugin, FrameCountPlugin. (#7083) 2023-01-05 11:42:35 +00:00