Testbed: don't open a window in benchmark mode.
This commit is contained in:
@@ -230,7 +230,6 @@ pub struct Testbed {
|
|||||||
gravity: Vector<f32>,
|
gravity: Vector<f32>,
|
||||||
integration_parameters: IntegrationParameters,
|
integration_parameters: IntegrationParameters,
|
||||||
physics: PhysicsState,
|
physics: PhysicsState,
|
||||||
window: Option<Box<Window>>,
|
|
||||||
graphics: GraphicsManager,
|
graphics: GraphicsManager,
|
||||||
nsteps: usize,
|
nsteps: usize,
|
||||||
camera_locked: bool, // Used so that the camera can remain the same before and after we change backend or press the restart button.
|
camera_locked: bool, // Used so that the camera can remain the same before and after we change backend or press the restart button.
|
||||||
@@ -244,7 +243,7 @@ pub struct Testbed {
|
|||||||
// cursor_pos: Point2<f32>,
|
// cursor_pos: Point2<f32>,
|
||||||
events: PhysicsEvents,
|
events: PhysicsEvents,
|
||||||
event_handler: ChannelEventCollector,
|
event_handler: ChannelEventCollector,
|
||||||
ui: TestbedUi,
|
ui: Option<TestbedUi>,
|
||||||
state: TestbedState,
|
state: TestbedState,
|
||||||
#[cfg(all(feature = "dim2", feature = "other-backends"))]
|
#[cfg(all(feature = "dim2", feature = "other-backends"))]
|
||||||
box2d: Option<Box2dWorld>,
|
box2d: Option<Box2dWorld>,
|
||||||
@@ -274,17 +273,8 @@ type CallbacksFluids = Vec<
|
|||||||
impl Testbed {
|
impl Testbed {
|
||||||
pub fn new_empty() -> Testbed {
|
pub fn new_empty() -> Testbed {
|
||||||
let graphics = GraphicsManager::new();
|
let graphics = GraphicsManager::new();
|
||||||
|
|
||||||
#[cfg(feature = "dim3")]
|
|
||||||
let mut window = Box::new(Window::new("rapier: 3d demo"));
|
|
||||||
#[cfg(feature = "dim2")]
|
|
||||||
let mut window = Box::new(Window::new("rapier: 2d demo"));
|
|
||||||
window.set_background_color(0.85, 0.85, 0.85);
|
|
||||||
window.set_framerate_limit(Some(60));
|
|
||||||
window.set_light(Light::StickToCamera);
|
|
||||||
|
|
||||||
let flags = TestbedStateFlags::SLEEP;
|
let flags = TestbedStateFlags::SLEEP;
|
||||||
let ui = TestbedUi::new(&mut window);
|
let ui = None;
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
let mut backend_names = vec!["rapier"];
|
let mut backend_names = vec!["rapier"];
|
||||||
@@ -352,7 +342,6 @@ impl Testbed {
|
|||||||
callbacks: Vec::new(),
|
callbacks: Vec::new(),
|
||||||
#[cfg(feature = "fluids")]
|
#[cfg(feature = "fluids")]
|
||||||
callbacks_fluids: Vec::new(),
|
callbacks_fluids: Vec::new(),
|
||||||
window: Some(window),
|
|
||||||
graphics,
|
graphics,
|
||||||
nsteps: 1,
|
nsteps: 1,
|
||||||
camera_locked: false,
|
camera_locked: false,
|
||||||
@@ -773,7 +762,14 @@ impl Testbed {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let window = mem::replace(&mut self.window, None).unwrap();
|
#[cfg(feature = "dim3")]
|
||||||
|
let mut window = Window::new("rapier: 3d demo");
|
||||||
|
#[cfg(feature = "dim2")]
|
||||||
|
let mut window = Window::new("rapier: 2d demo");
|
||||||
|
window.set_background_color(0.85, 0.85, 0.85);
|
||||||
|
window.set_framerate_limit(Some(60));
|
||||||
|
window.set_light(Light::StickToCamera);
|
||||||
|
self.ui = Some(TestbedUi::new(&mut window));
|
||||||
window.render_loop(self);
|
window.render_loop(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1207,8 +1203,9 @@ impl State for Testbed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn step(&mut self, window: &mut Window) {
|
fn step(&mut self, window: &mut Window) {
|
||||||
self.ui
|
if let Some(ui) = &mut self.ui {
|
||||||
.update(window, &mut self.integration_parameters, &mut self.state);
|
ui.update(window, &mut self.integration_parameters, &mut self.state);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle UI actions.
|
// Handle UI actions.
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user