Implement multibody joints and the new solver
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
name = "rapier-benchmarks-3d"
|
||||
version = "0.1.0"
|
||||
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
parallel = [ "rapier3d/parallel", "rapier_testbed3d/parallel" ]
|
||||
@@ -16,10 +16,10 @@ rand = "0.8"
|
||||
Inflector = "0.11"
|
||||
|
||||
[dependencies.rapier_testbed3d]
|
||||
path = "../build/rapier_testbed3d"
|
||||
path = "../crates/rapier_testbed3d"
|
||||
|
||||
[dependencies.rapier3d]
|
||||
path = "../build/rapier3d"
|
||||
path = "../crates/rapier3d"
|
||||
|
||||
[[bin]]
|
||||
name = "all_benchmarks3"
|
||||
|
||||
@@ -58,10 +58,10 @@ pub fn main() {
|
||||
("Stacks", stacks3::init_world),
|
||||
("Pyramid", pyramid3::init_world),
|
||||
("Trimesh", trimesh3::init_world),
|
||||
("Joint ball", joint_ball3::init_world),
|
||||
("Joint fixed", joint_fixed3::init_world),
|
||||
("Joint revolute", joint_revolute3::init_world),
|
||||
("Joint prismatic", joint_prismatic3::init_world),
|
||||
("ImpulseJoint ball", joint_ball3::init_world),
|
||||
("ImpulseJoint fixed", joint_fixed3::init_world),
|
||||
("ImpulseJoint revolute", joint_revolute3::init_world),
|
||||
("ImpulseJoint prismatic", joint_prismatic3::init_world),
|
||||
("Keva tower", keva3::init_world),
|
||||
];
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Create the balls
|
||||
@@ -48,6 +49,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -58,6 +59,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -59,6 +60,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -73,6 +74,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -66,6 +67,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -73,6 +74,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -73,6 +74,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let mut joints = JointSet::new();
|
||||
let mut impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
let rad = 0.4;
|
||||
let num = 100;
|
||||
@@ -36,16 +37,16 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
// Vertical joint.
|
||||
if i > 0 {
|
||||
let parent_handle = *body_handles.last().unwrap();
|
||||
let joint = BallJoint::new(Point::origin(), point![0.0, 0.0, -shift]);
|
||||
joints.insert(parent_handle, child_handle, joint);
|
||||
let joint = SphericalJoint::new().local_anchor2(point![0.0, 0.0, -shift]);
|
||||
impulse_joints.insert(parent_handle, child_handle, joint);
|
||||
}
|
||||
|
||||
// Horizontal joint.
|
||||
if k > 0 {
|
||||
let parent_index = body_handles.len() - num;
|
||||
let parent_handle = body_handles[parent_index];
|
||||
let joint = BallJoint::new(Point::origin(), point![-shift, 0.0, 0.0]);
|
||||
joints.insert(parent_handle, child_handle, joint);
|
||||
let joint = SphericalJoint::new().local_anchor2(point![-shift, 0.0, 0.0]);
|
||||
impulse_joints.insert(parent_handle, child_handle, joint);
|
||||
}
|
||||
|
||||
body_handles.push(child_handle);
|
||||
@@ -55,6 +56,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![-110.0, -46.0, 170.0], point![54.0, -38.0, 29.0]);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let mut joints = JointSet::new();
|
||||
let mut impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
let rad = 0.4;
|
||||
let num = 5;
|
||||
@@ -49,22 +50,16 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
// Vertical joint.
|
||||
if i > 0 {
|
||||
let parent_handle = *body_handles.last().unwrap();
|
||||
let joint = FixedJoint::new(
|
||||
Isometry::identity(),
|
||||
Isometry::translation(0.0, 0.0, -shift),
|
||||
);
|
||||
joints.insert(parent_handle, child_handle, joint);
|
||||
let joint = FixedJoint::new().local_anchor2(point![0.0, 0.0, -shift]);
|
||||
impulse_joints.insert(parent_handle, child_handle, joint);
|
||||
}
|
||||
|
||||
// Horizontal joint.
|
||||
if k > 0 {
|
||||
let parent_index = body_handles.len() - num;
|
||||
let parent_handle = body_handles[parent_index];
|
||||
let joint = FixedJoint::new(
|
||||
Isometry::identity(),
|
||||
Isometry::translation(-shift, 0.0, 0.0),
|
||||
);
|
||||
joints.insert(parent_handle, child_handle, joint);
|
||||
let joint = FixedJoint::new().local_anchor2(point![-shift, 0.0, 0.0]);
|
||||
impulse_joints.insert(parent_handle, child_handle, joint);
|
||||
}
|
||||
|
||||
body_handles.push(child_handle);
|
||||
@@ -77,6 +72,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![-38.0, 14.0, 108.0], point![46.0, 12.0, 23.0]);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let mut joints = JointSet::new();
|
||||
let mut impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
let rad = 0.4;
|
||||
let num = 5;
|
||||
@@ -47,19 +48,10 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
UnitVector::new_normalize(vector![-1.0, 1.0, 0.0])
|
||||
};
|
||||
|
||||
let z = Vector::z();
|
||||
let mut prism = PrismaticJoint::new(
|
||||
Point::origin(),
|
||||
axis,
|
||||
z,
|
||||
point![0.0, 0.0, -shift],
|
||||
axis,
|
||||
z,
|
||||
);
|
||||
prism.limits_enabled = true;
|
||||
prism.limits[0] = -2.0;
|
||||
prism.limits[1] = 2.0;
|
||||
joints.insert(curr_parent, curr_child, prism);
|
||||
let prism = PrismaticJoint::new(axis)
|
||||
.local_anchor2(point![0.0, 0.0, -shift])
|
||||
.limit_axis([-2.0, 0.0]);
|
||||
impulse_joints.insert(curr_parent, curr_child, prism);
|
||||
|
||||
curr_parent = curr_child;
|
||||
}
|
||||
@@ -70,6 +62,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![262.0, 63.0, 124.0], point![101.0, 4.0, -3.0]);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let mut joints = JointSet::new();
|
||||
let mut impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
let rad = 0.4;
|
||||
let num = 10;
|
||||
@@ -49,22 +50,21 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
colliders.insert_with_parent(collider, handles[k], &mut bodies);
|
||||
}
|
||||
|
||||
// Setup four joints.
|
||||
let o = Point::origin();
|
||||
// Setup four impulse_joints.
|
||||
let x = Vector::x_axis();
|
||||
let z = Vector::z_axis();
|
||||
|
||||
let revs = [
|
||||
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),
|
||||
RevoluteJoint::new(z).local_anchor2(point![0.0, 0.0, -shift]),
|
||||
RevoluteJoint::new(x).local_anchor2(point![-shift, 0.0, 0.0]),
|
||||
RevoluteJoint::new(z).local_anchor2(point![0.0, 0.0, -shift]),
|
||||
RevoluteJoint::new(x).local_anchor2(point![shift, 0.0, 0.0]),
|
||||
];
|
||||
|
||||
joints.insert(curr_parent, handles[0], revs[0]);
|
||||
joints.insert(handles[0], handles[1], revs[1]);
|
||||
joints.insert(handles[1], handles[2], revs[2]);
|
||||
joints.insert(handles[2], handles[3], revs[3]);
|
||||
impulse_joints.insert(curr_parent, handles[0], revs[0]);
|
||||
impulse_joints.insert(handles[0], handles[1], revs[1]);
|
||||
impulse_joints.insert(handles[1], handles[2], revs[2]);
|
||||
impulse_joints.insert(handles[2], handles[3], revs[3]);
|
||||
|
||||
curr_parent = handles[3];
|
||||
}
|
||||
@@ -74,6 +74,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![478.0, 83.0, 228.0], point![134.0, 83.0, -116.0]);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -132,6 +133,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -73,6 +74,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -101,7 +101,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -183,6 +184,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
*/
|
||||
let mut bodies = RigidBodySet::new();
|
||||
let mut colliders = ColliderSet::new();
|
||||
let joints = JointSet::new();
|
||||
let impulse_joints = ImpulseJointSet::new();
|
||||
let multibody_joints = MultibodyJointSet::new();
|
||||
|
||||
/*
|
||||
* Ground
|
||||
@@ -78,6 +79,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![100.0, 100.0, 100.0], Point::origin());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user