aboutsummaryrefslogtreecommitdiff
path: root/src_testbed/objects/node.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-04-28 13:19:58 +0200
committerSébastien Crozet <developer@crozet.re>2022-04-28 13:19:58 +0200
commit5063fa420392455f7926f1ba3e65612f79a0b066 (patch)
tree6efb5ee5b045521f9c4ffe605ac2dcfb593ba1ff /src_testbed/objects/node.rs
parent8ffb0d1658d448074f5ca2b77aee33f755761e24 (diff)
downloadrapier-5063fa420392455f7926f1ba3e65612f79a0b066.tar.gz
rapier-5063fa420392455f7926f1ba3e65612f79a0b066.tar.bz2
rapier-5063fa420392455f7926f1ba3e65612f79a0b066.zip
Testbed: switch to bevy 0.7
Diffstat (limited to 'src_testbed/objects/node.rs')
-rw-r--r--src_testbed/objects/node.rs36
1 files changed, 24 insertions, 12 deletions
diff --git a/src_testbed/objects/node.rs b/src_testbed/objects/node.rs
index 6a4807f..ba7a2aa 100644
--- a/src_testbed/objects/node.rs
+++ b/src_testbed/objects/node.rs
@@ -210,7 +210,8 @@ impl EntityWithGraphics {
// Cuboid mesh
//
let cuboid = bevy_mesh_from_polyline(Cuboid::new(Vector2::new(1.0, 1.0)).to_polyline());
- out.insert(ShapeType::Cuboid, meshes.add(cuboid));
+ out.insert(ShapeType::Cuboid, meshes.add(cuboid.clone()));
+ out.insert(ShapeType::RoundCuboid, meshes.add(cuboid));
//
// Ball mesh
@@ -228,7 +229,8 @@ impl EntityWithGraphics {
// Cuboid mesh
//
let cuboid = Mesh::from(shape::Cube { size: 2.0 });
- out.insert(ShapeType::Cuboid, meshes.add(cuboid));
+ out.insert(ShapeType::Cuboid, meshes.add(cuboid.clone()));
+ out.insert(ShapeType::RoundCuboid, meshes.add(cuboid));
//
// Ball mesh
@@ -305,12 +307,12 @@ fn bevy_polyline(buffers: (Vec<Point2<Real>>, Option<Vec<[u32; 2]>>)) -> Mesh {
// Generate the mesh
let mut mesh = Mesh::new(PrimitiveTopology::LineStrip);
- mesh.set_attribute(
+ mesh.insert_attribute(
Mesh::ATTRIBUTE_POSITION,
VertexAttributeValues::from(vertices),
);
- mesh.set_attribute(Mesh::ATTRIBUTE_NORMAL, VertexAttributeValues::from(normals));
- mesh.set_attribute(Mesh::ATTRIBUTE_UV_0, VertexAttributeValues::from(uvs));
+ mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, VertexAttributeValues::from(normals));
+ mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, VertexAttributeValues::from(uvs));
mesh.set_indices(Some(Indices::U32(indices)));
mesh
}
@@ -348,12 +350,12 @@ fn bevy_mesh(buffers: (Vec<Point3<Real>>, Vec<[u32; 3]>)) -> Mesh {
// Generate the mesh
let mut mesh = Mesh::new(PrimitiveTopology::TriangleList);
- mesh.set_attribute(
+ mesh.insert_attribute(
Mesh::ATTRIBUTE_POSITION,
VertexAttributeValues::from(vertices),
);
- mesh.set_attribute(Mesh::ATTRIBUTE_NORMAL, VertexAttributeValues::from(normals));
- mesh.set_attribute(Mesh::ATTRIBUTE_UV_0, VertexAttributeValues::from(uvs));
+ mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, VertexAttributeValues::from(normals));
+ mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, VertexAttributeValues::from(uvs));
mesh.set_indices(Some(Indices::U32(indices)));
mesh
}
@@ -365,6 +367,11 @@ fn collider_mesh_scale(co_shape: &dyn Shape) -> Vec3 {
let c = co_shape.as_cuboid().unwrap();
Vec3::new(c.half_extents.x as f32, c.half_extents.y as f32, 1.0)
}
+ #[cfg(feature = "dim2")]
+ ShapeType::RoundCuboid => {
+ let c = &co_shape.as_round_cuboid().unwrap().inner_shape;
+ Vec3::new(c.half_extents.x as f32, c.half_extents.y as f32, 1.0)
+ }
ShapeType::Ball => {
let b = co_shape.as_ball().unwrap();
Vec3::new(b.radius as f32, b.radius as f32, b.radius as f32)
@@ -375,13 +382,18 @@ fn collider_mesh_scale(co_shape: &dyn Shape) -> Vec3 {
Vec3::from_slice(c.half_extents.cast::<f32>().as_slice())
}
#[cfg(feature = "dim3")]
+ ShapeType::RoundCuboid => {
+ let c = co_shape.as_round_cuboid().unwrap();
+ Vec3::from_slice(c.inner_shape.half_extents.cast::<f32>().as_slice())
+ }
+ #[cfg(feature = "dim3")]
ShapeType::Cylinder => {
let c = co_shape.as_cylinder().unwrap();
Vec3::new(c.radius as f32, c.half_height as f32, c.radius as f32)
}
#[cfg(feature = "dim3")]
ShapeType::RoundCylinder => {
- let c = &co_shape.as_round_cylinder().unwrap().base_shape;
+ let c = &co_shape.as_round_cylinder().unwrap().inner_shape;
Vec3::new(c.radius as f32, c.half_height as f32, c.radius as f32)
}
#[cfg(feature = "dim3")]
@@ -391,7 +403,7 @@ fn collider_mesh_scale(co_shape: &dyn Shape) -> Vec3 {
}
#[cfg(feature = "dim3")]
ShapeType::RoundCone => {
- let c = &co_shape.as_round_cone().unwrap().base_shape;
+ let c = &co_shape.as_round_cone().unwrap().inner_shape;
Vec3::new(c.radius as f32, c.half_height as f32, c.radius as f32)
}
_ => Vec3::ONE,
@@ -439,7 +451,7 @@ fn generate_collider_mesh(co_shape: &dyn Shape) -> Option<Mesh> {
}
ShapeType::RoundConvexPolygon => {
let poly = co_shape.as_round_convex_polygon().unwrap();
- bevy_mesh_from_polyline(poly.base_shape.points().to_vec())
+ bevy_mesh_from_polyline(poly.inner_shape.points().to_vec())
}
_ => return None,
};
@@ -472,7 +484,7 @@ fn generate_collider_mesh(co_shape: &dyn Shape) -> Option<Mesh> {
}
ShapeType::RoundConvexPolyhedron => {
let poly = co_shape.as_round_convex_polyhedron().unwrap();
- bevy_mesh(poly.base_shape.to_trimesh())
+ bevy_mesh(poly.inner_shape.to_trimesh())
}
_ => return None,
};