Skip to content

Commit f008662

Browse files
committed
fix some rebase issues
1 parent b92ffca commit f008662

File tree

7 files changed

+43
-42
lines changed

7 files changed

+43
-42
lines changed

crates/bevy_core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ bevy_tasks = { path = "../bevy_tasks", version = "0.8.0-dev" }
1919
bevy_utils = { path = "../bevy_utils", version = "0.8.0-dev" }
2020

2121
# other
22-
crossbeam-channel = "0.5.0"
2322
bytemuck = "1.5"

crates/bevy_render/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev" }
3636
bevy_encase_derive = { path = "../bevy_encase_derive", version = "0.8.0-dev" }
3737
bevy_math = { path = "../bevy_math", version = "0.8.0-dev" }
3838
bevy_reflect = { path = "../bevy_reflect", version = "0.8.0-dev", features = ["bevy"] }
39+
bevy_time = { path = "../bevy_time", version = "0.8.0-dev" }
3940
bevy_transform = { path = "../bevy_transform", version = "0.8.0-dev" }
4041
bevy_window = { path = "../bevy_window", version = "0.8.0-dev" }
4142
bevy_utils = { path = "../bevy_utils", version = "0.8.0-dev" }

crates/bevy_render/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl Plugin for RenderPlugin {
178178
.insert_resource(asset_server)
179179
.init_resource::<RenderGraph>();
180180

181-
let (sender, receiver) = bevy_core::create_time_channels();
181+
let (sender, receiver) = bevy_time::create_time_channels();
182182
app.insert_resource(receiver);
183183
render_app.insert_resource(sender);
184184

crates/bevy_render/src/renderer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::{
1010
settings::{WgpuSettings, WgpuSettingsPriority},
1111
view::{ExtractedWindows, ViewTarget},
1212
};
13-
use bevy_core::TimeSender;
1413
use bevy_ecs::prelude::*;
14+
use bevy_time::TimeSender;
1515
use bevy_utils::Instant;
1616
use std::sync::Arc;
1717
use wgpu::{AdapterInfo, CommandEncoder, Instance, Queue, RequestAdapterOptions};

crates/bevy_time/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ bevy_app = { path = "../bevy_app", version = "0.8.0-dev" }
1515
bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev", features = ["bevy_reflect"] }
1616
bevy_reflect = { path = "../bevy_reflect", version = "0.8.0-dev", features = ["bevy"] }
1717
bevy_utils = { path = "../bevy_utils", version = "0.8.0-dev" }
18+
19+
# other
20+
crossbeam-channel = "0.5.0"

crates/bevy_time/src/lib.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ pub use stopwatch::*;
99
pub use time::*;
1010
pub use timer::*;
1111

12+
use bevy_ecs::system::{Local, Res, ResMut};
13+
use bevy_utils::{tracing::warn, Instant};
14+
use crossbeam_channel::{Receiver, Sender};
15+
1216
pub mod prelude {
1317
//! The Bevy Time Prelude.
1418
#[doc(hidden)]
@@ -41,6 +45,36 @@ impl Plugin for TimePlugin {
4145
}
4246
}
4347

44-
fn time_system(mut time: ResMut<Time>) {
45-
time.update();
48+
/// channel resource used to receive time from render world
49+
pub struct TimeReceiver(pub Receiver<Instant>);
50+
/// channel resource used to send time from render world
51+
pub struct TimeSender(pub Sender<Instant>);
52+
53+
/// create channels used for sending time between render world and app world
54+
pub fn create_time_channels() -> (TimeSender, TimeReceiver) {
55+
// bound the channel to 2 since when pipelined the render phase can finish before
56+
// the time system runs.
57+
let (s, r) = crossbeam_channel::bounded::<Instant>(2);
58+
(TimeSender(s), TimeReceiver(r))
59+
}
60+
61+
/// The system used to update the time. If there is a render world the time is sent from
62+
/// there to this system through channels. Otherwise the time is updated in this system.]
63+
fn time_system(
64+
mut time: ResMut<Time>,
65+
time_recv: Option<Res<TimeReceiver>>,
66+
mut has_received_time: Local<bool>,
67+
) {
68+
if let Some(time_recv) = time_recv {
69+
// TODO: delay checking channel on start by 2 frames when pipelined rendering
70+
// is enabled. This is to make sure we always read the N-2 frame's time.
71+
if let Ok(new_time) = time_recv.0.try_recv() {
72+
time.update_with_instant(new_time);
73+
*has_received_time = true;
74+
} else if *has_received_time {
75+
warn!("time_system did not receive time from render world! Calculations depending on the time may be incorrect.");
76+
}
77+
} else {
78+
time.update();
79+
}
4680
}

crates/bevy_time/src/time.rs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use bevy_ecs::system::{Local, Res, ResMut};
2-
use bevy_utils::{tracing::warn, Duration, Instant};
3-
use crossbeam_channel::{Receiver, Sender};
1+
use bevy_utils::{Duration, Instant};
42

53
/// Tracks elapsed time since the last update and since the App has started
64
#[derive(Debug, Clone)]
@@ -144,40 +142,6 @@ impl Time {
144142
}
145143
}
146144

147-
/// channel resource used to receive time from render world
148-
pub struct TimeReceiver(pub Receiver<Instant>);
149-
/// channel resource used to send time from render world
150-
pub struct TimeSender(pub Sender<Instant>);
151-
152-
/// create channels used for sending time between render world and app world
153-
pub fn create_time_channels() -> (TimeSender, TimeReceiver) {
154-
// bound the channel to 2 since when pipelined the render phase can finish before
155-
// the time system runs.
156-
let (s, r) = crossbeam_channel::bounded::<Instant>(2);
157-
(TimeSender(s), TimeReceiver(r))
158-
}
159-
160-
/// The system used to update the time. If there is a render world the time is sent from
161-
/// there to this system through channels. Otherwise the time is updated in this system.
162-
pub(crate) fn time_system(
163-
mut time: ResMut<Time>,
164-
time_recv: Option<Res<TimeReceiver>>,
165-
mut has_received_time: Local<bool>,
166-
) {
167-
if let Some(time_recv) = time_recv {
168-
// TODO: delay checking channel on start by 2 frames when pipelined rendering
169-
// is enabled. This is to make sure we always read the N-2 frame's time.
170-
if let Ok(new_time) = time_recv.0.try_recv() {
171-
time.update_with_instant(new_time);
172-
*has_received_time = true;
173-
} else if *has_received_time {
174-
warn!("time_system did not receive time from render world! Calculations depending on the time may be incorrect.");
175-
}
176-
} else {
177-
time.update();
178-
}
179-
}
180-
181145
#[cfg(test)]
182146
#[allow(clippy::float_cmp)]
183147
mod tests {

0 commit comments

Comments
 (0)