Add prelude + use vectors for setting linvel/translation in builders
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
use na::Point2;
|
||||
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet, RigidBodyType};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier2d::prelude::*;
|
||||
use rapier_testbed2d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -22,7 +20,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let co = ColliderDesc::new(ground_shape)
|
||||
.translation(-Vector2::y())
|
||||
.build(BodyPartHandle(ground_handle, 0));
|
||||
colliders.insert(co);
|
||||
colliders.insert_with_parent(co);
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -48,10 +46,12 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
};
|
||||
|
||||
// Build the rigid body.
|
||||
let rigid_body = RigidBodyBuilder::new(status).translation(x, y).build();
|
||||
let rigid_body = RigidBodyBuilder::new(status)
|
||||
.translation(vector![x, y])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::ball(rad).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,5 +59,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, 2.5), 5.0);
|
||||
testbed.look_at(point![0.0, 2.5], 5.0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::Point2;
|
||||
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier2d::prelude::*;
|
||||
use rapier_testbed2d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -19,23 +17,23 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let rigid_body = RigidBodyBuilder::new_static().build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size, 1.2).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new_static()
|
||||
.rotation(std::f32::consts::FRAC_PI_2)
|
||||
.translation(ground_size, ground_size * 2.0)
|
||||
.translation(vector![ground_size, ground_size * 2.0])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new_static()
|
||||
.rotation(std::f32::consts::FRAC_PI_2)
|
||||
.translation(-ground_size, ground_size * 2.0)
|
||||
.translation(vector![-ground_size, ground_size * 2.0])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
/*
|
||||
* Create the cubes
|
||||
@@ -53,10 +51,12 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let y = j as f32 * shift + centery + 2.0;
|
||||
|
||||
// Build the rigid body.
|
||||
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).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,5 +64,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, 50.0), 10.0);
|
||||
testbed.look_at(point![0.0, 50.0], 10.0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::Point2;
|
||||
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier2d::prelude::*;
|
||||
use rapier_testbed2d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -19,23 +17,23 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let rigid_body = RigidBodyBuilder::new_static().build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size, 1.2).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new_static()
|
||||
.rotation(std::f32::consts::FRAC_PI_2)
|
||||
.translation(ground_size, ground_size * 4.0)
|
||||
.translation(vector![ground_size, ground_size * 4.0])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size * 4.0, 1.2).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new_static()
|
||||
.rotation(std::f32::consts::FRAC_PI_2)
|
||||
.translation(-ground_size, ground_size * 4.0)
|
||||
.translation(vector![-ground_size, ground_size * 4.0])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size * 4.0, 1.2).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
/*
|
||||
* Create the cubes
|
||||
@@ -55,10 +53,12 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let y = j as f32 * shifty + centery + 3.0;
|
||||
|
||||
// Build the rigid body.
|
||||
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::capsule_y(rad * 1.5, rad).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,5 +66,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, 50.0), 10.0);
|
||||
testbed.look_at(point![0.0, 50.0], 10.0);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use na::Point2;
|
||||
use rand::distributions::{Distribution, Standard};
|
||||
use rand::{rngs::StdRng, SeedableRng};
|
||||
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier2d::prelude::*;
|
||||
use rapier_testbed2d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -21,23 +19,23 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let rigid_body = RigidBodyBuilder::new_static().build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size, 1.2).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new_static()
|
||||
.rotation(std::f32::consts::FRAC_PI_2)
|
||||
.translation(ground_size, ground_size * 2.0)
|
||||
.translation(vector![ground_size, ground_size * 2.0])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new_static()
|
||||
.rotation(std::f32::consts::FRAC_PI_2)
|
||||
.translation(-ground_size, ground_size * 2.0)
|
||||
.translation(vector![-ground_size, ground_size * 2.0])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
/*
|
||||
* Create the convex polygons
|
||||
@@ -58,18 +56,20 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let x = i as f32 * shift - centerx;
|
||||
let y = j as f32 * shift * 2.0 + centery + 2.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 mut points = Vec::new();
|
||||
|
||||
for _ in 0..10 {
|
||||
let pt: Point2<f32> = distribution.sample(&mut rng);
|
||||
let pt: Point<f32> = distribution.sample(&mut rng);
|
||||
points.push(pt * scale);
|
||||
}
|
||||
|
||||
let collider = ColliderBuilder::convex_hull(&points).unwrap().build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,5 +77,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, 50.0), 10.0);
|
||||
testbed.look_at(point![0.0, 50.0], 10.0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use na::{DVector, Point2, Vector2};
|
||||
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use na::DVector;
|
||||
use rapier2d::prelude::*;
|
||||
use rapier_testbed2d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -14,7 +13,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Ground
|
||||
*/
|
||||
let ground_size = Vector2::new(50.0, 1.0);
|
||||
let ground_size = Vector::new(50.0, 1.0);
|
||||
let nsubdivs = 2000;
|
||||
|
||||
let heights = DVector::from_fn(nsubdivs + 1, |i, _| {
|
||||
@@ -28,7 +27,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let rigid_body = RigidBodyBuilder::new_static().build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::heightfield(heights, ground_size).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
/*
|
||||
* Create the cubes
|
||||
@@ -46,15 +45,17 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let y = j as f32 * shift + centery + 3.0;
|
||||
|
||||
// Build the rigid body.
|
||||
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);
|
||||
|
||||
if j % 2 == 0 {
|
||||
let collider = ColliderBuilder::cuboid(rad, rad).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
} else {
|
||||
let collider = ColliderBuilder::ball(rad).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,5 +64,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, 50.0), 10.0);
|
||||
testbed.look_at(point![0.0, 50.0], 10.0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::Point2;
|
||||
use rapier2d::dynamics::{BallJoint, JointSet, RigidBodyBuilder, RigidBodySet, RigidBodyType};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier2d::prelude::*;
|
||||
use rapier_testbed2d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -34,16 +32,16 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
};
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new(status)
|
||||
.translation(fk * shift, -fi * shift)
|
||||
.translation(vector![fk * shift, -fi * shift])
|
||||
.build();
|
||||
let child_handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::ball(rad).build();
|
||||
colliders.insert(collider, child_handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, child_handle, &mut bodies);
|
||||
|
||||
// Vertical joint.
|
||||
if i > 0 {
|
||||
let parent_handle = *body_handles.last().unwrap();
|
||||
let joint = BallJoint::new(Point2::origin(), Point2::new(0.0, shift));
|
||||
let joint = BallJoint::new(Point::origin(), point![0.0, shift]);
|
||||
joints.insert(&mut bodies, parent_handle, child_handle, joint);
|
||||
}
|
||||
|
||||
@@ -51,7 +49,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
if k > 0 {
|
||||
let parent_index = body_handles.len() - numi;
|
||||
let parent_handle = body_handles[parent_index];
|
||||
let joint = BallJoint::new(Point2::origin(), Point2::new(-shift, 0.0));
|
||||
let joint = BallJoint::new(Point::origin(), point![-shift, 0.0]);
|
||||
joints.insert(&mut bodies, parent_handle, child_handle, joint);
|
||||
}
|
||||
|
||||
@@ -63,5 +61,5 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(numk as f32 * rad, numi as f32 * -rad), 5.0);
|
||||
testbed.look_at(point![numk as f32 * rad, numi as f32 * -rad], 5.0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::{Isometry2, Point2};
|
||||
use rapier2d::dynamics::{FixedJoint, JointSet, RigidBodyBuilder, RigidBodySet, RigidBodyType};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier2d::prelude::*;
|
||||
use rapier_testbed2d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -39,18 +37,18 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
};
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new(status)
|
||||
.translation(x + fk * shift, y - fi * shift)
|
||||
.translation(vector![x + fk * shift, y - fi * shift])
|
||||
.build();
|
||||
let child_handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::ball(rad).build();
|
||||
colliders.insert(collider, child_handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, child_handle, &mut bodies);
|
||||
|
||||
// Vertical joint.
|
||||
if i > 0 {
|
||||
let parent_handle = *body_handles.last().unwrap();
|
||||
let joint = FixedJoint::new(
|
||||
Isometry2::identity(),
|
||||
Isometry2::translation(0.0, shift),
|
||||
Isometry::identity(),
|
||||
Isometry::translation(0.0, shift),
|
||||
);
|
||||
joints.insert(&mut bodies, parent_handle, child_handle, joint);
|
||||
}
|
||||
@@ -60,8 +58,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let parent_index = body_handles.len() - num;
|
||||
let parent_handle = body_handles[parent_index];
|
||||
let joint = FixedJoint::new(
|
||||
Isometry2::identity(),
|
||||
Isometry2::translation(-shift, 0.0),
|
||||
Isometry::identity(),
|
||||
Isometry::translation(-shift, 0.0),
|
||||
);
|
||||
joints.insert(&mut bodies, parent_handle, child_handle, joint);
|
||||
}
|
||||
@@ -76,5 +74,5 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(50.0, 50.0), 5.0);
|
||||
testbed.look_at(point![50.0, 50.0], 5.0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::{Point2, Unit, Vector2};
|
||||
use rapier2d::dynamics::{JointSet, PrismaticJoint, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier2d::prelude::*;
|
||||
use rapier_testbed2d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -25,27 +23,31 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
for j in 0..50 {
|
||||
let x = j as f32 * shift * 4.0;
|
||||
|
||||
let ground = RigidBodyBuilder::new_static().translation(x, y).build();
|
||||
let ground = RigidBodyBuilder::new_static()
|
||||
.translation(vector![x, y])
|
||||
.build();
|
||||
let mut curr_parent = bodies.insert(ground);
|
||||
let collider = ColliderBuilder::cuboid(rad, rad).build();
|
||||
colliders.insert(collider, curr_parent, &mut bodies);
|
||||
colliders.insert_with_parent(collider, curr_parent, &mut bodies);
|
||||
|
||||
for i in 0..num {
|
||||
let y = y - (i + 1) as f32 * shift;
|
||||
let density = 1.0;
|
||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y).build();
|
||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
||||
.translation(vector![x, y])
|
||||
.build();
|
||||
let curr_child = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(rad, rad).density(density).build();
|
||||
colliders.insert(collider, curr_child, &mut bodies);
|
||||
colliders.insert_with_parent(collider, curr_child, &mut bodies);
|
||||
|
||||
let axis = if i % 2 == 0 {
|
||||
Unit::new_normalize(Vector2::new(1.0, 1.0))
|
||||
UnitVector::new_normalize(vector![1.0, 1.0])
|
||||
} else {
|
||||
Unit::new_normalize(Vector2::new(-1.0, 1.0))
|
||||
UnitVector::new_normalize(vector![-1.0, 1.0])
|
||||
};
|
||||
|
||||
let mut prism =
|
||||
PrismaticJoint::new(Point2::origin(), axis, Point2::new(0.0, shift), axis);
|
||||
PrismaticJoint::new(Point::origin(), axis, point![0.0, shift], axis);
|
||||
prism.limits_enabled = true;
|
||||
prism.limits[0] = -1.5;
|
||||
prism.limits[1] = 1.5;
|
||||
@@ -60,5 +62,5 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(80.0, 80.0), 15.0);
|
||||
testbed.look_at(point![80.0, 80.0], 15.0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::Point2;
|
||||
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier2d::prelude::*;
|
||||
use rapier_testbed2d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -20,7 +18,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let rigid_body = RigidBodyBuilder::new_static().build();
|
||||
let ground_handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size, ground_thickness).build();
|
||||
colliders.insert(collider, ground_handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
||||
|
||||
/*
|
||||
* Create the cubes
|
||||
@@ -40,10 +38,12 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let y = fi * shift + centery;
|
||||
|
||||
// Build the rigid body.
|
||||
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).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,5 +51,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, 2.5), 5.0);
|
||||
testbed.look_at(point![0.0, 2.5], 5.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user