From 780bc564fba14d73d460b9406e0d874c8713c183 Mon Sep 17 00:00:00 2001 From: Friz64 Date: Wed, 5 Jun 2024 22:48:12 +0200 Subject: [PATCH 1/2] Bevy 0.14 --- Cargo.toml | 27 ++++++++++++++------------- examples/minimal.rs | 2 +- examples/minimal_deferred.rs | 2 +- examples/mouse_picking.rs | 4 ++-- examples/mouse_picking_2d.rs | 4 ++-- examples/mouse_picking_deferred.rs | 4 ++-- examples/reflecting_laser.rs | 26 ++++++++++++++++++-------- examples/simplified_mesh.rs | 9 +++++---- examples/stress_test.rs | 5 +++-- src/deferred.rs | 14 +++++++------- src/immediate.rs | 17 +++++++++-------- 11 files changed, 64 insertions(+), 50 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5a17dfc..0abe6d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,22 +11,23 @@ categories = ["game-engines", "rendering"] resolver = "2" [dependencies] -bevy_app = { version = "0.13", default-features = false } -bevy_asset = { version = "0.13", default-features = false } -bevy_derive = { version = "0.13", default-features = false } -bevy_ecs = { version = "0.13", default-features = false } -bevy_gizmos = { version = "0.13", optional = true, default-features = false } -bevy_math = { version = "0.13", default-features = false } -bevy_reflect = { version = "0.13", default-features = false } -bevy_render = { version = "0.13", default-features = false } -bevy_sprite = { version = "0.13", optional = true, default-features = false } -bevy_transform = { version = "0.13", default-features = false } -bevy_utils = { version = "0.13", default-features = false } -bevy_window = { version = "0.13", default-features = false } +bevy_app = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_asset = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_derive = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_ecs = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_gizmos = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", optional = true, default-features = false } +bevy_math = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_reflect = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_render = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_sprite = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", optional = true, default-features = false } +bevy_transform = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_utils = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_window = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_color = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } crossbeam-channel = "0.5" [dev-dependencies] -bevy = { version = "0.13", default-features = true, features = [ +bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = true, features = [ "default_font", "ktx2", "tonemapping_luts", diff --git a/examples/minimal.rs b/examples/minimal.rs index c9ad3e7..861027f 100644 --- a/examples/minimal.rs +++ b/examples/minimal.rs @@ -33,7 +33,7 @@ fn setup( commands.spawn(PointLightBundle::default()); commands.spawn(PbrBundle { mesh: meshes.add(Capsule3d::default()), - material: materials.add(Color::rgb(1.0, 1.0, 1.0)), + material: materials.add(Color::srgb(1.0, 1.0, 1.0)), transform: Transform::from_translation(RAY_DIST), ..default() }); diff --git a/examples/minimal_deferred.rs b/examples/minimal_deferred.rs index f9ec6a6..6b8602a 100644 --- a/examples/minimal_deferred.rs +++ b/examples/minimal_deferred.rs @@ -48,7 +48,7 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Capsule3d::default()), - material: materials.add(Color::rgb(1.0, 1.0, 1.0)), + material: materials.add(Color::srgb(1.0, 1.0, 1.0)), transform: Transform::from_translation(RAY_DIST), ..default() }, diff --git a/examples/mouse_picking.rs b/examples/mouse_picking.rs index ff2b88f..842340f 100644 --- a/examples/mouse_picking.rs +++ b/examples/mouse_picking.rs @@ -2,7 +2,7 @@ //! scene, intersect a mesh, and mark the intersection with the built in debug cursor. If you are //! looking for a more fully-featured mouse picking plugin, try out bevy_mod_picking. -use bevy::prelude::*; +use bevy::{color::palettes::css, prelude::*}; use bevy_mod_raycast::prelude::*; fn main() { @@ -29,7 +29,7 @@ fn setup( commands.spawn(PointLightBundle::default()); commands.spawn(PbrBundle { mesh: meshes.add(Sphere::default()), - material: materials.add(Color::GRAY), + material: materials.add(Color::from(css::GRAY)), transform: Transform::from_xyz(0.0, 0.0, -5.0), ..default() }); diff --git a/examples/mouse_picking_2d.rs b/examples/mouse_picking_2d.rs index bb4f3ec..b76072c 100644 --- a/examples/mouse_picking_2d.rs +++ b/examples/mouse_picking_2d.rs @@ -1,4 +1,4 @@ -use bevy::{prelude::*, sprite::MaterialMesh2dBundle}; +use bevy::{color::palettes::css, prelude::*, sprite::MaterialMesh2dBundle}; use bevy_mod_raycast::prelude::*; fn main() { @@ -23,7 +23,7 @@ fn setup( MaterialMesh2dBundle { mesh: meshes.add(Circle::default()).into(), transform: Transform::default().with_scale(Vec3::splat(128.)), - material: materials.add(ColorMaterial::from(Color::PURPLE)), + material: materials.add(ColorMaterial::from(Color::from(css::PURPLE))), ..default() }, RaycastMesh::<()>::default(), // Make this mesh ray cast-able; diff --git a/examples/mouse_picking_deferred.rs b/examples/mouse_picking_deferred.rs index 48c9e31..072fba5 100644 --- a/examples/mouse_picking_deferred.rs +++ b/examples/mouse_picking_deferred.rs @@ -2,7 +2,7 @@ //! parameter. By contrast this example instead uses the deferred API, where raycasts are declared //! using components, and the plugin handles the raycasting. Note we use `()` as the raycasting set. -use bevy::prelude::*; +use bevy::{color::palettes::css, prelude::*}; use bevy_mod_raycast::prelude::*; fn main() { @@ -29,7 +29,7 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Sphere::default()), - material: materials.add(Color::GRAY), + material: materials.add(Color::from(css::GRAY)), transform: Transform::from_xyz(0.0, 0.0, -5.0), ..default() }, diff --git a/examples/reflecting_laser.rs b/examples/reflecting_laser.rs index 625876e..0f9528f 100644 --- a/examples/reflecting_laser.rs +++ b/examples/reflecting_laser.rs @@ -3,7 +3,7 @@ use std::f32::consts::{FRAC_PI_2, PI}; -use bevy::{core_pipeline::bloom::BloomSettings, math::vec3, prelude::*}; +use bevy::{color::palettes::css, core_pipeline::bloom::BloomSettings, math::vec3, prelude::*}; use bevy_mod_raycast::prelude::*; fn main() { @@ -35,26 +35,36 @@ fn bouncing_raycast( let ray_dir = (-ray_pos).normalize(); let ray = Ray3d::new(ray_pos, ray_dir); gizmos.sphere(ray_pos, Quat::IDENTITY, 0.1, Color::WHITE); - bounce_ray(ray, &mut raycast, &mut gizmos, Color::RED); + bounce_ray(ray, &mut raycast, &mut gizmos, Color::from(css::RED)); if let Some(cursor_ray) = **cursor_ray { - bounce_ray(cursor_ray, &mut raycast, &mut gizmos, Color::GREEN) + bounce_ray( + cursor_ray, + &mut raycast, + &mut gizmos, + Color::from(css::GREEN), + ) } } fn bounce_ray(mut ray: Ray3d, raycast: &mut Raycast, gizmos: &mut Gizmos, color: Color) { let mut intersections = Vec::with_capacity(MAX_BOUNCES + 1); - intersections.push((ray.origin, Color::rgb(30.0, 0.0, 0.0))); + intersections.push((ray.origin, Color::srgb(30.0, 0.0, 0.0))); for i in 0..MAX_BOUNCES { if let Some((_, hit)) = raycast.cast_ray(ray, &RaycastSettings::default()).first() { let bright = 1.0 + 10.0 * (1.0 - i as f32 / MAX_BOUNCES as f32); - intersections.push((hit.position(), color * bright)); - gizmos.sphere(hit.position(), Quat::IDENTITY, 0.005, color * bright * 2.0); + intersections.push((hit.position(), Color::BLACK.mix(&color, bright))); + gizmos.sphere( + hit.position(), + Quat::IDENTITY, + 0.005, + Color::BLACK.mix(&color, bright * 2.0), + ); let ray_dir = ray.direction; // reflect the ray let proj = (ray_dir.dot(hit.normal()) / hit.normal().dot(hit.normal())) * hit.normal(); - ray.direction = Direction3d::new(*ray_dir - 2.0 * proj).unwrap(); + ray.direction = Dir3::new(*ray_dir - 2.0 * proj).unwrap(); ray.origin = hit.position() + ray.direction * 1e-6; } else { break; @@ -88,7 +98,7 @@ fn setup_scene( // Make a box of planes facing inward so the laser gets trapped inside: let plane = PbrBundle { mesh: meshes.add(Plane3d::default()), - material: materials.add(Color::GRAY.with_a(0.01)), + material: materials.add(Color::from(css::GRAY).with_alpha(0.01)), ..default() }; let pbr_bundle = move |translation, rotation| PbrBundle { diff --git a/examples/simplified_mesh.rs b/examples/simplified_mesh.rs index fff089a..d8b7cd1 100644 --- a/examples/simplified_mesh.rs +++ b/examples/simplified_mesh.rs @@ -3,6 +3,7 @@ //! intersection with the mesh. use bevy::{ + color::palettes::css, diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}, prelude::*, }; @@ -37,7 +38,7 @@ fn setup_scene( PbrBundle { // This is a very complex mesh that will be hard to raycast on mesh: meshes.add(Sphere::default().mesh().uv(1000, 1000)), - material: materials.add(Color::rgb(1.0, 1.0, 1.0)), + material: materials.add(Color::srgb(1.0, 1.0, 1.0)), transform: Transform::from_translation(Vec3::new(0.0, 0.0, -5.0)), ..default() }, @@ -105,7 +106,7 @@ fn setup_ui(mut commands: Commands) { value: "ON".to_string(), style: TextStyle { font_size: 30.0, - color: Color::GREEN, + color: css::GREEN.into(), ..default() }, }, @@ -140,11 +141,11 @@ fn manage_simplified_mesh( mesh: meshes.add(Sphere::default()), }); text.sections[1].value = "ON".to_string(); - text.sections[1].style.color = Color::GREEN; + text.sections[1].style.color = css::GREEN.into(); } else { commands.entity(entity).remove::(); text.sections[1].value = "OFF".to_string(); - text.sections[1].style.color = Color::RED; + text.sections[1].style.color = css::RED.into(); } } } diff --git a/examples/stress_test.rs b/examples/stress_test.rs index e920d88..bd2f23b 100644 --- a/examples/stress_test.rs +++ b/examples/stress_test.rs @@ -1,6 +1,7 @@ use std::ops::Sub; use bevy::{ + color::palettes::css, diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}, math::Vec3A, prelude::*, @@ -144,10 +145,10 @@ fn update_status( let bool_to_text = |is_enabled: bool, text: &mut Text| { if is_enabled { text.sections[1].value = "ON".to_string(); - text.sections[1].style.color = Color::GREEN; + text.sections[1].style.color = css::GREEN.into(); } else { text.sections[1].value = "OFF".to_string(); - text.sections[1].style.color = Color::RED; + text.sections[1].style.color = css::RED.into(); } }; diff --git a/src/deferred.rs b/src/deferred.rs index 69f85bd..6041be9 100644 --- a/src/deferred.rs +++ b/src/deferred.rs @@ -504,11 +504,11 @@ pub fn update_target_intersections( pub mod debug { #![allow(unused)] + use bevy_color::palettes::css; use bevy_ecs::system::{Commands, Query}; use bevy_gizmos::gizmos::Gizmos; - use bevy_math::{primitives::Direction3d, Quat, Vec3}; + use bevy_math::{Dir3, Quat, Vec3}; use bevy_reflect::TypePath; - use bevy_render::color::Color; use bevy_utils::tracing::info; use std::marker::PhantomData; @@ -523,8 +523,8 @@ pub mod debug { ) { for ray in sources.iter().filter_map(|s| s.ray) { let orientation = Quat::from_rotation_arc(Vec3::NEG_Z, *ray.direction); - gizmos.ray(ray.origin, *ray.direction, Color::BLUE); - gizmos.sphere(ray.origin, orientation, 0.1, Color::BLUE); + gizmos.ray(ray.origin, *ray.direction, css::BLUE); + gizmos.sphere(ray.origin, orientation, 0.1, css::BLUE); } for (is_first, intersection) in sources.iter().flat_map(|m| { @@ -535,13 +535,13 @@ pub mod debug { .map(|(i, hit)| (i == 0, hit)) }) { let color = match is_first { - true => Color::GREEN, - false => Color::PINK, + true => css::GREEN, + false => css::PINK, }; gizmos.ray(intersection.position(), intersection.normal(), color); gizmos.circle( intersection.position(), - Direction3d::new_unchecked(intersection.normal().normalize()), + Dir3::new_unchecked(intersection.normal().normalize()), 0.1, color, ); diff --git a/src/immediate.rs b/src/immediate.rs index 9b7fa94..a90ac7a 100644 --- a/src/immediate.rs +++ b/src/immediate.rs @@ -9,11 +9,11 @@ use bevy_asset::{Assets, Handle}; use bevy_ecs::{prelude::*, system::lifetimeless::Read, system::SystemParam}; -use bevy_math::Ray3d; +use bevy_math::{FloatOrd, Ray3d}; use bevy_reflect::Reflect; use bevy_render::{prelude::*, primitives::Aabb}; use bevy_transform::components::GlobalTransform; -use bevy_utils::{tracing::*, FloatOrd}; +use bevy_utils::tracing::*; #[cfg(feature = "debug")] use { @@ -196,11 +196,12 @@ impl<'w, 's> Raycast<'w, 's> { settings: &RaycastSettings, gizmos: &mut Gizmos, ) -> &[(Entity, IntersectionData)] { - use bevy_math::primitives::Direction3d; + use bevy_color::palettes::css; + use bevy_math::Dir3; let orientation = Quat::from_rotation_arc(Vec3::NEG_Z, *ray.direction); - gizmos.ray(ray.origin, *ray.direction, Color::BLUE); - gizmos.sphere(ray.origin, orientation, 0.1, Color::BLUE); + gizmos.ray(ray.origin, *ray.direction, css::BLUE); + gizmos.sphere(ray.origin, orientation, 0.1, css::BLUE); let hits = self.cast_ray(ray, settings); @@ -211,13 +212,13 @@ impl<'w, 's> Raycast<'w, 's> { .map(|(i, hit)| (i == 0, hit)) { let color = match is_first { - true => Color::GREEN, - false => Color::PINK, + true => css::GREEN, + false => css::PINK, }; gizmos.ray(intersection.position(), intersection.normal(), color); gizmos.circle( intersection.position(), - Direction3d::new_unchecked(intersection.normal().normalize()), + Dir3::new_unchecked(intersection.normal().normalize()), 0.1, color, ); From e4910eee447d7de2600c0077071bd8e19780ee42 Mon Sep 17 00:00:00 2001 From: Friz64 Date: Fri, 7 Jun 2024 18:06:17 +0200 Subject: [PATCH 2/2] 0.14.0-rc.2 --- Cargo.toml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0abe6d4..d30de60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,23 +11,23 @@ categories = ["game-engines", "rendering"] resolver = "2" [dependencies] -bevy_app = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_asset = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_derive = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_ecs = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_gizmos = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", optional = true, default-features = false } -bevy_math = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_reflect = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_render = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_sprite = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", optional = true, default-features = false } -bevy_transform = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_utils = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_window = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } -bevy_color = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = false } +bevy_app = { version = "0.14.0-rc.2", default-features = false } +bevy_asset = { version = "0.14.0-rc.2", default-features = false } +bevy_derive = { version = "0.14.0-rc.2", default-features = false } +bevy_ecs = { version = "0.14.0-rc.2", default-features = false } +bevy_gizmos = { version = "0.14.0-rc.2", optional = true, default-features = false } +bevy_math = { version = "0.14.0-rc.2", default-features = false } +bevy_reflect = { version = "0.14.0-rc.2", default-features = false } +bevy_render = { version = "0.14.0-rc.2", default-features = false } +bevy_sprite = { version = "0.14.0-rc.2", optional = true, default-features = false } +bevy_transform = { version = "0.14.0-rc.2", default-features = false } +bevy_utils = { version = "0.14.0-rc.2", default-features = false } +bevy_window = { version = "0.14.0-rc.2", default-features = false } +bevy_color = { version = "0.14.0-rc.2", default-features = false } crossbeam-channel = "0.5" [dev-dependencies] -bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "519abbc", default-features = true, features = [ +bevy = { version = "0.14.0-rc.2", default-features = true, features = [ "default_font", "ktx2", "tonemapping_luts",