Remove thiserror from bevy_pbr (#15767)

# Objective

- Contributes to #15460

## Solution

- Removed `thiserror` from `bevy_pbr`
This commit is contained in:
Zachary Harrold 2024-10-10 01:25:16 +11:00 committed by GitHub
parent 80fe269349
commit 46ad0b7513
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 20 deletions

View file

@ -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 }

View file

@ -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<M: Material>(pub Handle<M>);
@ -78,12 +79,6 @@ impl<M: Material> Default for MeshMaterial3d<M> {
}
}
impl<M: Material> From<Handle<M>> for MeshMaterial3d<M> {
fn from(handle: Handle<M>) -> Self {
Self(handle)
}
}
impl<M: Material> From<MeshMaterial3d<M>> for AssetId<M> {
fn from(material: MeshMaterial3d<M>) -> Self {
material.id()

View file

@ -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<u64, std::io::Error> {

View file

@ -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,
}