diff options
Diffstat (limited to 'examples2d/collision_groups2.rs')
| -rw-r--r-- | examples2d/collision_groups2.rs | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/examples2d/collision_groups2.rs b/examples2d/collision_groups2.rs index 08b73fb..3f2a786 100644 --- a/examples2d/collision_groups2.rs +++ b/examples2d/collision_groups2.rs @@ -1,6 +1,4 @@ -use na::{Point2, Point3}; -use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; -use rapier2d::geometry::{ColliderBuilder, ColliderSet, InteractionGroups}; +use rapier2d::prelude::*; use rapier_testbed2d::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) + .translation(vector![0.0, -ground_height]) .build(); let floor_handle = bodies.insert(rigid_body); let collider = ColliderBuilder::cuboid(ground_size, ground_height).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) - .translation(0.0, 1.0) + .translation(vector![0.0, 1.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) - .translation(0.0, 2.0) + .translation(vector![0.0, 2.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 @@ -69,17 +68,19 @@ pub fn init_world(testbed: &mut Testbed) { // Alternate between the green and blue groups. let (group, color) = if i % 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).build(); + let rigid_body = RigidBodyBuilder::new_dynamic() + .translation(vector![x, y]) + .build(); let handle = bodies.insert(rigid_body); let collider = ColliderBuilder::cuboid(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); } @@ -89,5 +90,5 @@ pub fn init_world(testbed: &mut Testbed) { * Set up the testbed. */ testbed.set_world(bodies, colliders, joints); - testbed.look_at(Point2::new(0.0, 1.0), 100.0); + testbed.look_at(point![0.0, 1.0], 100.0); } |
