Add prelude + use vectors for setting linvel/translation in builders
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
use na::{Point2, Vector2};
|
||||
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) {
|
||||
@@ -24,8 +22,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
|
||||
// Build the rigid body.
|
||||
let rb = RigidBodyBuilder::new_dynamic()
|
||||
.translation(x, y)
|
||||
.linvel(x * 10.0, y * 10.0)
|
||||
.translation(vector![x, y])
|
||||
.linvel(vector![x * 10.0, y * 10.0])
|
||||
.angvel(100.0)
|
||||
.linear_damping((i + 1) as f32 * subdiv * 10.0)
|
||||
.angular_damping((num - i) as f32 * subdiv * 10.0)
|
||||
@@ -34,12 +32,12 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
|
||||
// Build the collider.
|
||||
let co = ColliderBuilder::cuboid(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, Vector2::zeros(), ());
|
||||
testbed.look_at(Point2::new(3.0, 2.0), 50.0);
|
||||
testbed.set_world_with_params(bodies, colliders, joints, Vector::zeros(), ());
|
||||
testbed.look_at(point![3.0, 2.0], 50.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user