From 31e7d95ff9b4a9accad3035f1c529456e93827fb Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 23 Jan 2022 16:48:24 +0100 Subject: Add f64 testbed --- examples3d-f64/debug_serialized3.rs | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 examples3d-f64/debug_serialized3.rs (limited to 'examples3d-f64/debug_serialized3.rs') diff --git a/examples3d-f64/debug_serialized3.rs b/examples3d-f64/debug_serialized3.rs new file mode 100644 index 0000000..5d4ae19 --- /dev/null +++ b/examples3d-f64/debug_serialized3.rs @@ -0,0 +1,72 @@ +use rapier3d::prelude::*; +use rapier_testbed3d::Testbed; + +#[derive(serde::Deserialize)] +struct State { + 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 ccd_solver: CCDSolver, +} + +pub fn init_world(testbed: &mut Testbed) { + /* + * Set up the testbed. + */ + let bytes = std::fs::read("state.bin").unwrap(); + let mut state: State = bincode::deserialize(&bytes).unwrap(); + + for body in state.bodies.iter_mut() { + dbg!(body.1.position()); + dbg!(body.1.is_ccd_enabled()); + dbg!(body.1.is_sleeping()); + // dbg!(body.1); + body.1.clear_forces(false); + } + + let mut to_remove = vec![]; + for (_, co) in state.colliders.iter() { + if co.shape().as_ball().is_none() { + if let Some(parent) = co.parent() { + let body = &state.bodies[parent]; + if body.is_dynamic() { + to_remove.push(parent); + } + } + } + } + + // for h in to_remove { + // state.bodies.remove( + // h, + // &mut state.islands, + // &mut state.colliders, + // &mut state.impulse_joints, + // &mut state.multibody_joints, + // ); + // } + + 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.ccd_solver = state.ccd_solver; + // testbed.harness_mut().physics.integration_parameters.erp = 0.0; + // testbed + // .harness_mut() + // .physics + // .integration_parameters + // .delassus_inv_factor = 1.0; + + 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]); +} -- cgit From b3b675d2de64d4437748ad46e41cca90c691de1a Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 23 Jan 2022 17:17:30 +0100 Subject: Fix tests build --- examples3d-f64/debug_serialized3.rs | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'examples3d-f64/debug_serialized3.rs') diff --git a/examples3d-f64/debug_serialized3.rs b/examples3d-f64/debug_serialized3.rs index 5d4ae19..e94d7ef 100644 --- a/examples3d-f64/debug_serialized3.rs +++ b/examples3d-f64/debug_serialized3.rs @@ -20,36 +20,6 @@ pub fn init_world(testbed: &mut Testbed) { let bytes = std::fs::read("state.bin").unwrap(); let mut state: State = bincode::deserialize(&bytes).unwrap(); - for body in state.bodies.iter_mut() { - dbg!(body.1.position()); - dbg!(body.1.is_ccd_enabled()); - dbg!(body.1.is_sleeping()); - // dbg!(body.1); - body.1.clear_forces(false); - } - - let mut to_remove = vec![]; - for (_, co) in state.colliders.iter() { - if co.shape().as_ball().is_none() { - if let Some(parent) = co.parent() { - let body = &state.bodies[parent]; - if body.is_dynamic() { - to_remove.push(parent); - } - } - } - } - - // for h in to_remove { - // state.bodies.remove( - // h, - // &mut state.islands, - // &mut state.colliders, - // &mut state.impulse_joints, - // &mut state.multibody_joints, - // ); - // } - testbed.set_world( state.bodies, state.colliders, @@ -60,12 +30,6 @@ pub fn init_world(testbed: &mut Testbed) { testbed.harness_mut().physics.broad_phase = state.broad_phase; testbed.harness_mut().physics.narrow_phase = state.narrow_phase; testbed.harness_mut().physics.ccd_solver = state.ccd_solver; - // testbed.harness_mut().physics.integration_parameters.erp = 0.0; - // testbed - // .harness_mut() - // .physics - // .integration_parameters - // .delassus_inv_factor = 1.0; 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]); -- cgit