diff options
Diffstat (limited to 'src_testbed/box2d_backend.rs')
| -rw-r--r-- | src_testbed/box2d_backend.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src_testbed/box2d_backend.rs b/src_testbed/box2d_backend.rs index 941c6d5..29fd4fa 100644 --- a/src_testbed/box2d_backend.rs +++ b/src_testbed/box2d_backend.rs @@ -174,6 +174,14 @@ impl Box2dWorld { b2_shape.set_radius(b.radius); b2_shape.set_position(center); body.create_fixture(&b2_shape, &mut fixture_def); + } else if let Some(p) = shape.as_convex_polygon() { + let vertices: Vec<_> = p + .points() + .iter() + .map(|p| na_vec_to_b2_vec(p.coords)) + .collect(); + let b2_shape = b2::PolygonShape::new_with(&vertices); + body.create_fixture(&b2_shape, &mut fixture_def); } else if let Some(c) = shape.as_cuboid() { let b2_shape = b2::PolygonShape::new_box(c.half_extents.x, c.half_extents.y); body.create_fixture(&b2_shape, &mut fixture_def); |
