Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bug #531

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"name": "Debug executable 'all_examples2'",
"cargo": {
"args": [
"build",
"run",
"--bin=all_examples2",
"--package=rapier-examples-2d"
],
Expand Down Expand Up @@ -104,7 +104,8 @@
"name": "Debug executable 'all_benchmarks2'",
"cargo": {
"args": [
"build",
"run",
"--release",
"--bin=all_benchmarks2",
"--package=rapier-benchmarks-2d"
],
Expand Down Expand Up @@ -323,4 +324,4 @@
"cwd": "${workspaceFolder}"
}
]
}
}
43 changes: 32 additions & 11 deletions examples2d/debug_box_ball2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rapier2d::prelude::*;
use rapier2d::{prelude::*, parry};
use rapier_testbed2d::Testbed;

pub fn init_world(testbed: &mut Testbed) {
Expand All @@ -10,28 +10,49 @@ pub fn init_world(testbed: &mut Testbed) {
let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new();

// Bug

let shape1 = SharedShape::capsule_y(5.0, 10.0);
let mut vec = Vec::<Point::<Real>>::with_capacity(3);
unsafe {
vec.push(Point::<Real> { coords : vector![64.0, 507.0] });
vec.push(Point::<Real> { coords : vector![440.0, 326.0] });
vec.push(Point::<Real> { coords : vector![1072.0, 507.0] });
}
let shape2 = SharedShape::convex_polyline(vec);
let shape2 = shape2.unwrap();
let transform1 = Isometry::new(vector![381.592, 348.491], 0.0);
let transform2 = Isometry::new(vector![0.0, 0.0], 0.0);

/*
* Ground
*/
let rad = 1.0;
let rigid_body = RigidBodyBuilder::fixed()
.translation(vector![0.0, -rad])
.rotation(std::f32::consts::PI / 4.0);
.translation(vector![0.0, 0.0])
.rotation(0.0);
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(rad, rad);
colliders.insert_with_parent(collider, handle, &mut bodies);
//let collider = ColliderBuilder::cuboid(rad, rad);
colliders.insert_with_parent(ColliderBuilder::new(shape2.clone()), handle, &mut bodies);

// Build the dynamic box rigid body.
let rigid_body = RigidBodyBuilder::dynamic()
.translation(vector![0.0, 3.0 * rad])
let rigid_body = RigidBodyBuilder::fixed()
.translation(vector![381.592, 348.491])
.can_sleep(false);
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::ball(rad);
colliders.insert_with_parent(collider, handle, &mut bodies);

//let collider = ColliderBuilder::ball(rad);
colliders.insert_with_parent(ColliderBuilder::new(shape1.clone()), handle, &mut bodies);

if let Ok(Some(contact)) = parry::query::contact(
&transform1, shape1.as_ref(), &transform2, shape2.as_ref(), 1.0
) {
panic!("collision");
} else {
print!("no collision");
}
/*
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
testbed.look_at(point![0.0, 0.0], 50.0);
testbed.look_at(point![381.592, 348.491], 1.0);
}