diff --git a/crates/bevy_pbr/Cargo.toml b/crates/bevy_pbr/Cargo.toml index 5afe67229d..72b2b53938 100644 --- a/crates/bevy_pbr/Cargo.toml +++ b/crates/bevy_pbr/Cargo.toml @@ -18,7 +18,7 @@ shader_format_glsl = ["bevy_render/shader_format_glsl"] trace = ["bevy_render/trace"] ios_simulator = ["bevy_render/ios_simulator"] # Enables the meshlet renderer for dense high-poly scenes (experimental) -meshlet = ["dep:lz4_flex", "dep:thiserror", "dep:range-alloc", "dep:bevy_tasks"] +meshlet = ["dep:lz4_flex", "dep:range-alloc", "dep:bevy_tasks"] # Enables processing meshes into meshlet meshes meshlet_processor = [ "meshlet", @@ -54,7 +54,11 @@ fixedbitset = "0.5" lz4_flex = { version = "0.11", default-features = false, features = [ "frame", ], optional = true } -thiserror = { version = "1", optional = true } +derive_more = { version = "1", default-features = false, features = [ + "error", + "from", + "display", +] } range-alloc = { version = "0.1.3", optional = true } meshopt = { version = "0.3.0", optional = true } metis = { version = "0.2", optional = true } diff --git a/crates/bevy_pbr/src/mesh_material.rs b/crates/bevy_pbr/src/mesh_material.rs index 90ee6ea9dc..c737c991b8 100644 --- a/crates/bevy_pbr/src/mesh_material.rs +++ b/crates/bevy_pbr/src/mesh_material.rs @@ -3,6 +3,7 @@ use bevy_asset::{AssetId, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use derive_more::derive::From; /// A [material](Material) for a [`Mesh3d`]. /// @@ -67,7 +68,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; /// ``` /// /// [`StandardMaterial`]: crate::StandardMaterial -#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, PartialEq, Eq)] +#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, PartialEq, Eq, From)] #[reflect(Component, Default)] #[require(HasMaterial3d)] pub struct MeshMaterial3d(pub Handle); @@ -78,12 +79,6 @@ impl Default for MeshMaterial3d { } } -impl From> for MeshMaterial3d { - fn from(handle: Handle) -> Self { - Self(handle) - } -} - impl From> for AssetId { fn from(material: MeshMaterial3d) -> Self { material.id() diff --git a/crates/bevy_pbr/src/meshlet/asset.rs b/crates/bevy_pbr/src/meshlet/asset.rs index 2ba821a9da..433f421a52 100644 --- a/crates/bevy_pbr/src/meshlet/asset.rs +++ b/crates/bevy_pbr/src/meshlet/asset.rs @@ -8,6 +8,7 @@ use bevy_math::{Vec2, Vec3}; use bevy_reflect::TypePath; use bevy_tasks::block_on; use bytemuck::{Pod, Zeroable}; +use derive_more::derive::{Display, Error, From}; use lz4_flex::frame::{FrameDecoder, FrameEncoder}; use std::io::{Read, Write}; @@ -194,16 +195,16 @@ impl AssetLoader for MeshletMeshLoader { } } -#[derive(thiserror::Error, Debug)] +#[derive(Error, Display, Debug, From)] pub enum MeshletMeshSaveOrLoadError { - #[error("file was not a MeshletMesh asset")] + #[display("file was not a MeshletMesh asset")] WrongFileType, - #[error("expected asset version {MESHLET_MESH_ASSET_VERSION} but found version {found}")] + #[display("expected asset version {MESHLET_MESH_ASSET_VERSION} but found version {found}")] WrongVersion { found: u64 }, - #[error("failed to compress or decompress asset data")] - CompressionOrDecompression(#[from] lz4_flex::frame::Error), - #[error("failed to read or write asset data")] - Io(#[from] std::io::Error), + #[display("failed to compress or decompress asset data")] + CompressionOrDecompression(lz4_flex::frame::Error), + #[display("failed to read or write asset data")] + Io(std::io::Error), } async fn async_read_u64(reader: &mut dyn Reader) -> Result { diff --git a/crates/bevy_pbr/src/meshlet/from_mesh.rs b/crates/bevy_pbr/src/meshlet/from_mesh.rs index 367e572276..b8cdd1fc11 100644 --- a/crates/bevy_pbr/src/meshlet/from_mesh.rs +++ b/crates/bevy_pbr/src/meshlet/from_mesh.rs @@ -8,6 +8,7 @@ use bevy_render::{ use bevy_utils::HashMap; use bitvec::{order::Lsb0, vec::BitVec, view::BitView}; use core::ops::Range; +use derive_more::derive::{Display, Error}; use itertools::Itertools; use meshopt::{ build_meshlets, compute_cluster_bounds, compute_meshlet_bounds, @@ -478,12 +479,12 @@ fn pack2x16snorm(v: Vec2) -> u32 { } /// An error produced by [`MeshletMesh::from_mesh`]. -#[derive(thiserror::Error, Debug)] +#[derive(Error, Display, Debug)] pub enum MeshToMeshletMeshConversionError { - #[error("Mesh primitive topology is not TriangleList")] + #[display("Mesh primitive topology is not TriangleList")] WrongMeshPrimitiveTopology, - #[error("Mesh attributes are not {{POSITION, NORMAL, UV_0}}")] + #[display("Mesh attributes are not {{POSITION, NORMAL, UV_0}}")] WrongMeshVertexAttributes, - #[error("Mesh has no indices")] + #[display("Mesh has no indices")] MeshMissingIndices, }