aboutsummaryrefslogtreecommitdiff
path: root/examples3d
diff options
context:
space:
mode:
Diffstat (limited to 'examples3d')
-rw-r--r--examples3d/ccd3.rs70
-rw-r--r--examples3d/collision_groups3.rs33
-rw-r--r--examples3d/compound3.rs32
-rw-r--r--examples3d/convex_decomposition3.rs18
-rw-r--r--examples3d/convex_polyhedron3.rs18
-rw-r--r--examples3d/damping3.rs16
-rw-r--r--examples3d/debug_add_remove_collider3.rs22
-rw-r--r--examples3d/debug_big_colliders3.rs14
-rw-r--r--examples3d/debug_boxes3.rs16
-rw-r--r--examples3d/debug_cylinder3.rs16
-rw-r--r--examples3d/debug_dynamic_collider_add3.rs28
-rw-r--r--examples3d/debug_friction3.rs16
-rw-r--r--examples3d/debug_infinite_fall3.rs18
-rw-r--r--examples3d/debug_prismatic3.rs50
-rw-r--r--examples3d/debug_rollback3.rs22
-rw-r--r--examples3d/debug_shape_modification3.rs28
-rw-r--r--examples3d/debug_triangle3.rs20
-rw-r--r--examples3d/debug_trimesh3.rs32
-rw-r--r--examples3d/domino3.rs20
-rw-r--r--examples3d/fountain3.rs14
-rw-r--r--examples3d/harness_capsules3.rs15
-rw-r--r--examples3d/heightfield3.rs23
-rw-r--r--examples3d/joints3.rs143
-rw-r--r--examples3d/keva3.rs38
-rw-r--r--examples3d/locked_rotations3.rs22
-rw-r--r--examples3d/one_way_platforms3.rs39
-rw-r--r--examples3d/platform3.rs20
-rw-r--r--examples3d/primitives3.rs16
-rw-r--r--examples3d/restitution3.rs14
-rw-r--r--examples3d/sensor3.rs39
-rw-r--r--examples3d/trimesh3.rs23
31 files changed, 433 insertions, 462 deletions
diff --git a/examples3d/ccd3.rs b/examples3d/ccd3.rs
index e5dee33..facdec1 100644
--- a/examples3d/ccd3.rs
+++ b/examples3d/ccd3.rs
@@ -1,15 +1,13 @@
-use na::{Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
fn create_wall(
testbed: &mut Testbed,
bodies: &mut RigidBodySet,
colliders: &mut ColliderSet,
- offset: Vector3<f32>,
+ offset: Vector<f32>,
stack_height: usize,
- half_extents: Vector3<f32>,
+ half_extents: Vector<f32>,
) {
let shift = half_extents * 2.0;
let mut k = 0;
@@ -23,22 +21,18 @@ fn create_wall(
- stack_height as f32 * half_extents.z;
// Build the rigid body.
- let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
+ let rigid_body = RigidBodyBuilder::new_dynamic()
+ .translation(vector![x, y, z])
+ .build();
let handle = bodies.insert(rigid_body);
let collider =
ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z).build();
- colliders.insert(collider, handle, bodies);
+ colliders.insert_with_parent(collider, handle, bodies);
k += 1;
if k % 2 == 0 {
- testbed.set_initial_body_color(
- handle,
- Point3::new(255. / 255., 131. / 255., 244.0 / 255.),
- );
+ testbed.set_initial_body_color(handle, [255. / 255., 131. / 255., 244.0 / 255.]);
} else {
- testbed.set_initial_body_color(
- handle,
- Point3::new(131. / 255., 255. / 255., 244.0 / 255.),
- );
+ testbed.set_initial_body_color(handle, [131. / 255., 255. / 255., 244.0 / 255.]);
}
}
}
@@ -59,11 +53,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let ground_handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, ground_handle, &mut bodies);
+ colliders.insert_with_parent(collider, ground_handle, &mut bodies);
/*
* Create the pyramids.
@@ -79,18 +73,18 @@ pub fn init_world(testbed: &mut Testbed) {
testbed,
&mut bodies,
&mut colliders,
- Vector3::new(x, shift_y, 0.0),
+ vector![x, shift_y, 0.0],
num_z,
- Vector3::new(0.5, 0.5, 1.0),
+ vector![0.5, 0.5, 1.0],
);
create_wall(
testbed,
&mut bodies,
&mut colliders,
- Vector3::new(x, shift_y, shift_z),
+ vector![x, shift_y, shift_z],
num_z,
- Vector3::new(0.5, 0.5, 1.0),
+ vector![0.5, 0.5, 1.0],
);
}
@@ -104,35 +98,45 @@ pub fn init_world(testbed: &mut Testbed) {
.sensor(true)
.build();
let rigid_body = RigidBodyBuilder::new_dynamic()
- .linvel(1000.0, 0.0, 0.0)
- .translation(-20.0, shift_y + 2.0, 0.0)
+ .linvel(vector![1000.0, 0.0, 0.0])
+ .translation(vector![-20.0, shift_y + 2.0, 0.0])
.ccd_enabled(true)
.build();
let sensor_handle = bodies.insert(rigid_body);
- colliders.insert(collider, sensor_handle, &mut bodies);
+ colliders.insert_with_parent(collider, sensor_handle, &mut bodies);
// Second rigid-body with CCD enabled.
let collider = ColliderBuilder::ball(1.0).density(10.0).build();
let rigid_body = RigidBodyBuilder::new_dynamic()
- .linvel(1000.0, 0.0, 0.0)
- .translation(-20.0, shift_y + 2.0, shift_z)
+ .linvel(vector![1000.0, 0.0, 0.0])
+ .translation(vector![-20.0, shift_y + 2.0, shift_z])
.ccd_enabled(true)
.build();
let handle = bodies.insert(rigid_body);
- colliders.insert(collider.clone(), handle, &mut bodies);
- testbed.set_initial_body_color(handle, Point3::new(0.2, 0.2, 1.0));
+ colliders.insert_with_parent(collider.clone(), handle, &mut bodies);
+ testbed.set_initial_body_color(handle, [0.2, 0.2, 1.0]);
// Callback that will be executed on the main loop to handle proximities.
testbed.add_callback(move |mut graphics, physics, events, _| {
while let Ok(prox) = events.intersection_events.try_recv() {
let color = if prox.intersecting {
- Point3::new(1.0, 1.0, 0.0)
+ [1.0, 1.0, 0.0]
} else {
- Point3::new(0.5, 0.5, 1.0)
+ [0.5, 0.5, 1.0]
};
- let parent_handle1 = physics.colliders.get(prox.collider1).unwrap().parent();
- let parent_handle2 = physics.colliders.get(prox.collider2).unwrap().parent();
+ let parent_handle1 = physics
+ .colliders
+ .get(prox.collider1)
+ .unwrap()
+ .parent()
+ .unwrap();
+ let parent_handle2 = physics
+ .colliders
+ .get(prox.collider2)
+ .unwrap()
+ .parent()
+ .unwrap();
if let Some(graphics) = &mut graphics {
if parent_handle1 != ground_handle && parent_handle1 != sensor_handle {
@@ -149,5 +153,5 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(100.0, 100.0, 100.0), Point3::origin());
+ testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
}
diff --git a/examples3d/collision_groups3.rs b/examples3d/collision_groups3.rs
index a79a4bc..8db86fa 100644
--- a/examples3d/collision_groups3.rs
+++ b/examples3d/collision_groups3.rs
@@ -1,6 +1,4 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet, InteractionGroups};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -18,11 +16,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let floor_handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, floor_handle, &mut bodies);
+ colliders.insert_with_parent(collider, floor_handle, &mut bodies);
/*
* Setup groups
@@ -34,23 +32,24 @@ pub fn init_world(testbed: &mut Testbed) {
* A green floor that will collide with the GREEN group only.
*/
let green_floor = ColliderBuilder::cuboid(1.0, 0.1, 1.0)
- .translation(0.0, 1.0, 0.0)
+ .translation(vector![0.0, 1.0, 0.0])
.collision_groups(GREEN_GROUP)
.build();
- let green_collider_handle = colliders.insert(green_floor, floor_handle, &mut bodies);
+ let green_collider_handle =
+ colliders.insert_with_parent(green_floor, floor_handle, &mut bodies);
- testbed.set_initial_collider_color(green_collider_handle, Point3::new(0.0, 1.0, 0.0));
+ testbed.set_initial_collider_color(green_collider_handle, [0.0, 1.0, 0.0]);
/*
* A blue floor that will collide with the BLUE group only.
*/
let blue_floor = ColliderBuilder::cuboid(1.0, 0.1, 1.0)
- .translation(0.0, 2.0, 0.0)
+ .translation(vector![0.0, 2.0, 0.0])
.collision_groups(BLUE_GROUP)
.build();
- let blue_collider_handle = colliders.insert(blue_floor, floor_handle, &mut bodies);
+ let blue_collider_handle = colliders.insert_with_parent(blue_floor, floor_handle, &mut bodies);
- testbed.set_initial_collider_color(blue_collider_handle, Point3::new(0.0, 0.0, 1.0));
+ testbed.set_initial_collider_color(blue_collider_handle, [0.0, 0.0, 1.0]);
/*
* Create the cubes
@@ -72,17 +71,19 @@ pub fn init_world(testbed: &mut Testbed) {
// Alternate between the green and blue groups.
let (group, color) = if k % 2 == 0 {
- (GREEN_GROUP, Point3::new(0.0, 1.0, 0.0))
+ (GREEN_GROUP, [0.0, 1.0, 0.0])
} else {
- (BLUE_GROUP, Point3::new(0.0, 0.0, 1.0))
+ (BLUE_GROUP, [0.0, 0.0, 1.0])
};
- let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
+ let rigid_body = RigidBodyBuilder::new_dynamic()
+ .translation(vector![x, y, z])
+ .build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(rad, rad, rad)
.collision_groups(group)
.build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
testbed.set_initial_body_color(handle, color);
}
@@ -93,5 +94,5 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(10.0, 10.0, 10.0), Point3::origin());
+ testbed.look_at(point!(10.0, 10.0, 10.0), Point::origin());
}
diff --git a/examples3d/compound3.rs b/examples3d/compound3.rs
index 51523f3..f5f1de1 100644
--- a/examples3d/compound3.rs
+++ b/examples3d/compound3.rs
@@ -1,6 +1,4 @@
-use na::{Isometry3, Point3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet, SharedShape};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -18,11 +16,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the cubes
@@ -46,40 +44,42 @@ pub fn init_world(testbed: &mut Testbed) {
let z = k as f32 * shift * 2.0 - centerz + offset;
// Build the rigid body.
- let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
+ let rigid_body = RigidBodyBuilder::new_dynamic()
+ .translation(vector![x, y, z])
+ .build();
let handle = bodies.insert(rigid_body);
// First option: attach several colliders to a single rigid-body.
if j < numy / 2 {
let collider1 = ColliderBuilder::cuboid(rad * 10.0, rad, rad).build();
let collider2 = ColliderBuilder::cuboid(rad, rad * 10.0, rad)
- .translation(rad * 10.0, rad * 10.0, 0.0)
+ .translation(vector![rad * 10.0, rad * 10.0, 0.0])
.build();
let collider3 = ColliderBuilder::cuboid(rad, rad * 10.0, rad)
- .translation(-rad * 10.0, rad * 10.0, 0.0)
+ .translation(vector![-rad * 10.0, rad * 10.0, 0.0])
.build();
- colliders.insert(collider1, handle, &mut bodies);
- colliders.insert(collider2, handle, &mut bodies);
- colliders.insert(collider3, handle, &mut bodies);
+ colliders.insert_with_parent(collider1, handle, &mut bodies);
+ colliders.insert_with_parent(collider2, handle, &mut bodies);
+ colliders.insert_with_parent(collider3, handle, &mut bodies);
} else {
// Second option: create a compound shape and attach it to a single collider.
let shapes = vec![
(
- Isometry3::identity(),
+ Isometry::identity(),
SharedShape::cuboid(rad * 10.0, rad, rad),
),
(
- Isometry3::translation(rad * 10.0, rad * 10.0, 0.0),
+ Isometry::translation(rad * 10.0, rad * 10.0, 0.0),
SharedShape::cuboid(rad, rad * 10.0, rad),
),
(
- Isometry3::translation(-rad * 10.0, rad * 10.0, 0.0),
+ Isometry::translation(-rad * 10.0, rad * 10.0, 0.0),
SharedShape::cuboid(rad, rad * 10.0, rad),
),
];
let collider = ColliderBuilder::compound(shapes).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
}
@@ -91,5 +91,5 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(100.0, 100.0, 100.0), Point3::origin());
+ testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
}
diff --git a/examples3d/convex_decomposition3.rs b/examples3d/convex_decomposition3.rs
index 1d19597..5676f6d 100644
--- a/examples3d/convex_decomposition3.rs
+++ b/examples3d/convex_decomposition3.rs
@@ -1,8 +1,6 @@
-use na::Point3;
use obj::raw::object::Polygon;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet, SharedShape};
use rapier3d::parry::bounding_volume;
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
use std::fs::File;
use std::io::BufReader;
@@ -26,11 +24,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the convex decompositions.
@@ -52,7 +50,7 @@ pub fn init_world(testbed: &mut Testbed) {
let mut vertices: Vec<_> = model
.positions
.iter()
- .map(|v| Point3::new(v.0, v.1, v.2))
+ .map(|v| point![v.0, v.1, v.2])
.collect();
use std::iter::FromIterator;
let indices: Vec<_> = model
@@ -90,12 +88,14 @@ pub fn init_world(testbed: &mut Testbed) {
let y = (igeom / width) as f32 * shift + 4.0;
let z = k as f32 * shift;
- let body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
+ let body = RigidBodyBuilder::new_dynamic()
+ .translation(vector![x, y, z])
+ .build();
let handle = bodies.insert(body);
for shape in &shapes {
let collider = ColliderBuilder::new(shape.clone()).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
}
@@ -105,7 +105,7 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(100.0, 100.0, 100.0), Point3::origin());
+ testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
}
fn models() -> Vec<String> {
diff --git a/examples3d/convex_polyhedron3.rs b/examples3d/convex_polyhedron3.rs
index c43a781..896eb03 100644
--- a/examples3d/convex_polyhedron3.rs
+++ b/examples3d/convex_polyhedron3.rs
@@ -1,8 +1,6 @@
-use na::Point3;
use rand::distributions::{Distribution, Standard};
use rand::{rngs::StdRng, SeedableRng};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -20,11 +18,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the polyhedra
@@ -50,17 +48,19 @@ pub fn init_world(testbed: &mut Testbed) {
let mut points = Vec::new();
for _ in 0..10 {
- let pt: Point3<f32> = distribution.sample(&mut rng);
+ let pt: Point<f32> = distribution.sample(&mut rng);
points.push(pt * scale);
}
// Build the rigid body.
- let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
+ let rigid_body = RigidBodyBuilder::new_dynamic()
+ .translation(vector![x, y, z])
+ .build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::round_convex_hull(&points, border_rad)
.unwrap()
.build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
}
@@ -69,5 +69,5 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(30.0, 30.0, 30.0), Point3::origin());
+ testbed.look_at(point![30.0, 30.0, 30.0], Point::origin());
}
diff --git a/examples3d/damping3.rs b/examples3d/damping3.rs
index 3847ceb..c634a0a 100644
--- a/examples3d/damping3.rs
+++ b/examples3d/damping3.rs
@@ -1,6 +1,4 @@
-use na::{Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -24,9 +22,9 @@ pub fn init_world(testbed: &mut Testbed) {
// Build the rigid body.
let rb = RigidBodyBuilder::new_dynamic()
- .translation(x, y, 0.0)
- .linvel(x * 10.0, y * 10.0, 0.0)
- .angvel(Vector3::z() * 100.0)
+ .translation(vector![x, y, 0.0])
+ .linvel(vector![x * 10.0, y * 10.0, 0.0])
+ .angvel(Vector::z() * 100.0)
.linear_damping((i + 1) as f32 * subdiv * 10.0)
.angular_damping((num - i) as f32 * subdiv * 10.0)
.build();
@@ -34,12 +32,12 @@ pub fn init_world(testbed: &mut Testbed) {
// Build the collider.
let co = ColliderBuilder::cuboid(rad, rad, rad).build();
- colliders.insert(co, rb_handle, &mut bodies);
+ colliders.insert_with_parent(co, rb_handle, &mut bodies);
}
/*
* Set up the testbed.
*/
- testbed.set_world_with_params(bodies, colliders, joints, Vector3::zeros(), ());
- testbed.look_at(Point3::new(2.0, 2.5, 20.0), Point3::new(2.0, 2.5, 0.0));
+ testbed.set_world_with_params(bodies, colliders, joints, Vector::zeros(), ());
+ testbed.look_at(point![2.0, 2.5, 20.0], point![2.0, 2.5, 0.0]);
}
diff --git a/examples3d/debug_add_remove_collider3.rs b/examples3d/debug_add_remove_collider3.rs
index 00a0ff3..12d58ec 100644
--- a/examples3d/debug_add_remove_collider3.rs
+++ b/examples3d/debug_add_remove_collider3.rs
@@ -1,6 +1,4 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -17,22 +15,23 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let ground_handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, 0.4).build();
- let mut ground_collider_handle = colliders.insert(collider, ground_handle, &mut bodies);
+ let mut ground_collider_handle =
+ colliders.insert_with_parent(collider, ground_handle, &mut bodies);
/*
* Rolling ball
*/
let ball_rad = 0.1;
let rb = RigidBodyBuilder::new_dynamic()
- .translation(0.0, 0.2, 0.0)
+ .translation(vector![0.0, 0.2, 0.0])
.build();
let ball_handle = bodies.insert(rb);
let collider = ColliderBuilder::ball(ball_rad).density(100.0).build();
- colliders.insert(collider, ball_handle, &mut bodies);
+ colliders.insert_with_parent(collider, ball_handle, &mut bodies);
testbed.add_callback(move |_, physics, _, _| {
// Remove then re-add the ground collider.
@@ -46,14 +45,15 @@ pub fn init_world(testbed: &mut Testbed) {
true,
)
.unwrap();
- ground_collider_handle = physics
- .colliders
- .insert(coll, ground_handle, &mut physics.bodies);
+ ground_collider_handle =
+ physics
+ .colliders
+ .insert_with_parent(coll, ground_handle, &mut physics.bodies);
});
/*
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(10.0, 10.0, 10.0), Point3::origin());
+ testbed.look_at(point![10.0, 10.0, 10.0], Point::origin());
}
diff --git a/examples3d/debug_big_colliders3.rs b/examples3d/debug_big_colliders3.rs
index a524f97..864782f 100644
--- a/examples3d/debug_big_colliders3.rs
+++ b/examples3d/debug_big_colliders3.rs
@@ -1,6 +1,4 @@
-use na::{Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet, HalfSpace, SharedShape};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -16,9 +14,9 @@ pub fn init_world(testbed: &mut Testbed) {
*/
let rigid_body = RigidBodyBuilder::new_static().build();
let handle = bodies.insert(rigid_body);
- let halfspace = SharedShape::new(HalfSpace::new(Vector3::y_axis()));
+ let halfspace = SharedShape::new(HalfSpace::new(Vector::y_axis()));
let collider = ColliderBuilder::new(halfspace).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
let mut curr_y = 0.0;
let mut curr_width = 10_000.0;
@@ -28,11 +26,11 @@ pub fn init_world(testbed: &mut Testbed) {
curr_y += curr_height * 4.0;
let rigid_body = RigidBodyBuilder::new_dynamic()
- .translation(0.0, curr_y, 0.0)
+ .translation(vector![0.0, curr_y, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(curr_width, curr_height, curr_width).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
curr_width /= 5.0;
}
@@ -41,5 +39,5 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(10.0, 10.0, 10.0), Point3::origin());
+ testbed.look_at(point![10.0, 10.0, 10.0], Point::origin());
}
diff --git a/examples3d/debug_boxes3.rs b/examples3d/debug_boxes3.rs
index cba9d01..ea39a8a 100644
--- a/examples3d/debug_boxes3.rs
+++ b/examples3d/debug_boxes3.rs
@@ -1,6 +1,4 @@
-use na::{Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -19,28 +17,28 @@ pub fn init_world(testbed: &mut Testbed) {
for _ in 0..6 {
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
// Build the dynamic box rigid body.
for _ in 0..6 {
let rigid_body = RigidBodyBuilder::new_dynamic()
- .translation(1.1, 0.0, 0.0)
- .rotation(Vector3::new(0.8, 0.2, 0.1))
+ .translation(vector![1.1, 0.0, 0.0])
+ .rotation(vector![0.8, 0.2, 0.1])
.can_sleep(false)
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(2.0, 0.1, 1.0).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
/*
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(10.0, 10.0, 10.0), Point3::origin());
+ testbed.look_at(point![10.0, 10.0, 10.0], Point::origin());
}
diff --git a/examples3d/debug_cylinder3.rs b/examples3d/debug_cylinder3.rs
index 0b68b62..88908c1 100644
--- a/examples3d/debug_cylinder3.rs
+++ b/examples3d/debug_cylinder3.rs
@@ -1,6 +1,4 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
// This shows a bug when a cylinder is in contact with a very large
@@ -21,11 +19,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the cubes
@@ -47,14 +45,16 @@ pub fn init_world(testbed: &mut Testbed) {
let z = -centerz + offset;
// Build the rigid body.
- let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
+ let rigid_body = RigidBodyBuilder::new_dynamic()
+ .translation(vector![x, y, z])
+ .build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cylinder(rad, rad).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(100.0, 100.0, 100.0), Point3::origin());
+ testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
}
diff --git a/examples3d/debug_dynamic_collider_add3.rs b/examples3d/debug_dynamic_collider_add3.rs
index 6a4589b..f66d8ce 100644
--- a/examples3d/debug_dynamic_collider_add3.rs
+++ b/examples3d/debug_dynamic_collider_add3.rs
@@ -1,6 +1,4 @@
-use na::{Isometry3, Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -17,30 +15,30 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBo