Skip to content

Commit

Permalink
Remove thiserror from bevy_pbr (#15767)
Browse files Browse the repository at this point in the history
# Objective

- Contributes to #15460

## Solution

- Removed `thiserror` from `bevy_pbr`
  • Loading branch information
bushrat011899 authored Oct 9, 2024
1 parent 80fe269 commit 46ad0b7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
8 changes: 6 additions & 2 deletions crates/bevy_pbr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 }
Expand Down
9 changes: 2 additions & 7 deletions crates/bevy_pbr/src/mesh_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
///
Expand Down Expand Up @@ -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>);
Expand All @@ -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()
Expand Down
15 changes: 8 additions & 7 deletions crates/bevy_pbr/src/meshlet/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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> {
Expand Down
9 changes: 5 additions & 4 deletions crates/bevy_pbr/src/meshlet/from_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}

0 comments on commit 46ad0b7

Please sign in to comment.