Fix testbed compilation with other backends.

This commit is contained in:
Crozet Sébastien
2020-10-26 15:12:10 +01:00
parent e028f45040
commit 3da333f11c
4 changed files with 81 additions and 79 deletions

View File

@@ -18,15 +18,17 @@ jobs:
BENCHBOT_TARGET_COMMIT: ${{ github.event.pull_request.head.sha }} BENCHBOT_TARGET_COMMIT: ${{ github.event.pull_request.head.sha }}
BENCHBOT_SHA: ${{ github.sha }} BENCHBOT_SHA: ${{ github.sha }}
BENCHBOT_HEAD_REF: ${{github.head_ref}} BENCHBOT_HEAD_REF: ${{github.head_ref}}
BENCHBOT_OTHER_BACKENDS: 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Find commit SHA - name: Find commit SHA
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
run: | run: |
echo "::set-env name=BENCHBOT_TARGET_COMMIT::$BENCHBOT_SHA" echo "::set-env name=BENCHBOT_TARGET_COMMIT::$BENCHBOT_SHA"
echo "::set-env name=BENCHBOT_OTHER_BACKENDS::false"
- name: Send 3D bench message - name: Send 3D bench message
shell: bash shell: bash
run: curl -u $BENCHBOT_AMQP_USER:$BENCHBOT_AMQP_PASS run: curl -u $BENCHBOT_AMQP_USER:$BENCHBOT_AMQP_PASS
-i -H "content-type:application/json" -X POST -i -H "content-type:application/json" -X POST
https://$BENCHBOT_AMQP_HOST/api/exchanges/$BENCHBOT_AMQP_VHOST//publish https://$BENCHBOT_AMQP_HOST/api/exchanges/$BENCHBOT_AMQP_VHOST//publish
-d'{"properties":{},"routing_key":"benchmark","payload":"{ \"repository\":\"https://github.com/'$BENCHBOT_TARGET_REPO'\", \"branch\":\"'$GITHUB_REF'\", \"commit\":\"'$BENCHBOT_TARGET_COMMIT'\" }","payload_encoding":"string"}' -d'{"properties":{},"routing_key":"benchmark","payload":"{ \"repository\":\"https://github.com/'$BENCHBOT_TARGET_REPO'\", \"branch\":\"'$GITHUB_REF'\", \"commit\":\"'$BENCHBOT_TARGET_COMMIT'\", \"other_backends\":\"'$BENCHBOT_OTHER_BACKENDS'\" }","payload_encoding":"string"}'

View File

@@ -167,28 +167,26 @@ impl Box2dWorld {
fixture_def.is_sensor = collider.is_sensor(); fixture_def.is_sensor = collider.is_sensor();
fixture_def.filter = b2::Filter::new(); fixture_def.filter = b2::Filter::new();
match collider.shape() { let shape = collider.shape();
Shape::Ball(b) => {
if let Some(b) = shape.as_ball() {
let mut b2_shape = b2::CircleShape::new(); let mut b2_shape = b2::CircleShape::new();
b2_shape.set_radius(b.radius); b2_shape.set_radius(b.radius);
b2_shape.set_position(center); b2_shape.set_position(center);
body.create_fixture(&b2_shape, &mut fixture_def); body.create_fixture(&b2_shape, &mut fixture_def);
} } else if let Some(c) = shape.as_cuboid() {
Shape::Cuboid(c) => {
let b2_shape = b2::PolygonShape::new_box(c.half_extents.x, c.half_extents.y); let b2_shape = b2::PolygonShape::new_box(c.half_extents.x, c.half_extents.y);
body.create_fixture(&b2_shape, &mut fixture_def); body.create_fixture(&b2_shape, &mut fixture_def);
} // } else if let Some(polygon) = shape.as_polygon() {
Shape::Polygon(poly) => { // let points: Vec<_> = poly
let points: Vec<_> = poly // .vertices()
.vertices() // .iter()
.iter() // .map(|p| collider.position_wrt_parent() * p)
.map(|p| collider.position_wrt_parent() * p) // .map(|p| na_vec_to_b2_vec(p.coords))
.map(|p| na_vec_to_b2_vec(p.coords)) // .collect();
.collect(); // let b2_shape = b2::PolygonShape::new_with(&points);
let b2_shape = b2::PolygonShape::new_with(&points); // body.create_fixture(&b2_shape, &mut fixture_def);
body.create_fixture(&b2_shape, &mut fixture_def); } else if let Some(heightfield) = shape.as_heightfield() {
}
Shape::HeightField(heightfield) => {
let mut segments = heightfield.segments(); let mut segments = heightfield.segments();
let seg1 = segments.next().unwrap(); let seg1 = segments.next().unwrap();
let mut vertices = vec![ let mut vertices = vec![
@@ -203,8 +201,8 @@ impl Box2dWorld {
let b2_shape = b2::ChainShape::new_chain(&vertices); let b2_shape = b2::ChainShape::new_chain(&vertices);
body.create_fixture(&b2_shape, &mut fixture_def); body.create_fixture(&b2_shape, &mut fixture_def);
} } else {
_ => eprintln!("Creating a shape unknown to the Box2d backend."), eprintln!("Creating a shape unknown to the Box2d backend.");
} }
} }

View File

@@ -177,19 +177,20 @@ fn nphysics_collider_from_rapier_collider(
) -> Option<ColliderDesc<f32>> { ) -> Option<ColliderDesc<f32>> {
let margin = ColliderDesc::<f32>::default_margin(); let margin = ColliderDesc::<f32>::default_margin();
let mut pos = *collider.position_wrt_parent(); let mut pos = *collider.position_wrt_parent();
let shape = collider.shape();
let shape = match collider.shape() { let shape = if let Some(cuboid) = shape.as_cuboid() {
Shape::Cuboid(cuboid) => {
ShapeHandle::new(Cuboid::new(cuboid.half_extents.map(|e| e - margin))) ShapeHandle::new(Cuboid::new(cuboid.half_extents.map(|e| e - margin)))
} } else if let Some(ball) = shape.as_ball() {
Shape::Ball(ball) => ShapeHandle::new(Ball::new(ball.radius - margin)), ShapeHandle::new(Ball::new(ball.radius - margin))
Shape::Capsule(capsule) => { } else if let Some(capsule) = shape.as_capsule() {
pos *= capsule.transform_wrt_y(); ShapeHandle::new(Capsule::new(capsule.half_height, capsule.radius))
ShapeHandle::new(Capsule::new(capsule.half_height(), capsule.radius)) } else if let Some(heightfield) = shape.as_heightfield() {
} ShapeHandle::new(heightfield.clone())
Shape::HeightField(heightfield) => ShapeHandle::new(heightfield.clone()), } else {
#[cfg(feature = "dim3")] #[cfg(feature = "dim3")]
Shape::Trimesh(trimesh) => ShapeHandle::new(TriMesh::new( if let Some(trimesh) = shape.as_trimesh() {
ShapeHandle::new(TriMesh::new(
trimesh.vertices().to_vec(), trimesh.vertices().to_vec(),
trimesh trimesh
.indices() .indices()
@@ -197,8 +198,15 @@ fn nphysics_collider_from_rapier_collider(
.map(|idx| na::convert(*idx)) .map(|idx| na::convert(*idx))
.collect(), .collect(),
None, None,
)), ))
_ => return None, } else {
return None;
}
#[cfg(feature = "dim2")]
{
return None;
}
}; };
let density = if is_dynamic { collider.density() } else { 0.0 }; let density = if is_dynamic { collider.density() } else { 0.0 };

View File

@@ -422,27 +422,22 @@ fn physx_collider_from_rapier_collider(
collider: &Collider, collider: &Collider,
) -> Option<(ColliderDesc, Isometry3<f32>)> { ) -> Option<(ColliderDesc, Isometry3<f32>)> {
let mut local_pose = *collider.position_wrt_parent(); let mut local_pose = *collider.position_wrt_parent();
let desc = match collider.shape() { let shape = collider.shape();
Shape::Cuboid(cuboid) => ColliderDesc::Box(
let desc = if let Some(cuboid) = shape.as_cuboid() {
ColliderDesc::Box(
cuboid.half_extents.x, cuboid.half_extents.x,
cuboid.half_extents.y, cuboid.half_extents.y,
cuboid.half_extents.z, cuboid.half_extents.z,
), )
Shape::Ball(ball) => ColliderDesc::Sphere(ball.radius), } else if let Some(ball) = shape.as_ball() {
Shape::Capsule(capsule) => { ColliderDesc::Sphere(ball.radius)
let center = capsule.center(); } else if let Some(capsule) = shape.as_capsule() {
let mut dir = capsule.b - capsule.a; let rot = UnitQuaternion::rotation_between(&Vector3::x(), &Vector3::y());
local_pose *= rot.unwrap_or(UnitQuaternion::identity());
if dir.x < 0.0 {
dir = -dir;
}
let rot = UnitQuaternion::rotation_between(&Vector3::x(), &dir);
local_pose *=
Translation3::from(center.coords) * rot.unwrap_or(UnitQuaternion::identity());
ColliderDesc::Capsule(capsule.radius, capsule.height()) ColliderDesc::Capsule(capsule.radius, capsule.height())
} } else if let Some(trimesh) = shape.as_trimesh() {
Shape::Trimesh(trimesh) => ColliderDesc::TriMesh { ColliderDesc::TriMesh {
vertices: trimesh vertices: trimesh
.vertices() .vertices()
.iter() .iter()
@@ -450,11 +445,10 @@ fn physx_collider_from_rapier_collider(
.collect(), .collect(),
indices: trimesh.flat_indices().to_vec(), indices: trimesh.flat_indices().to_vec(),
mesh_scale: Vector3::repeat(1.0).into_glam(), mesh_scale: Vector3::repeat(1.0).into_glam(),
}, }
_ => { } else {
eprintln!("Creating a shape unknown to the PhysX backend."); eprintln!("Creating a shape unknown to the PhysX backend.");
return None; return None;
}
}; };
Some((desc, local_pose)) Some((desc, local_pose))