diff options
Diffstat (limited to 'src_testbed/engine.rs')
| -rw-r--r-- | src_testbed/engine.rs | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/src_testbed/engine.rs b/src_testbed/engine.rs index ca2d71f..ca1a2b8 100644 --- a/src_testbed/engine.rs +++ b/src_testbed/engine.rs @@ -350,33 +350,44 @@ impl GraphicsManager { color: Point3<f32>, out: &mut Vec<Node>, ) { - match collider.shape() { - Shape::Ball(ball) => { - out.push(Node::Ball(Ball::new(handle, ball.radius, color, window))) - } - Shape::Polygon(poly) => out.push(Node::Convex(Convex::new( - handle, - poly.vertices().to_vec(), - color, - window, - ))), - Shape::Cuboid(cuboid) => out.push(Node::Box(BoxNode::new( + let shape = collider.shape(); + + if let Some(ball) = shape.as_ball() { + out.push(Node::Ball(Ball::new(handle, ball.radius, color, window))) + } + + // Shape::Polygon(poly) => out.push(Node::Convex(Convex::new( + // handle, + // poly.vertices().to_vec(), + // color, + // window, + // ))), + + if let Some(cuboid) = shape.as_cuboid() { + out.push(Node::Box(BoxNode::new( handle, cuboid.half_extents, color, window, - ))), - Shape::Capsule(capsule) => { - out.push(Node::Capsule(Capsule::new(handle, capsule, color, window))) - } - Shape::Triangle(triangle) => out.push(Node::Mesh(Mesh::new( + ))) + } + + if let Some(capsule) = shape.as_capsule() { + out.push(Node::Capsule(Capsule::new(handle, capsule, color, window))) + } + + if let Some(triangle) = shape.as_triangle() { + out.push(Node::Mesh(Mesh::new( handle, vec![triangle.a, triangle.b, triangle.c], vec![Point3::new(0, 1, 2)], color, window, - ))), - Shape::Trimesh(trimesh) => out.push(Node::Mesh(Mesh::new( + ))) + } + + if let Some(trimesh) = shape.as_trimesh() { + out.push(Node::Mesh(Mesh::new( handle, trimesh.vertices().to_vec(), trimesh @@ -386,21 +397,27 @@ impl GraphicsManager { .collect(), color, window, - ))), - Shape::HeightField(heightfield) => out.push(Node::HeightField(HeightField::new( + ))) + } + + if let Some(heightfield) = shape.as_heightfield() { + out.push(Node::HeightField(HeightField::new( handle, heightfield, color, window, - ))), - #[cfg(feature = "dim3")] - Shape::Cylinder(cylinder) => out.push(Node::Cylinder(Cylinder::new( + ))) + } + + #[cfg(feature = "dim3")] + if let Some(cylinder) = shape.as_cylinder() { + out.push(Node::Cylinder(Cylinder::new( handle, cylinder.half_height, cylinder.radius, color, window, - ))), + ))) } } |
