Testbed: add a constructor that calls a custom closure with bevy’s App
This commit is contained in:
committed by
Sébastien Crozet
parent
0ef55c7df7
commit
22f21c14b8
@@ -18,7 +18,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
* Set up the testbed.
|
* Set up the testbed.
|
||||||
*/
|
*/
|
||||||
let bytes = std::fs::read("state.bin").unwrap();
|
let bytes = std::fs::read("state.bin").unwrap();
|
||||||
let mut state: State = bincode::deserialize(&bytes).unwrap();
|
let state: State = bincode::deserialize(&bytes).unwrap();
|
||||||
|
|
||||||
testbed.set_world(
|
testbed.set_world(
|
||||||
state.bodies,
|
state.bodies,
|
||||||
|
|||||||
BIN
examples3d-f64/rapier.data
Normal file
BIN
examples3d-f64/rapier.data
Normal file
Binary file not shown.
@@ -227,7 +227,11 @@ impl TestbedApp {
|
|||||||
self.builders = SceneBuilders(builders)
|
self.builders = SceneBuilders(builders)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(mut self) {
|
pub fn run(self) {
|
||||||
|
self.run_with_init(|_| {})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_with_init(mut self, mut init: impl FnMut(&mut App)) {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
let mut benchmark_mode = false;
|
let mut benchmark_mode = false;
|
||||||
|
|
||||||
@@ -392,8 +396,9 @@ impl TestbedApp {
|
|||||||
.insert_non_send_resource(self.plugins)
|
.insert_non_send_resource(self.plugins)
|
||||||
.add_stage_before(CoreStage::Update, "physics", SystemStage::single_threaded())
|
.add_stage_before(CoreStage::Update, "physics", SystemStage::single_threaded())
|
||||||
.add_system_to_stage("physics", update_testbed.system())
|
.add_system_to_stage("physics", update_testbed.system())
|
||||||
.add_system(egui_focus.system())
|
.add_system(egui_focus.system());
|
||||||
.run();
|
init(&mut app);
|
||||||
|
app.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user