Skip to content

Commit f8d25c6

Browse files
Run systems in First after Time set
If we accept that [(#4669) Res<Time> is jittery](bevyengine/bevy#4669) then 1. Time is updated in the [TimeSystem set](https://docs.rs/bevy/0.14.2/bevy/time/struct.TimeSystem.html) 2. No work should happen before the Time is updated in a frame This doesn't fix the upstream jitter issue, but we can reduce bevy_ecs_tilemap's potential impact on the issue by making sure any work we do in `First` is done *after* time is updated. \## Solution 1. Create a new `TilemapFirstSet` SystemSet 2. Add bevy_ecs_tilemap `First` systems to `TilemapFirstSet` 3. Order `TilemapFirstSet` systems after the `TimeSystem`. \## Migration This shouldn't require end-user migration, but if you want to run system in First after bevy_ecs_tilemap's work, then the new SystemSet should be used.
1 parent ac311b0 commit f8d25c6

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
//! - Built in animation support – see [`animation` example](https://github.com/StarArawn/bevy_ecs_tilemap/blob/main/examples/animation.rs).
1515
//! - Texture array support.
1616
17-
use bevy::prelude::{
18-
Bundle, Changed, Component, Deref, First, GlobalTransform, InheritedVisibility, Plugin, Query,
19-
Reflect, ReflectComponent, Transform, ViewVisibility, Visibility,
17+
use bevy::{
18+
prelude::{
19+
Bundle, Changed, Component, Deref, First, GlobalTransform, InheritedVisibility,
20+
IntoSystemConfigs, IntoSystemSetConfigs, Plugin, Query, Reflect, ReflectComponent,
21+
SystemSet, Transform, ViewVisibility, Visibility,
22+
},
23+
time::TimeSystem,
2024
};
2125

2226
#[cfg(feature = "render")]
@@ -58,7 +62,7 @@ impl Plugin for TilemapPlugin {
5862
#[cfg(feature = "render")]
5963
app.add_plugins(render::TilemapRenderingPlugin);
6064

61-
app.add_systems(First, update_changed_tile_positions);
65+
app.add_systems(First, update_changed_tile_positions.in_set(TilemapFirstSet));
6266

6367
#[cfg(all(not(feature = "atlas"), feature = "render"))]
6468
{
@@ -83,10 +87,14 @@ impl Plugin for TilemapPlugin {
8387
.register_type::<TileFlip>()
8488
.register_type::<TileStorage>()
8589
.register_type::<TilePosOld>()
86-
.register_type::<AnimatedTile>();
90+
.register_type::<AnimatedTile>()
91+
.configure_sets(First, TilemapFirstSet.after(TimeSystem));
8792
}
8893
}
8994

95+
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
96+
pub struct TilemapFirstSet;
97+
9098
#[derive(Component, Reflect, Debug, Clone, Copy, Deref)]
9199
#[reflect(Component)]
92100
pub struct FrustumCulling(pub bool);

src/render/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use bevy::render::texture::GpuImage;
2424
use crate::{
2525
prelude::TilemapRenderSettings,
2626
tiles::{TilePos, TileStorage},
27+
TilemapFirstSet,
2728
};
2829
use crate::{
2930
prelude::TilemapTexture,
@@ -113,7 +114,7 @@ impl Plugin for TilemapRenderingPlugin {
113114
#[cfg(not(feature = "atlas"))]
114115
app.add_systems(Update, set_texture_to_copy_src);
115116

116-
app.add_systems(First, clear_removed);
117+
app.add_systems(First, clear_removed.in_set(TilemapFirstSet));
117118
app.add_systems(PostUpdate, (removal_helper, removal_helper_tilemap));
118119

119120
app.add_plugins(MaterialTilemapPlugin::<StandardTilemapMaterial>::default());

0 commit comments

Comments
 (0)