remove time & timestep_id from testbed side of things
remove events code
This commit is contained in:
@@ -117,9 +117,6 @@ pub struct TestbedState {
|
|||||||
pub physx_use_two_friction_directions: bool,
|
pub physx_use_two_friction_directions: bool,
|
||||||
pub num_threads: usize,
|
pub num_threads: usize,
|
||||||
pub snapshot: Option<PhysicsSnapshot>,
|
pub snapshot: Option<PhysicsSnapshot>,
|
||||||
// #[cfg(feature = "parallel")]
|
|
||||||
// pub thread_pool: rapier::rayon::ThreadPool,
|
|
||||||
pub timestep_id: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Testbed {
|
pub struct Testbed {
|
||||||
@@ -129,13 +126,10 @@ pub struct Testbed {
|
|||||||
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.
|
||||||
callbacks: Callbacks,
|
callbacks: Callbacks,
|
||||||
plugins: Vec<Box<dyn TestbedPlugin>>,
|
plugins: Vec<Box<dyn TestbedPlugin>>,
|
||||||
time: f32,
|
|
||||||
hide_counters: bool,
|
hide_counters: bool,
|
||||||
// persistant_contacts: HashMap<ContactId, bool>,
|
// persistant_contacts: HashMap<ContactId, bool>,
|
||||||
font: Rc<Font>,
|
font: Rc<Font>,
|
||||||
cursor_pos: Point2<f32>,
|
cursor_pos: Point2<f32>,
|
||||||
events: PhysicsEvents,
|
|
||||||
event_handler: ChannelEventCollector,
|
|
||||||
ui: Option<TestbedUi>,
|
ui: Option<TestbedUi>,
|
||||||
state: TestbedState,
|
state: TestbedState,
|
||||||
harness: Harness,
|
harness: Harness,
|
||||||
@@ -194,7 +188,6 @@ impl Testbed {
|
|||||||
backend_names,
|
backend_names,
|
||||||
example_names: Vec::new(),
|
example_names: Vec::new(),
|
||||||
selected_example: 0,
|
selected_example: 0,
|
||||||
timestep_id: 0,
|
|
||||||
selected_backend: RAPIER_BACKEND,
|
selected_backend: RAPIER_BACKEND,
|
||||||
physx_use_two_friction_directions: true,
|
physx_use_two_friction_directions: true,
|
||||||
num_threads,
|
num_threads,
|
||||||
@@ -219,14 +212,11 @@ impl Testbed {
|
|||||||
graphics,
|
graphics,
|
||||||
nsteps: 1,
|
nsteps: 1,
|
||||||
camera_locked: false,
|
camera_locked: false,
|
||||||
time: 0.0,
|
|
||||||
hide_counters: true,
|
hide_counters: true,
|
||||||
// persistant_contacts: HashMap::new(),
|
// persistant_contacts: HashMap::new(),
|
||||||
font: Font::default(),
|
font: Font::default(),
|
||||||
cursor_pos: Point2::new(0.0f32, 0.0),
|
cursor_pos: Point2::new(0.0f32, 0.0),
|
||||||
ui,
|
ui,
|
||||||
event_handler,
|
|
||||||
events,
|
|
||||||
state,
|
state,
|
||||||
harness,
|
harness,
|
||||||
#[cfg(all(feature = "dim2", feature = "other-backends"))]
|
#[cfg(all(feature = "dim2", feature = "other-backends"))]
|
||||||
@@ -298,9 +288,6 @@ impl Testbed {
|
|||||||
.action_flags
|
.action_flags
|
||||||
.set(TestbedActionFlags::RESET_WORLD_GRAPHICS, true);
|
.set(TestbedActionFlags::RESET_WORLD_GRAPHICS, true);
|
||||||
|
|
||||||
//FIXME: remove time & state.timestep_id if appropriate
|
|
||||||
self.time = 0.0;
|
|
||||||
self.state.timestep_id = 0;
|
|
||||||
self.state.highlighted_body = None;
|
self.state.highlighted_body = None;
|
||||||
|
|
||||||
#[cfg(all(feature = "dim2", feature = "other-backends"))]
|
#[cfg(all(feature = "dim2", feature = "other-backends"))]
|
||||||
@@ -462,6 +449,7 @@ impl Testbed {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME: move this to dedicated benchmarking code
|
||||||
if benchmark_mode {
|
if benchmark_mode {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufWriter, Write};
|
use std::io::{BufWriter, Write};
|
||||||
@@ -494,7 +482,6 @@ impl Testbed {
|
|||||||
let mut timings = Vec::new();
|
let mut timings = Vec::new();
|
||||||
for k in 0..=NUM_ITERS {
|
for k in 0..=NUM_ITERS {
|
||||||
{
|
{
|
||||||
// FIXME: code duplicated from self.step()
|
|
||||||
if self.state.selected_backend == RAPIER_BACKEND {
|
if self.state.selected_backend == RAPIER_BACKEND {
|
||||||
self.harness.step();
|
self.harness.step();
|
||||||
}
|
}
|
||||||
@@ -1109,7 +1096,7 @@ impl State for Testbed {
|
|||||||
.action_flags
|
.action_flags
|
||||||
.set(TestbedActionFlags::TAKE_SNAPSHOT, false);
|
.set(TestbedActionFlags::TAKE_SNAPSHOT, false);
|
||||||
self.state.snapshot = PhysicsSnapshot::new(
|
self.state.snapshot = PhysicsSnapshot::new(
|
||||||
self.state.timestep_id,
|
self.harness.state.timestep_id,
|
||||||
&self.harness.physics.broad_phase,
|
&self.harness.physics.broad_phase,
|
||||||
&self.harness.physics.narrow_phase,
|
&self.harness.physics.narrow_phase,
|
||||||
&self.harness.physics.bodies,
|
&self.harness.physics.bodies,
|
||||||
@@ -1144,7 +1131,8 @@ impl State for Testbed {
|
|||||||
self.set_world(w.3, w.4, w.5);
|
self.set_world(w.3, w.4, w.5);
|
||||||
self.harness.physics.broad_phase = w.1;
|
self.harness.physics.broad_phase = w.1;
|
||||||
self.harness.physics.narrow_phase = w.2;
|
self.harness.physics.narrow_phase = w.2;
|
||||||
self.state.timestep_id = w.0;
|
//FIXME: not completely sure this is valid
|
||||||
|
self.harness.state.timestep_id = w.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1253,7 +1241,6 @@ impl State for Testbed {
|
|||||||
|
|
||||||
if self.state.running != RunMode::Stop {
|
if self.state.running != RunMode::Stop {
|
||||||
for _ in 0..self.nsteps {
|
for _ in 0..self.nsteps {
|
||||||
self.state.timestep_id += 1;
|
|
||||||
if self.state.selected_backend == RAPIER_BACKEND {
|
if self.state.selected_backend == RAPIER_BACKEND {
|
||||||
self.harness.step();
|
self.harness.step();
|
||||||
|
|
||||||
@@ -1311,12 +1298,10 @@ impl State for Testbed {
|
|||||||
// FIXME: should this be handled by harness plugins?
|
// FIXME: should this be handled by harness plugins?
|
||||||
for plugin in &mut self.plugins {
|
for plugin in &mut self.plugins {
|
||||||
{
|
{
|
||||||
plugin.run_callbacks(window, &mut self.harness.physics, self.time);
|
plugin.run_callbacks(window, &mut self.harness.physics, self.harness.state.time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.events.poll_all();
|
|
||||||
|
|
||||||
// if true {
|
// if true {
|
||||||
// // !self.hide_counters {
|
// // !self.hide_counters {
|
||||||
// #[cfg(not(feature = "log"))]
|
// #[cfg(not(feature = "log"))]
|
||||||
@@ -1324,7 +1309,6 @@ impl State for Testbed {
|
|||||||
// #[cfg(feature = "log")]
|
// #[cfg(feature = "log")]
|
||||||
// debug!("{}", self.world.counters);
|
// debug!("{}", self.world.counters);
|
||||||
// }
|
// }
|
||||||
self.time += self.harness.physics.integration_parameters.dt();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1425,7 +1409,7 @@ Hashes at frame: {}
|
|||||||
|_ Joints [{:.1}KB]: {:?}"#,
|
|_ Joints [{:.1}KB]: {:?}"#,
|
||||||
profile,
|
profile,
|
||||||
serialization_time,
|
serialization_time,
|
||||||
self.state.timestep_id,
|
self.harness.state.timestep_id,
|
||||||
bf.len() as f32 / 1000.0,
|
bf.len() as f32 / 1000.0,
|
||||||
hash_bf,
|
hash_bf,
|
||||||
nf.len() as f32 / 1000.0,
|
nf.len() as f32 / 1000.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user