mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Remove thiserror
from bevy_mesh
(#15768)
# Objective - Contributes to #15460 ## Solution - Removed `thiserror` from `bevy_mesh`
This commit is contained in:
parent
1f4adec7df
commit
80fe269349
7 changed files with 38 additions and 31 deletions
|
@ -27,7 +27,11 @@ bytemuck = { version = "1.5" }
|
||||||
wgpu = { version = "22", default-features = false }
|
wgpu = { version = "22", default-features = false }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
hexasphere = "15.0"
|
hexasphere = "15.0"
|
||||||
thiserror = "1.0"
|
derive_more = { version = "1", default-features = false, features = [
|
||||||
|
"error",
|
||||||
|
"from",
|
||||||
|
"display",
|
||||||
|
] }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
|
|
||||||
use super::VertexAttributeValues;
|
use super::VertexAttributeValues;
|
||||||
use bevy_math::{IVec2, IVec3, IVec4, UVec2, UVec3, UVec4, Vec2, Vec3, Vec3A, Vec4};
|
use bevy_math::{IVec2, IVec3, IVec4, UVec2, UVec3, UVec4, Vec2, Vec3, Vec3A, Vec4};
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
#[derive(Debug, Clone, Error, Display)]
|
||||||
#[error("cannot convert VertexAttributeValues::{variant} to {into}")]
|
#[display("cannot convert VertexAttributeValues::{variant} to {into}")]
|
||||||
pub struct FromVertexAttributeError {
|
pub struct FromVertexAttributeError {
|
||||||
from: VertexAttributeValues,
|
from: VertexAttributeValues,
|
||||||
variant: &'static str,
|
variant: &'static str,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
use core::iter::FusedIterator;
|
use core::iter::FusedIterator;
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
use wgpu::IndexFormat;
|
use wgpu::IndexFormat;
|
||||||
|
|
||||||
/// A disjunction of four iterators. This is necessary to have a well-formed type for the output
|
/// A disjunction of four iterators. This is necessary to have a well-formed type for the output
|
||||||
|
@ -33,35 +33,35 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that occurred while trying to invert the winding of a [`Mesh`](super::Mesh).
|
/// An error that occurred while trying to invert the winding of a [`Mesh`](super::Mesh).
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
pub enum MeshWindingInvertError {
|
pub enum MeshWindingInvertError {
|
||||||
/// This error occurs when you try to invert the winding for a mesh with [`PrimitiveTopology::PointList`](super::PrimitiveTopology::PointList).
|
/// This error occurs when you try to invert the winding for a mesh with [`PrimitiveTopology::PointList`](super::PrimitiveTopology::PointList).
|
||||||
#[error("Mesh winding invertation does not work for primitive topology `PointList`")]
|
#[display("Mesh winding invertation does not work for primitive topology `PointList`")]
|
||||||
WrongTopology,
|
WrongTopology,
|
||||||
|
|
||||||
/// This error occurs when you try to invert the winding for a mesh with
|
/// This error occurs when you try to invert the winding for a mesh with
|
||||||
/// * [`PrimitiveTopology::TriangleList`](super::PrimitiveTopology::TriangleList), but the indices are not in chunks of 3.
|
/// * [`PrimitiveTopology::TriangleList`](super::PrimitiveTopology::TriangleList), but the indices are not in chunks of 3.
|
||||||
/// * [`PrimitiveTopology::LineList`](super::PrimitiveTopology::LineList), but the indices are not in chunks of 2.
|
/// * [`PrimitiveTopology::LineList`](super::PrimitiveTopology::LineList), but the indices are not in chunks of 2.
|
||||||
#[error("Indices weren't in chunks according to topology")]
|
#[display("Indices weren't in chunks according to topology")]
|
||||||
AbruptIndicesEnd,
|
AbruptIndicesEnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that occurred while trying to extract a collection of triangles from a [`Mesh`](super::Mesh).
|
/// An error that occurred while trying to extract a collection of triangles from a [`Mesh`](super::Mesh).
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
pub enum MeshTrianglesError {
|
pub enum MeshTrianglesError {
|
||||||
#[error("Source mesh does not have primitive topology TriangleList or TriangleStrip")]
|
#[display("Source mesh does not have primitive topology TriangleList or TriangleStrip")]
|
||||||
WrongTopology,
|
WrongTopology,
|
||||||
|
|
||||||
#[error("Source mesh lacks position data")]
|
#[display("Source mesh lacks position data")]
|
||||||
MissingPositions,
|
MissingPositions,
|
||||||
|
|
||||||
#[error("Source mesh position data is not Float32x3")]
|
#[display("Source mesh position data is not Float32x3")]
|
||||||
PositionsFormat,
|
PositionsFormat,
|
||||||
|
|
||||||
#[error("Source mesh lacks face index data")]
|
#[display("Source mesh lacks face index data")]
|
||||||
MissingIndices,
|
MissingIndices,
|
||||||
|
|
||||||
#[error("Face index data references vertices that do not exist")]
|
#[display("Face index data references vertices that do not exist")]
|
||||||
BadIndices,
|
BadIndices,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::{Indices, Mesh, VertexAttributeValues};
|
use super::{Indices, Mesh, VertexAttributeValues};
|
||||||
use bevy_math::Vec3;
|
use bevy_math::Vec3;
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
use wgpu::{PrimitiveTopology, VertexFormat};
|
use wgpu::{PrimitiveTopology, VertexFormat};
|
||||||
|
|
||||||
struct MikktspaceGeometryHelper<'a> {
|
struct MikktspaceGeometryHelper<'a> {
|
||||||
|
@ -53,18 +53,21 @@ impl bevy_mikktspace::Geometry for MikktspaceGeometryHelper<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
/// Failed to generate tangents for the mesh.
|
/// Failed to generate tangents for the mesh.
|
||||||
pub enum GenerateTangentsError {
|
pub enum GenerateTangentsError {
|
||||||
#[error("cannot generate tangents for {0:?}")]
|
#[display("cannot generate tangents for {_0:?}")]
|
||||||
|
#[error(ignore)]
|
||||||
UnsupportedTopology(PrimitiveTopology),
|
UnsupportedTopology(PrimitiveTopology),
|
||||||
#[error("missing indices")]
|
#[display("missing indices")]
|
||||||
MissingIndices,
|
MissingIndices,
|
||||||
#[error("missing vertex attributes '{0}'")]
|
#[display("missing vertex attributes '{_0}'")]
|
||||||
|
#[error(ignore)]
|
||||||
MissingVertexAttribute(&'static str),
|
MissingVertexAttribute(&'static str),
|
||||||
#[error("the '{0}' vertex attribute should have {1:?} format")]
|
#[display("the '{_0}' vertex attribute should have {_1:?} format")]
|
||||||
|
#[error(ignore)]
|
||||||
InvalidVertexAttributeFormat(&'static str, VertexFormat),
|
InvalidVertexAttributeFormat(&'static str, VertexFormat),
|
||||||
#[error("mesh not suitable for tangent generation")]
|
#[display("mesh not suitable for tangent generation")]
|
||||||
MikktspaceError,
|
MikktspaceError,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use bevy_math::Vec3;
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use core::iter;
|
use core::iter;
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
use wgpu::{Extent3d, TextureDimension, TextureFormat};
|
use wgpu::{Extent3d, TextureDimension, TextureFormat};
|
||||||
|
|
||||||
const MAX_TEXTURE_WIDTH: u32 = 2048;
|
const MAX_TEXTURE_WIDTH: u32 = 2048;
|
||||||
|
@ -17,9 +17,9 @@ const MAX_COMPONENTS: u32 = MAX_TEXTURE_WIDTH * MAX_TEXTURE_WIDTH;
|
||||||
/// Max target count available for [morph targets](MorphWeights).
|
/// Max target count available for [morph targets](MorphWeights).
|
||||||
pub const MAX_MORPH_WEIGHTS: usize = 64;
|
pub const MAX_MORPH_WEIGHTS: usize = 64;
|
||||||
|
|
||||||
#[derive(Error, Clone, Debug)]
|
#[derive(Error, Display, Clone, Debug)]
|
||||||
pub enum MorphBuildError {
|
pub enum MorphBuildError {
|
||||||
#[error(
|
#[display(
|
||||||
"Too many vertex×components in morph target, max is {MAX_COMPONENTS}, \
|
"Too many vertex×components in morph target, max is {MAX_COMPONENTS}, \
|
||||||
got {vertex_count}×{component_count} = {}",
|
got {vertex_count}×{component_count} = {}",
|
||||||
*vertex_count * *component_count as usize
|
*vertex_count * *component_count as usize
|
||||||
|
@ -28,7 +28,7 @@ pub enum MorphBuildError {
|
||||||
vertex_count: usize,
|
vertex_count: usize,
|
||||||
component_count: u32,
|
component_count: u32,
|
||||||
},
|
},
|
||||||
#[error(
|
#[display(
|
||||||
"Bevy only supports up to {} morph targets (individual poses), tried to \
|
"Bevy only supports up to {} morph targets (individual poses), tried to \
|
||||||
create a model with {target_count} morph targets",
|
create a model with {target_count} morph targets",
|
||||||
MAX_MORPH_WEIGHTS
|
MAX_MORPH_WEIGHTS
|
||||||
|
|
|
@ -2,15 +2,15 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable};
|
||||||
use bevy_asset::RenderAssetUsages;
|
use bevy_asset::RenderAssetUsages;
|
||||||
use bevy_math::{ops, primitives::Sphere};
|
use bevy_math::{ops, primitives::Sphere};
|
||||||
use core::f32::consts::PI;
|
use core::f32::consts::PI;
|
||||||
|
use derive_more::derive::{Display, Error};
|
||||||
use hexasphere::shapes::IcoSphere;
|
use hexasphere::shapes::IcoSphere;
|
||||||
use thiserror::Error;
|
|
||||||
use wgpu::PrimitiveTopology;
|
use wgpu::PrimitiveTopology;
|
||||||
|
|
||||||
/// An error when creating an icosphere [`Mesh`] from a [`SphereMeshBuilder`].
|
/// An error when creating an icosphere [`Mesh`] from a [`SphereMeshBuilder`].
|
||||||
#[derive(Clone, Copy, Debug, Error)]
|
#[derive(Clone, Copy, Debug, Error, Display)]
|
||||||
pub enum IcosphereError {
|
pub enum IcosphereError {
|
||||||
/// The icosphere has too many vertices.
|
/// The icosphere has too many vertices.
|
||||||
#[error("Cannot create an icosphere of {subdivisions} subdivisions due to there being too many vertices being generated: {number_of_resulting_points}. (Limited to 65535 vertices or 79 subdivisions)")]
|
#[display("Cannot create an icosphere of {subdivisions} subdivisions due to there being too many vertices being generated: {number_of_resulting_points}. (Limited to 65535 vertices or 79 subdivisions)")]
|
||||||
TooManyVertices {
|
TooManyVertices {
|
||||||
/// The number of subdivisions used. 79 is the largest allowed value for a mesh to be generated.
|
/// The number of subdivisions used. 79 is the largest allowed value for a mesh to be generated.
|
||||||
subdivisions: u32,
|
subdivisions: u32,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use bevy_math::Vec3;
|
||||||
use bevy_utils::HashSet;
|
use bevy_utils::HashSet;
|
||||||
use bytemuck::cast_slice;
|
use bytemuck::cast_slice;
|
||||||
use core::hash::{Hash, Hasher};
|
use core::hash::{Hash, Hasher};
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
use wgpu::{BufferAddress, VertexAttribute, VertexFormat, VertexStepMode};
|
use wgpu::{BufferAddress, VertexAttribute, VertexFormat, VertexStepMode};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
@ -108,8 +108,8 @@ impl MeshVertexBufferLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
#[error("Mesh is missing requested attribute: {name} ({id:?}, pipeline type: {pipeline_type:?})")]
|
#[display("Mesh is missing requested attribute: {name} ({id:?}, pipeline type: {pipeline_type:?})")]
|
||||||
pub struct MissingVertexAttributeError {
|
pub struct MissingVertexAttributeError {
|
||||||
pub pipeline_type: Option<&'static str>,
|
pub pipeline_type: Option<&'static str>,
|
||||||
id: MeshVertexAttributeId,
|
id: MeshVertexAttributeId,
|
||||||
|
|
Loading…
Reference in a new issue