diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-03-06 22:56:12 +0100 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2022-03-20 21:49:16 +0100 |
| commit | c8a2c0379eee04e78462d5a51d1644cd7e66be23 (patch) | |
| tree | 968cb7be797c8b3d1a84129aa1d8f3bc8b7faa58 | |
| parent | 891c08177d090c5f045fd01b5e1b5f7b7b26552f (diff) | |
| download | rapier-c8a2c0379eee04e78462d5a51d1644cd7e66be23.tar.gz rapier-c8a2c0379eee04e78462d5a51d1644cd7e66be23.tar.bz2 rapier-c8a2c0379eee04e78462d5a51d1644cd7e66be23.zip | |
Rename the 3D debug-deserialize example
| -rw-r--r-- | .vscode/tasks.json | 16 | ||||
| -rw-r--r-- | examples3d/all_examples3.rs | 7 | ||||
| -rw-r--r-- | examples3d/debug_deserialize3.rs | 42 | ||||
| -rw-r--r-- | examples3d/debug_serialized3.rs | 38 |
4 files changed, 60 insertions, 43 deletions
diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1f7b545..ce32955 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -25,6 +25,22 @@ "group": "build" }, { + "label": "🚀 run 3d − 💌 deterministic", + "type": "shell", + "command": "cargo", + "args": [ + "run", + "--bin", + "all_examples3", + "--release", + "--features", + "enhanced-determinism", + "--", + "--pause" + ], + "group": "build" + }, + { "label": "🚀 run 3d − 🌈 simd", "type": "shell", "command": "cargo", diff --git a/examples3d/all_examples3.rs b/examples3d/all_examples3.rs index 2b51a7f..1bef234 100644 --- a/examples3d/all_examples3.rs +++ b/examples3d/all_examples3.rs @@ -20,12 +20,12 @@ mod debug_articulations3; mod debug_big_colliders3; mod debug_boxes3; mod debug_cylinder3; +mod debug_deserialize3; mod debug_dynamic_collider_add3; mod debug_friction3; mod debug_infinite_fall3; mod debug_prismatic3; mod debug_rollback3; -mod debug_serialized3; mod debug_shape_modification3; mod debug_triangle3; mod debug_trimesh3; @@ -123,10 +123,7 @@ pub fn main() { "(Debug) shape modification", debug_shape_modification3::init_world, ), - ( - "A serialized", - debug_serialized3::init_world, - ), + ("(Debug) deserialize", debug_deserialize3::init_world), ]; // Lexicographic sort, with stress tests moved at the end of the list. diff --git a/examples3d/debug_deserialize3.rs b/examples3d/debug_deserialize3.rs new file mode 100644 index 0000000..6de4c76 --- /dev/null +++ b/examples3d/debug_deserialize3.rs @@ -0,0 +1,42 @@ +use rapier3d::prelude::*; +use rapier_testbed3d::Testbed; + +#[derive(serde::Deserialize)] +struct PhysicsState { + pub gravity: Vector<f32>, + pub integration_parameters: IntegrationParameters, + pub islands: IslandManager, + pub broad_phase: BroadPhase, + pub narrow_phase: NarrowPhase, + pub bodies: RigidBodySet, + pub colliders: ColliderSet, + pub impulse_joints: ImpulseJointSet, + pub multibody_joints: MultibodyJointSet, +} + +pub fn init_world(testbed: &mut Testbed) { + /* + * Set up the testbed. + */ + let bytes = std::fs::read("state.bin").unwrap(); + match bincode::deserialize(&bytes) { + Ok(state) => { + let state: PhysicsState = state; + testbed.set_world( + state.bodies, + state.colliders, + state.impulse_joints, + state.multibody_joints, + ); + testbed.harness_mut().physics.islands = state.islands; + testbed.harness_mut().physics.broad_phase = state.broad_phase; + testbed.harness_mut().physics.narrow_phase = state.narrow_phase; + testbed.harness_mut().physics.integration_parameters = state.integration_parameters; + testbed.harness_mut().physics.gravity = state.gravity; + + testbed.set_graphics_shift(vector![-541.0, -6377257.0, -61.0]); + testbed.look_at(point![10.0, 10.0, 10.0], point![0.0, 0.0, 0.0]); + } + Err(err) => println!("Failed to deserialize the world state: {}", err), + } +} diff --git a/examples3d/debug_serialized3.rs b/examples3d/debug_serialized3.rs deleted file mode 100644 index 76766c8..0000000 --- a/examples3d/debug_serialized3.rs +++ /dev/null @@ -1,38 +0,0 @@ -use rapier3d::prelude::*; -use rapier_testbed3d::Testbed; - -#[derive(serde::Deserialize)] -struct PhysicsState { - pub gravity: Vector<f32>, - pub integration_parameters: IntegrationParameters, - pub islands: IslandManager, - pub broad_phase: BroadPhase, - pub narrow_phase: NarrowPhase, - pub bodies: RigidBodySet, - pub colliders: ColliderSet, - pub impulse_joints: ImpulseJointSet, - pub multibody_joints: MultibodyJointSet, -} - -pub fn init_world(testbed: &mut Testbed) { - /* - * Set up the testbed. - */ - let bytes = std::fs::read("state.bin").unwrap(); - let mut state: PhysicsState = bincode::deserialize(&bytes).unwrap(); - - testbed.set_world( - state.bodies, - state.colliders, - state.impulse_joints, - state.multibody_joints, - ); - testbed.harness_mut().physics.islands = state.islands; - testbed.harness_mut().physics.broad_phase = state.broad_phase; - testbed.harness_mut().physics.narrow_phase = state.narrow_phase; - testbed.harness_mut().physics.integration_parameters = state.integration_parameters; - testbed.harness_mut().physics.gravity = state.gravity; - - testbed.set_graphics_shift(vector![-541.0, -6377257.0, -61.0]); - testbed.look_at(point![10.0, 10.0, 10.0], point![0.0, 0.0, 0.0]); -} |
