Skip to content

Commit bd20ccd

Browse files
committed
debug multibody collider example
1 parent adc47ce commit bd20ccd

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

examples3d/all_examples3.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ mod debug_disabled3;
4545
mod debug_internal_edges3;
4646
mod debug_long_chain3;
4747
mod debug_multibody_ang_motor_pos3;
48+
mod debug_multibody_collider3;
4849
mod debug_sleeping_kinematic3;
4950
mod debug_two_cubes3;
5051
mod gyroscopic3;
@@ -146,6 +147,10 @@ pub fn main() {
146147
"(Debug) multibody ang. motor pos.",
147148
debug_multibody_ang_motor_pos3::init_world,
148149
),
150+
(
151+
"(Debug) multibody collider",
152+
debug_multibody_collider3::init_world,
153+
),
149154
];
150155

151156
// Lexicographic sort, with stress tests moved at the end of the list.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use rapier_testbed3d::Testbed;
2+
use rapier3d::prelude::*;
3+
4+
pub fn init_world(testbed: &mut Testbed) {
5+
let mut bodies = RigidBodySet::new();
6+
let mut colliders = ColliderSet::new();
7+
let impulse_joints = ImpulseJointSet::new();
8+
let mut multibody_joints = MultibodyJointSet::new();
9+
10+
// Ground
11+
{
12+
let ground_body = bodies.insert(RigidBodyBuilder::fixed());
13+
colliders.insert_with_parent(
14+
ColliderBuilder::cuboid(50.0, 0.5, 50.0),
15+
ground_body,
16+
&mut bodies,
17+
);
18+
19+
let body = bodies.insert(
20+
RigidBodyBuilder::dynamic()
21+
.translation(Vector::new(0.0, 3.0, 0.0))
22+
.angvel(Vector::new(0.0, 1.0, 0.0)),
23+
);
24+
colliders.insert_with_parent(ColliderBuilder::cuboid(0.5, 0.5, 0.5), body, &mut bodies);
25+
26+
multibody_joints.insert(
27+
ground_body,
28+
body,
29+
RevoluteJointBuilder::new(UnitVector::new_unchecked(Vector::new(0.0, 1.0, 0.0)))
30+
.local_anchor1(Point::new(0.0, 3.0, 0.0)),
31+
true,
32+
);
33+
}
34+
35+
// Another collider
36+
{
37+
let body =
38+
bodies.insert(RigidBodyBuilder::dynamic().translation(Vector::new(3.0, 3.0, 0.0)));
39+
colliders.insert_with_parent(ColliderBuilder::cuboid(0.5, 0.5, 0.5), body, &mut bodies);
40+
}
41+
42+
/*
43+
* Set up the testbed.
44+
*/
45+
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
46+
testbed.look_at(point![-30.0, 4.0, -30.0], point![0.0, 1.0, 0.0]);
47+
}

0 commit comments

Comments
 (0)