Skip to content

Commit 2567645

Browse files
committed
fix snapshots in 2d examples
1 parent 317322b commit 2567645

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

src_testbed/testbed.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,21 +1297,17 @@ fn update_testbed(
12971297
state
12981298
.action_flags
12991299
.set(TestbedActionFlags::TAKE_SNAPSHOT, false);
1300-
// FIXME
1301-
println!(
1302-
"!!!!!!!!! Snapshots are not working any more. Requires broad-phase serialization."
1303-
);
1304-
// state.snapshot = PhysicsSnapshot::new(
1305-
// harness.state.timestep_id,
1306-
// &*harness.physics.broad_phase,
1307-
// &harness.physics.narrow_phase,
1308-
// &harness.physics.islands,
1309-
// &harness.physics.bodies,
1310-
// &harness.physics.colliders,
1311-
// &harness.physics.impulse_joints,
1312-
// &harness.physics.multibody_joints,
1313-
// )
1314-
// .ok();
1300+
state.snapshot = PhysicsSnapshot::new(
1301+
harness.state.timestep_id,
1302+
&harness.physics.broad_phase,
1303+
&harness.physics.narrow_phase,
1304+
&harness.physics.islands,
1305+
&harness.physics.bodies,
1306+
&harness.physics.colliders,
1307+
&harness.physics.impulse_joints,
1308+
&harness.physics.multibody_joints,
1309+
)
1310+
.ok();
13151311

13161312
if let Some(snap) = &state.snapshot {
13171313
snap.print_snapshot_len();

src_testbed/ui.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ fn serialization_string(timestep_id: usize, physics: &PhysicsState) -> String {
414414
// let bf = bincode::serialize(&physics.broad_phase).unwrap();
415415
// println!("bf: {}", Instant::now() - t);
416416
// let t = Instant::now();
417+
let bf = bincode::serialize(&physics.broad_phase).unwrap();
417418
let nf = bincode::serialize(&physics.narrow_phase).unwrap();
418419
// println!("nf: {}", Instant::now() - t);
419420
// let t = Instant::now();
@@ -426,7 +427,7 @@ fn serialization_string(timestep_id: usize, physics: &PhysicsState) -> String {
426427
let js = bincode::serialize(&physics.impulse_joints).unwrap();
427428
// println!("js: {}", Instant::now() - t);
428429
let serialization_time = Instant::now() - t;
429-
// let hash_bf = md5::compute(&bf);
430+
let hash_bf = md5::compute(&bf);
430431
let hash_nf = md5::compute(&nf);
431432
let hash_bodies = md5::compute(&bs);
432433
let hash_colliders = md5::compute(&cs);
@@ -441,8 +442,8 @@ Hashes at frame: {}
441442
|_ Joints [{:.1}KB]: {}"#,
442443
serialization_time.as_secs_f64() * 1000.0,
443444
timestep_id,
444-
"<fixme>", // bf.len() as f32 / 1000.0,
445-
"<fixme>", // format!("{:?}", hash_bf).split_at(10).0,
445+
bf.len() as f32 / 1000.0,
446+
format!("{hash_bf:?}").split_at(10).0,
446447
nf.len() as f32 / 1000.0,
447448
format!("{hash_nf:?}").split_at(10).0,
448449
bs.len() as f32 / 1000.0,

0 commit comments

Comments
 (0)