Add prelude + use vectors for setting linvel/translation in builders
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
use na::Point3;
|
||||
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet, RigidBodyType};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -37,10 +35,12 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let density = 0.477;
|
||||
|
||||
// Build the rigid body.
|
||||
let rigid_body = RigidBodyBuilder::new(status).translation(x, y, z).build();
|
||||
let rigid_body = RigidBodyBuilder::new(status)
|
||||
.translation(vector![x, y, z])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::ball(rad).density(density).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,5 +49,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());
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -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
|
||||
@@ -45,10 +43,12 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let z = k as f32 * shift - 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::cuboid(rad, rad, 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(Point3::new(100.0, 100.0, 100.0), Point3::origin());
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -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,10 +44,12 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let z = k as f32 * shift - 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::capsule_y(rad, rad).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,5 +60,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());
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -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
|
||||
@@ -49,8 +47,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
|
||||
// Build the rigid body.
|
||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
||||
.translation(x, y, z)
|
||||
.linvel(0.0, -1000.0, 0.0)
|
||||
.translation(vector![x, y, z])
|
||||
.linvel(vector![0.0, -1000.0, 0.0])
|
||||
.ccd_enabled(true)
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
@@ -65,7 +63,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
_ => ColliderBuilder::capsule_y(rad, rad),
|
||||
};
|
||||
|
||||
colliders.insert(collider.build(), handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider.build(), handle, &mut bodies);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,5 +74,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());
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -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
|
||||
@@ -45,18 +43,20 @@ 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,5 +67,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());
|
||||
}
|
||||
|
||||
@@ -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 cubes
|
||||
@@ -53,17 +51,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,5 +74,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());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use na::{ComplexField, DMatrix, Point3, Vector3};
|
||||
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use na::ComplexField;
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -14,7 +13,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Ground
|
||||
*/
|
||||
let ground_size = Vector3::new(200.0, 1.0, 200.0);
|
||||
let ground_size = vector![200.0, 1.0, 200.0];
|
||||
let nsubdivs = 20;
|
||||
|
||||
let heights = DMatrix::from_fn(nsubdivs + 1, nsubdivs + 1, |i, j| {
|
||||
@@ -34,7 +33,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
|
||||
@@ -55,15 +54,17 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let z = k as f32 * shift - centerz;
|
||||
|
||||
// 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);
|
||||
|
||||
if j % 2 == 0 {
|
||||
let collider = ColliderBuilder::cuboid(rad, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,5 +74,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());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::Point3;
|
||||
use rapier3d::dynamics::{BallJoint, JointSet, RigidBodyBuilder, RigidBodySet, RigidBodyType};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -29,16 +27,16 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
};
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new(status)
|
||||
.translation(fk * shift, 0.0, fi * shift)
|
||||
.translation(vector![fk * shift, 0.0, 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(Point3::origin(), Point3::new(0.0, 0.0, -shift));
|
||||
let joint = BallJoint::new(Point::origin(), point![0.0, 0.0, -shift]);
|
||||
joints.insert(&mut bodies, parent_handle, child_handle, joint);
|
||||
}
|
||||
|
||||
@@ -46,7 +44,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
if k > 0 {
|
||||
let parent_index = body_handles.len() - num;
|
||||
let parent_handle = body_handles[parent_index];
|
||||
let joint = BallJoint::new(Point3::origin(), Point3::new(-shift, 0.0, 0.0));
|
||||
let joint = BallJoint::new(Point::origin(), point![-shift, 0.0, 0.0]);
|
||||
joints.insert(&mut bodies, parent_handle, child_handle, joint);
|
||||
}
|
||||
|
||||
@@ -58,8 +56,5 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(
|
||||
Point3::new(-110.0, -46.0, 170.0),
|
||||
Point3::new(54.0, -38.0, 29.0),
|
||||
);
|
||||
testbed.look_at(point![-110.0, -46.0, 170.0], point![54.0, -38.0, 29.0]);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::{Isometry3, Point3};
|
||||
use rapier3d::dynamics::{FixedJoint, JointSet, RigidBodyBuilder, RigidBodySet, RigidBodyType};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -42,18 +40,18 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
};
|
||||
|
||||
let rigid_body = RigidBodyBuilder::new(status)
|
||||
.translation(x + fk * shift, y, z + fi * shift)
|
||||
.translation(vector![x + fk * shift, y, z + 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(
|
||||
Isometry3::identity(),
|
||||
Isometry3::translation(0.0, 0.0, -shift),
|
||||
Isometry::identity(),
|
||||
Isometry::translation(0.0, 0.0, -shift),
|
||||
);
|
||||
joints.insert(&mut bodies, parent_handle, child_handle, joint);
|
||||
}
|
||||
@@ -63,8 +61,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(
|
||||
Isometry3::identity(),
|
||||
Isometry3::translation(-shift, 0.0, 0.0),
|
||||
Isometry::identity(),
|
||||
Isometry::translation(-shift, 0.0, 0.0),
|
||||
);
|
||||
joints.insert(&mut bodies, parent_handle, child_handle, joint);
|
||||
}
|
||||
@@ -80,8 +78,5 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(
|
||||
Point3::new(-38.0, 14.0, 108.0),
|
||||
Point3::new(46.0, 12.0, 23.0),
|
||||
);
|
||||
testbed.look_at(point![-38.0, 14.0, 108.0], point![46.0, 12.0, 23.0]);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::{Point3, Unit, Vector3};
|
||||
use rapier3d::dynamics::{JointSet, PrismaticJoint, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -24,33 +22,37 @@ 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, z).build();
|
||||
let ground = RigidBodyBuilder::new_static()
|
||||
.translation(vector![x, y, z])
|
||||
.build();
|
||||
let mut curr_parent = bodies.insert(ground);
|
||||
let collider = ColliderBuilder::cuboid(rad, 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 z = z + (i + 1) as f32 * shift;
|
||||
let density = 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 curr_child = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(rad, 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(Vector3::new(1.0, 1.0, 0.0))
|
||||
UnitVector::new_normalize(vector![1.0, 1.0, 0.0])
|
||||
} else {
|
||||
Unit::new_normalize(Vector3::new(-1.0, 1.0, 0.0))
|
||||
UnitVector::new_normalize(vector![-1.0, 1.0, 0.0])
|
||||
};
|
||||
|
||||
let z = Vector3::z();
|
||||
let z = Vector::z();
|
||||
let mut prism = PrismaticJoint::new(
|
||||
Point3::origin(),
|
||||
Point::origin(),
|
||||
axis,
|
||||
z,
|
||||
Point3::new(0.0, 0.0, -shift),
|
||||
point![0.0, 0.0, -shift],
|
||||
axis,
|
||||
z,
|
||||
);
|
||||
@@ -69,8 +71,5 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(
|
||||
Point3::new(262.0, 63.0, 124.0),
|
||||
Point3::new(101.0, 4.0, -3.0),
|
||||
);
|
||||
testbed.look_at(point![262.0, 63.0, 124.0], point![101.0, 4.0, -3.0]);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use na::{Isometry3, Point3, Vector3};
|
||||
use rapier3d::dynamics::{JointSet, RevoluteJoint, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -22,20 +20,20 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let x = j as f32 * shift * 4.0;
|
||||
|
||||
let ground = RigidBodyBuilder::new_static()
|
||||
.translation(x, y, 0.0)
|
||||
.translation(vector![x, y, 0.0])
|
||||
.build();
|
||||
let mut curr_parent = bodies.insert(ground);
|
||||
let collider = ColliderBuilder::cuboid(rad, rad, rad).build();
|
||||
colliders.insert(collider, curr_parent, &mut bodies);
|
||||
colliders.insert_with_parent(collider, curr_parent, &mut bodies);
|
||||
|
||||
for i in 0..num {
|
||||
// Create four bodies.
|
||||
let z = i as f32 * shift * 2.0 + shift;
|
||||
let positions = [
|
||||
Isometry3::translation(x, y, z),
|
||||
Isometry3::translation(x + shift, y, z),
|
||||
Isometry3::translation(x + shift, y, z + shift),
|
||||
Isometry3::translation(x, y, z + shift),
|
||||
Isometry::translation(x, y, z),
|
||||
Isometry::translation(x + shift, y, z),
|
||||
Isometry::translation(x + shift, y, z + shift),
|
||||
Isometry::translation(x, y, z + shift),
|
||||
];
|
||||
|
||||
let mut handles = [curr_parent; 4];
|
||||
@@ -48,19 +46,19 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let collider = ColliderBuilder::cuboid(rad, rad, rad)
|
||||
.density(density)
|
||||
.build();
|
||||
colliders.insert(collider, handles[k], &mut bodies);
|
||||
colliders.insert_with_parent(collider, handles[k], &mut bodies);
|
||||
}
|
||||
|
||||
// Setup four joints.
|
||||
let o = Point3::origin();
|
||||
let x = Vector3::x_axis();
|
||||
let z = Vector3::z_axis();
|
||||
let o = Point::origin();
|
||||
let x = Vector::x_axis();
|
||||
let z = Vector::z_axis();
|
||||
|
||||
let revs = [
|
||||
RevoluteJoint::new(o, z, Point3::new(0.0, 0.0, -shift), z),
|
||||
RevoluteJoint::new(o, x, Point3::new(-shift, 0.0, 0.0), x),
|
||||
RevoluteJoint::new(o, z, Point3::new(0.0, 0.0, -shift), z),
|
||||
RevoluteJoint::new(o, x, Point3::new(shift, 0.0, 0.0), x),
|
||||
RevoluteJoint::new(o, z, point![0.0, 0.0, -shift], z),
|
||||
RevoluteJoint::new(o, x, point![-shift, 0.0, 0.0], x),
|
||||
RevoluteJoint::new(o, z, point![0.0, 0.0, -shift], z),
|
||||
RevoluteJoint::new(o, x, point![shift, 0.0, 0.0], x),
|
||||
];
|
||||
|
||||
joints.insert(&mut bodies, curr_parent, handles[0], revs[0]);
|
||||
@@ -77,8 +75,5 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(
|
||||
Point3::new(478.0, 83.0, 228.0),
|
||||
Point3::new(134.0, 83.0, -116.0),
|
||||
);
|
||||
testbed.look_at(point![478.0, 83.0, 228.0], point![134.0, 83.0, -116.0]);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use na::{Point3, Vector3};
|
||||
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
pub fn build_block(
|
||||
testbed: &mut Testbed,
|
||||
bodies: &mut RigidBodySet,
|
||||
colliders: &mut ColliderSet,
|
||||
half_extents: Vector3<f32>,
|
||||
shift: Vector3<f32>,
|
||||
half_extents: Vector<f32>,
|
||||
shift: Vector<f32>,
|
||||
mut numx: usize,
|
||||
numy: usize,
|
||||
mut numz: usize,
|
||||
@@ -17,8 +15,8 @@ pub fn build_block(
|
||||
let block_width = 2.0 * half_extents.z * numx as f32;
|
||||
let block_height = 2.0 * half_extents.y * numy as f32;
|
||||
let spacing = (half_extents.z * numx as f32 - half_extents.x) / (numz as f32 - 1.0);
|
||||
let mut color0 = Point3::new(0.7, 0.5, 0.9);
|
||||
let mut color1 = Point3::new(0.6, 1.0, 0.6);
|
||||
let mut color0 = [0.7, 0.5, 0.9];
|
||||
let mut color1 = [0.6, 1.0, 0.6];
|
||||
|
||||
for i in 0..numy {
|
||||
std::mem::swap(&mut numx, &mut numz);
|
||||
@@ -41,15 +39,15 @@ pub fn build_block(
|
||||
|
||||
// Build the rigid body.
|
||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
||||
.translation(
|
||||
.translation(vector![
|
||||
x + dim.x + shift.x,
|
||||
y + dim.y + shift.y,
|
||||
z + dim.z + shift.z,
|
||||
)
|
||||
z + dim.z + shift.z
|
||||
])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z).build();
|
||||
colliders.insert(collider, handle, bodies);
|
||||
colliders.insert_with_parent(collider, handle, bodies);
|
||||
|
||||
testbed.set_initial_body_color(handle, color0);
|
||||
std::mem::swap(&mut color0, &mut color1);
|
||||
@@ -64,15 +62,15 @@ pub fn build_block(
|
||||
for j in 0..(block_width / (dim.z as f32 * 2.0)) as usize {
|
||||
// Build the rigid body.
|
||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
||||
.translation(
|
||||
.translation(vector![
|
||||
i as f32 * dim.x * 2.0 + dim.x + shift.x,
|
||||
dim.y + shift.y + block_height,
|
||||
j as f32 * dim.z * 2.0 + dim.z + shift.z,
|
||||
)
|
||||
j as f32 * dim.z * 2.0 + dim.z + shift.z
|
||||
])
|
||||
.build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z).build();
|
||||
colliders.insert(collider, handle, bodies);
|
||||
colliders.insert_with_parent(collider, handle, bodies);
|
||||
testbed.set_initial_body_color(handle, color0);
|
||||
std::mem::swap(&mut color0, &mut color1);
|
||||
}
|
||||
@@ -94,16 +92,16 @@ 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
|
||||
*/
|
||||
let half_extents = Vector3::new(0.02, 0.1, 0.4) / 2.0 * 10.0;
|
||||
let half_extents = vector![0.02, 0.1, 0.4] / 2.0 * 10.0;
|
||||
let mut block_height = 0.0;
|
||||
// These should only be set to odd values otherwise
|
||||
// the blocks won't align in the nicest way.
|
||||
@@ -120,7 +118,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
half_extents,
|
||||
Vector3::new(-block_width / 2.0, block_height, -block_width / 2.0),
|
||||
vector![-block_width / 2.0, block_height, -block_width / 2.0],
|
||||
numx,
|
||||
numy,
|
||||
numz,
|
||||
@@ -135,5 +133,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());
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use na::{Point3, Vector3};
|
||||
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
fn create_pyramid(
|
||||
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.5;
|
||||
for i in 0usize..stack_height {
|
||||
@@ -24,12 +22,14 @@ fn create_pyramid(
|
||||
- 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 rigid_body_handle = bodies.insert(rigid_body);
|
||||
|
||||
let collider =
|
||||
ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z).build();
|
||||
colliders.insert(collider, rigid_body_handle, bodies);
|
||||
colliders.insert_with_parent(collider, rigid_body_handle, bodies);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,22 +50,22 @@ 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 cubes
|
||||
*/
|
||||
let cube_size = 1.0;
|
||||
let hext = Vector3::repeat(cube_size);
|
||||
let hext = Vector::repeat(cube_size);
|
||||
let bottomy = cube_size;
|
||||
create_pyramid(
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
Vector3::new(0.0, bottomy, 0.0),
|
||||
vector![0.0, bottomy, 0.0],
|
||||
24,
|
||||
hext,
|
||||
);
|
||||
@@ -74,5 +74,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());
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use na::{Point3, Translation3, UnitQuaternion, Vector3};
|
||||
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
fn create_tower_circle(
|
||||
bodies: &mut RigidBodySet,
|
||||
colliders: &mut ColliderSet,
|
||||
offset: Vector3<f32>,
|
||||
offset: Vector<f32>,
|
||||
stack_height: usize,
|
||||
nsubdivs: usize,
|
||||
half_extents: Vector3<f32>,
|
||||
half_extents: Vector<f32>,
|
||||
) {
|
||||
let ang_step = std::f32::consts::PI * 2.0 / nsubdivs as f32;
|
||||
let radius = 1.3 * nsubdivs as f32 * half_extents.x / std::f32::consts::PI;
|
||||
@@ -20,16 +18,16 @@ fn create_tower_circle(
|
||||
let fj = j as f32;
|
||||
let fi = i as f32;
|
||||
let y = fi * shift.y;
|
||||
let pos = Translation3::from(offset)
|
||||
* UnitQuaternion::new(Vector3::y() * (fi / 2.0 + fj) * ang_step)
|
||||
* Translation3::new(0.0, y, radius);
|
||||
let pos = Translation::from(offset)
|
||||
* Rotation::new(Vector::y() * (fi / 2.0 + fj) * ang_step)
|
||||
* Translation::new(0.0, y, radius);
|
||||
|
||||
// Build the rigid body.
|
||||
let rigid_body = RigidBodyBuilder::new_dynamic().position(pos).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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,9 +35,9 @@ fn create_tower_circle(
|
||||
fn create_wall(
|
||||
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;
|
||||
for i in 0usize..stack_height {
|
||||
@@ -52,11 +50,13 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,9 +64,9 @@ fn create_wall(
|
||||
fn create_pyramid(
|
||||
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;
|
||||
|
||||
@@ -83,11 +83,13 @@ fn create_pyramid(
|
||||
- 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,71 +110,71 @@ 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
|
||||
*/
|
||||
let cube_size = 1.0;
|
||||
let hext = Vector3::repeat(cube_size);
|
||||
let hext = Vector::repeat(cube_size);
|
||||
let bottomy = cube_size * 50.0;
|
||||
create_pyramid(
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
Vector3::new(-110.0, bottomy, 0.0),
|
||||
vector![-110.0, bottomy, 0.0],
|
||||
12,
|
||||
hext,
|
||||
);
|
||||
create_pyramid(
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
Vector3::new(-80.0, bottomy, 0.0),
|
||||
vector![-80.0, bottomy, 0.0],
|
||||
12,
|
||||
hext,
|
||||
);
|
||||
create_pyramid(
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
Vector3::new(-50.0, bottomy, 0.0),
|
||||
vector![-50.0, bottomy, 0.0],
|
||||
12,
|
||||
hext,
|
||||
);
|
||||
create_pyramid(
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
Vector3::new(-20.0, bottomy, 0.0),
|
||||
vector![-20.0, bottomy, 0.0],
|
||||
12,
|
||||
hext,
|
||||
);
|
||||
create_wall(
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
Vector3::new(-2.0, bottomy, 0.0),
|
||||
vector![-2.0, bottomy, 0.0],
|
||||
12,
|
||||
hext,
|
||||
);
|
||||
create_wall(
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
Vector3::new(4.0, bottomy, 0.0),
|
||||
vector![4.0, bottomy, 0.0],
|
||||
12,
|
||||
hext,
|
||||
);
|
||||
create_wall(
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
Vector3::new(10.0, bottomy, 0.0),
|
||||
vector![10.0, bottomy, 0.0],
|
||||
12,
|
||||
hext,
|
||||
);
|
||||
create_tower_circle(
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
Vector3::new(25.0, bottomy, 0.0),
|
||||
vector![25.0, bottomy, 0.0],
|
||||
8,
|
||||
24,
|
||||
hext,
|
||||
@@ -182,5 +184,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());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use na::{ComplexField, DMatrix, Point3, Vector3};
|
||||
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier3d::geometry::{ColliderBuilder, ColliderSet, HeightField};
|
||||
use na::ComplexField;
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
pub fn init_world(testbed: &mut Testbed) {
|
||||
@@ -14,7 +13,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Ground
|
||||
*/
|
||||
let ground_size = Vector3::new(200.0, 1.0, 200.0);
|
||||
let ground_size = vector![200.0, 1.0, 200.0];
|
||||
let nsubdivs = 20;
|
||||
|
||||
let heights = DMatrix::from_fn(nsubdivs + 1, nsubdivs + 1, |i, j| {
|
||||
@@ -39,7 +38,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let rigid_body = RigidBodyBuilder::new_static().build();
|
||||
let handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::trimesh(vertices, indices).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||
|
||||
/*
|
||||
* Create the cubes
|
||||
@@ -60,15 +59,17 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let z = k as f32 * shift - centerz;
|
||||
|
||||
// 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);
|
||||
|
||||
if j % 2 == 0 {
|
||||
let collider = ColliderBuilder::cuboid(rad, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,5 +79,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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user