update testbeds to bevy 0.14 (#723)

This commit is contained in:
Thierry Berger
2024-09-06 16:15:34 +02:00
committed by GitHub
parent bedb12b88a
commit 04058a111d
7 changed files with 42 additions and 41 deletions

View File

@@ -25,7 +25,7 @@ pub fn track_mouse_state(
- Vec2::ONE)
* Vec2::new(1.0, -1.0);
let ndc_to_world =
camera_transform.compute_matrix() * camera.projection_matrix().inverse();
camera_transform.compute_matrix() * camera.clip_from_view().inverse();
let ray_pt1 =
ndc_to_world.project_point3(Vec3::new(ndc_cursor.x, ndc_cursor.y, -1.0));

View File

@@ -44,7 +44,7 @@ impl EntityWithGraphics {
#[cfg(feature = "dim2")]
let selection_material = ColorMaterial {
color: Color::rgb(1.0, 0.0, 0.0),
color: Color::from(Srgba::rgb(1.0, 0.0, 0.0)),
texture: None,
};
#[cfg(feature = "dim3")]
@@ -52,7 +52,7 @@ impl EntityWithGraphics {
metallic: 0.5,
perceptual_roughness: 0.5,
double_sided: true, // TODO: this doesn't do anything?
..StandardMaterial::from(Color::rgb(1.0, 0.0, 0.0))
..StandardMaterial::from(Color::from(Srgba::rgb(1.0, 0.0, 0.0)))
};
instanced_materials.insert(
@@ -85,7 +85,7 @@ impl EntityWithGraphics {
.or_else(|| generate_collider_mesh(shape).map(|m| meshes.add(m)));
let opacity = 1.0;
let bevy_color = Color::rgba(color.x, color.y, color.z, opacity);
let bevy_color = Color::from(Srgba::new(color.x, color.y, color.z, opacity));
let shape_pos = collider_pos * delta;
let mut transform = Transform::from_scale(scale);
transform.translation.x = shape_pos.translation.vector.x as f32;
@@ -169,11 +169,12 @@ impl EntityWithGraphics {
if let Some(material) = materials.get_mut(&self.material) {
#[cfg(feature = "dim2")]
{
material.color = Color::rgba(color.x, color.y, color.z, self.opacity);
material.color = Color::from(Srgba::new(color.x, color.y, color.z, self.opacity));
}
#[cfg(feature = "dim3")]
{
material.base_color = Color::rgba(color.x, color.y, color.z, self.opacity);
material.base_color =
Color::from(Srgba::new(color.x, color.y, color.z, self.opacity));
}
}
self.color = color;

View File

@@ -429,7 +429,7 @@ impl TestbedApp {
};
let mut app = App::new();
app.insert_resource(ClearColor(Color::rgb(0.15, 0.15, 0.15)))
app.insert_resource(ClearColor(Color::from(Srgba::rgb(0.15, 0.15, 0.15))))
.insert_resource(Msaa::Sample4)
.insert_resource(AmbientLight {
brightness: 0.3,
@@ -1600,7 +1600,7 @@ fn highlight_hovered_body(
cursor.x / window.width() * 2.0 - 1.0,
1.0 - cursor.y / window.height() * 2.0,
);
let ndc_to_world = camera_transform.compute_matrix() * camera.projection_matrix().inverse();
let ndc_to_world = camera_transform.compute_matrix() * camera.clip_from_view().inverse();
let ray_pt1 = ndc_to_world.project_point3(Vec3::new(ndc_cursor.x, ndc_cursor.y, -1.0));
let ray_pt2 = ndc_to_world.project_point3(Vec3::new(ndc_cursor.x, ndc_cursor.y, 1.0));
let ray_dir = ray_pt2 - ray_pt1;