From 59b4dc3f4c3f2a62ab1ca9918e41262257a4662e Mon Sep 17 00:00:00 2001 From: IceSentry Date: Mon, 7 Oct 2024 17:55:32 -0400 Subject: [PATCH] Update to bevy 0.14 (#8) --- Cargo.toml | 12 ++++++------ rust-toolchain.toml | 2 +- src/box_frame.rs | 4 ++-- src/drag_face.rs | 2 +- src/picking_backend.rs | 6 +++--- src/solid_color_material.rs | 11 ++++++----- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 53c3df9..459a6d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_fsl_box_frame" -version = "0.3.0" +version = "0.4.0" description = "A gizmo for manipulating an OBB via 3D picking" edition = "2021" authors = ["Duncan Fairbanks "] @@ -16,17 +16,17 @@ categories = ["3D", "game-development"] [dependencies] approx = "0.5" -bevy_polyline = "0.9" +bevy_polyline = "0.10" parry3d = "0.13" -bevy = { version = "0.13", default-features = false, features = [ +bevy = { version = "0.14", default-features = false, features = [ "bevy_asset", "bevy_pbr", ] } -bevy_mod_picking = { version = "0.19", default_features = false } -nalgebra = { version = "0.32", features = ["glam025"] } +bevy_mod_picking = { version = "0.20", default-features = false } +nalgebra = { version = "0.32", features = ["glam027"] } [dev-dependencies] -bevy = { version = "0.13", default-features = false, features = [ +bevy = { version = "0.14", default-features = false, features = [ "bevy_asset", "bevy_pbr", "bevy_winit", diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 3eb87d6..d5ed441 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] profile = "default" -channel = "1.76" +channel = "1.79" diff --git a/src/box_frame.rs b/src/box_frame.rs index 9ebd482..6195c35 100644 --- a/src/box_frame.rs +++ b/src/box_frame.rs @@ -1,5 +1,5 @@ use crate::{drag_face::Dragging, solid_color_material::SolidColorMaterial}; -use bevy::{ecs::system::EntityCommands, prelude::*, utils::FloatOrd}; +use bevy::{color::palettes::css::RED, ecs::system::EntityCommands, math::FloatOrd, prelude::*}; use bevy_mod_picking::prelude::{Pickable, PointerButton}; use bevy_polyline::prelude::{Polyline, PolylineBundle, PolylineMaterial}; use parry3d::{bounding_volume::Aabb, shape::Ball}; @@ -80,7 +80,7 @@ impl BoxFrameVisuals { }), handle_mesh: meshes.add(Sphere::new(1.0).mesh()), - handle_material: materials.add(Color::RED), + handle_material: materials.add(RED), handle_scale: |e| 0.05 * median3(e), handle_hover_scale: 1.2, } diff --git a/src/drag_face.rs b/src/drag_face.rs index f5f2d69..4b3be0f 100644 --- a/src/drag_face.rs +++ b/src/drag_face.rs @@ -57,7 +57,7 @@ pub(crate) fn drag_face( initial_coord: frame.faces()[face], drag_ray: Ray3d { origin: world_position, - direction: Direction3d::new(world_normal).unwrap(), + direction: Dir3::new(world_normal).unwrap(), }, }); } diff --git a/src/picking_backend.rs b/src/picking_backend.rs index 2e8f221..4bf6b7d 100644 --- a/src/picking_backend.rs +++ b/src/picking_backend.rs @@ -21,14 +21,14 @@ pub(crate) fn box_frame_backend( continue; }; - let cam_view_mask = view_mask.copied().unwrap_or_default(); + let cam_view_mask = view_mask.unwrap_or_default(); let ray = parry3d::query::Ray::new(ray.origin.into(), ray.direction.xyz().into()); let mut picks = Vec::new(); for (frame_entity, frame, frame_transform, frame_view_mask) in &box_frames { - let frame_view_mask = frame_view_mask.copied().unwrap_or_default(); - if !frame_view_mask.intersects(&cam_view_mask) { + let frame_view_mask = frame_view_mask.unwrap_or_default(); + if !frame_view_mask.intersects(cam_view_mask) { continue; } diff --git a/src/solid_color_material.rs b/src/solid_color_material.rs index 37c746e..0c81125 100644 --- a/src/solid_color_material.rs +++ b/src/solid_color_material.rs @@ -1,6 +1,7 @@ use bevy::{ asset::Asset, - prelude::{AlphaMode, Color, Handle, Material, Shader}, + color::{LinearRgba, Srgba}, + prelude::{AlphaMode, Handle, Material, Shader}, reflect::TypePath, render::render_resource::{AsBindGroup, ShaderRef}, }; @@ -12,7 +13,7 @@ pub(crate) const SHADER_HANDLE: Handle = Handle::weak_from_u128(78254136 #[derive(Asset, AsBindGroup, Clone, Debug, TypePath)] pub struct SolidColorMaterial { #[uniform(0)] - pub color: Color, + pub color: LinearRgba, pub alpha_mode: AlphaMode, } @@ -26,10 +27,10 @@ impl Material for SolidColorMaterial { } } -impl From for SolidColorMaterial { - fn from(color: Color) -> Self { +impl From for SolidColorMaterial { + fn from(color: Srgba) -> Self { Self { - color, + color: color.into(), alpha_mode: AlphaMode::Opaque, } }