From f58b4f7c195ab7acf0778ea65c46ebf37ac8188c Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 21 Apr 2024 18:55:11 +0200 Subject: feat: add warmstarting to contact constraints resolution --- examples2d/s2d_far_pyramid.rs | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 examples2d/s2d_far_pyramid.rs (limited to 'examples2d/s2d_far_pyramid.rs') diff --git a/examples2d/s2d_far_pyramid.rs b/examples2d/s2d_far_pyramid.rs new file mode 100644 index 0000000..f5e34c0 --- /dev/null +++ b/examples2d/s2d_far_pyramid.rs @@ -0,0 +1,51 @@ +use rapier2d::prelude::*; +use rapier_testbed2d::Testbed; + +pub fn init_world(testbed: &mut Testbed) { + /* + * World + */ + let mut bodies = RigidBodySet::new(); + let mut colliders = ColliderSet::new(); + let impulse_joints = ImpulseJointSet::new(); + let multibody_joints = MultibodyJointSet::new(); + + let origin = vector![100_000.0, -80_000.0]; + let extent = 1.0; + let friction = 0.6; + + /* + * Ground + */ + let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -1.0] + origin); + let ground_handle = bodies.insert(rigid_body); + let collider = ColliderBuilder::cuboid(100.0, 1.0).friction(friction); + colliders.insert_with_parent(collider, ground_handle, &mut bodies); + + /* + * Create the cubes + */ + let base_count = 10; + + let h = 0.5; + let shift = 1.25 * h; + + for i in 0..base_count { + let y = (2.0 * i as f32 + 1.0) * shift + 0.5; + + for j in i..base_count { + let x = (i as f32 + 1.0) * shift + 2.0 * (j as f32 - i as f32) * shift + - h * base_count as f32; + let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y] + origin); + let ground_handle = bodies.insert(rigid_body); + let collider = ColliderBuilder::cuboid(h, h).friction(friction); + colliders.insert_with_parent(collider, ground_handle, &mut bodies); + } + } + + /* + * Set up the testbed. + */ + testbed.set_world(bodies, colliders, impulse_joints, multibody_joints); + testbed.look_at(point![0.0, 2.5] + origin, 20.0); +} -- cgit From 0a9153e273dc0bdd4ba6443bd7f4dcfc671faac3 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 28 Apr 2024 18:23:30 +0200 Subject: chore: clippy fixes --- examples2d/s2d_far_pyramid.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'examples2d/s2d_far_pyramid.rs') diff --git a/examples2d/s2d_far_pyramid.rs b/examples2d/s2d_far_pyramid.rs index f5e34c0..7948731 100644 --- a/examples2d/s2d_far_pyramid.rs +++ b/examples2d/s2d_far_pyramid.rs @@ -11,7 +11,6 @@ pub fn init_world(testbed: &mut Testbed) { let multibody_joints = MultibodyJointSet::new(); let origin = vector![100_000.0, -80_000.0]; - let extent = 1.0; let friction = 0.6; /* -- cgit