Testbed: don’t panic when trying to render an unknown custom shape.

This commit is contained in:
Sébastien Crozet
2021-10-20 16:44:39 +02:00
committed by Sébastien Crozet
parent b59e813fd3
commit 7cda2f05e2

View File

@@ -48,8 +48,7 @@ impl EntityWithGraphics {
let mesh = prefab_meshs let mesh = prefab_meshs
.get(&shape.shape_type()) .get(&shape.shape_type())
.cloned() .cloned()
.or_else(|| generate_collider_mesh(shape).map(|m| meshes.add(m))) .or_else(|| generate_collider_mesh(shape).map(|m| meshes.add(m)));
.expect("Could not build the collider's render mesh");
let opacity = 1.0; let opacity = 1.0;
let bevy_color = Color::rgba(color.x, color.y, color.z, opacity); let bevy_color = Color::rgba(color.x, color.y, color.z, opacity);
@@ -83,6 +82,8 @@ impl EntityWithGraphics {
}; };
let material_handle = materials.add(material); let material_handle = materials.add(material);
let material_weak_handle = material_handle.clone_weak(); let material_weak_handle = material_handle.clone_weak();
if let Some(mesh) = mesh {
let pbr = PbrBundle { let pbr = PbrBundle {
mesh, mesh,
material: material_handle, material: material_handle,
@@ -96,6 +97,7 @@ impl EntityWithGraphics {
if sensor { if sensor {
entity_commands.insert(Wireframe); entity_commands.insert(Wireframe);
} }
}
EntityWithGraphics { EntityWithGraphics {
entity, entity,