From ff2da7fb27f0ea7a15b1dc6b6daf763fe7faf13b Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 6 Sep 2020 12:16:09 +0200 Subject: Move benchmark demos into their own directory. --- examples2d/capsules2.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'examples2d/capsules2.rs') diff --git a/examples2d/capsules2.rs b/examples2d/capsules2.rs index 041edf5..76633bc 100644 --- a/examples2d/capsules2.rs +++ b/examples2d/capsules2.rs @@ -56,9 +56,7 @@ pub fn init_world(testbed: &mut Testbed) { // Build the rigid body. let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y).build(); let handle = bodies.insert(rigid_body); - let collider = ColliderBuilder::capsule_y(rad * 1.5, rad) - .density(1.0) - .build(); + let collider = ColliderBuilder::capsule_y(rad * 1.5, rad).build(); colliders.insert(collider, handle, &mut bodies); } } -- cgit From e7466e2f6923d24e987a34f8ebaf839346af8d4e Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Mon, 28 Sep 2020 10:19:49 +0200 Subject: Move 2D benchmarks into their own directory/crate. --- examples2d/capsules2.rs | 74 ------------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 examples2d/capsules2.rs (limited to 'examples2d/capsules2.rs') diff --git a/examples2d/capsules2.rs b/examples2d/capsules2.rs deleted file mode 100644 index 76633bc..0000000 --- a/examples2d/capsules2.rs +++ /dev/null @@ -1,74 +0,0 @@ -use na::Point2; -use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; -use rapier2d::geometry::{ColliderBuilder, ColliderSet}; -use rapier_testbed2d::Testbed; - -pub fn init_world(testbed: &mut Testbed) { - /* - * World - */ - let mut bodies = RigidBodySet::new(); - let mut colliders = ColliderSet::new(); - let joints = JointSet::new(); - - /* - * Ground - */ - let ground_size = 25.0; - - let rigid_body = RigidBodyBuilder::new_static().build(); - let handle = bodies.insert(rigid_body); - let collider = ColliderBuilder::cuboid(ground_size, 1.2).build(); - colliders.insert(collider, handle, &mut bodies); - - let rigid_body = RigidBodyBuilder::new_static() - .rotation(std::f32::consts::FRAC_PI_2) - .translation(ground_size, ground_size * 4.0) - .build(); - let handle = bodies.insert(rigid_body); - let collider = ColliderBuilder::cuboid(ground_size * 4.0, 1.2).build(); - colliders.insert(collider, handle, &mut bodies); - - let rigid_body = RigidBodyBuilder::new_static() - .rotation(std::f32::consts::FRAC_PI_2) - .translation(-ground_size, ground_size * 4.0) - .build(); - let handle = bodies.insert(rigid_body); - let collider = ColliderBuilder::cuboid(ground_size * 4.0, 1.2).build(); - colliders.insert(collider, handle, &mut bodies); - - /* - * Create the cubes - */ - let num = 26; - let rad = 0.5; - - let shift = rad * 2.0; - let shifty = rad * 5.0; - let centerx = shift * (num as f32) / 2.0; - let centery = shift / 2.0; - - for i in 0..num { - for j in 0usize..num * 5 { - let x = i as f32 * shift - centerx; - let y = j as f32 * shifty + centery + 3.0; - - // Build the rigid body. - let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y).build(); - let handle = bodies.insert(rigid_body); - let collider = ColliderBuilder::capsule_y(rad * 1.5, rad).build(); - colliders.insert(collider, handle, &mut bodies); - } - } - - /* - * Set up the testbed. - */ - testbed.set_world(bodies, colliders, joints); - testbed.look_at(Point2::new(0.0, 50.0), 10.0); -} - -fn main() { - let testbed = Testbed::from_builders(0, vec![("Balls", init_world)]); - testbed.run() -} -- cgit