feat: add a few more debug demos

This commit is contained in:
Sébastien Crozet
2024-04-14 15:56:47 +02:00
committed by Sébastien Crozet
parent 9c5c14070d
commit 3ad9c5ad3b
11 changed files with 250 additions and 3 deletions

View File

@@ -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.

View File

@@ -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);
}