diff options
| author | Sébastien Crozet <sebcrozet@dimforge.com> | 2024-04-14 15:56:47 +0200 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2024-04-30 23:10:46 +0200 |
| commit | 3ad9c5ad3ba58b3cd4f19c07c6c89880908e0878 (patch) | |
| tree | 06d5253a5ced447c9453e4823ce43ffc1541cee5 /examples2d | |
| parent | 9c5c14070d0a0b0283f3943c0f95552c395f2b97 (diff) | |
| download | rapier-3ad9c5ad3ba58b3cd4f19c07c6c89880908e0878.tar.gz rapier-3ad9c5ad3ba58b3cd4f19c07c6c89880908e0878.tar.bz2 rapier-3ad9c5ad3ba58b3cd4f19c07c6c89880908e0878.zip | |
feat: add a few more debug demos
Diffstat (limited to 'examples2d')
| -rw-r--r-- | examples2d/all_examples2.rs | 2 | ||||
| -rw-r--r-- | examples2d/debug_total_overlap2.rs | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/examples2d/all_examples2.rs b/examples2d/all_examples2.rs index 4cdbf98..6eff54f 100644 --- a/examples2d/all_examples2.rs +++ b/examples2d/all_examples2.rs @@ -15,6 +15,7 @@ mod collision_groups2; mod convex_polygons2; mod damping2; mod debug_box_ball2; +mod debug_total_overlap2; mod drum2; mod heightfield2; mod joint_motor_position2; @@ -82,6 +83,7 @@ pub fn main() { ("Trimesh", trimesh2::init_world), ("Joint motor position", joint_motor_position2::init_world), ("(Debug) box ball", debug_box_ball2::init_world), + ("(Debug) total overlap", debug_total_overlap2::init_world), ]; // Lexicographic sort, with stress tests moved at the end of the list. diff --git a/examples2d/debug_total_overlap2.rs b/examples2d/debug_total_overlap2.rs new file mode 100644 index 0000000..b61ad67 --- /dev/null +++ b/examples2d/debug_total_overlap2.rs @@ -0,0 +1,28 @@ +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(); + + // Build many balls, all spawned at the same point. + let rad = 0.5; + + for _ in 0..100 { + let rigid_body = RigidBodyBuilder::dynamic(); + let handle = bodies.insert(rigid_body); + let collider = ColliderBuilder::cuboid(rad, rad); + colliders.insert_with_parent(collider, handle, &mut bodies); + } + + /* + * Set up the testbed. + */ + testbed.set_world(bodies, colliders, impulse_joints, multibody_joints); + testbed.look_at(point![0.0, 0.0], 50.0); +} |
