mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 14:10:19 +00:00
Remove thiserror
from bevy_math
(#15769)
# Objective - Contributes to #15460 ## Solution - Removed `thiserror` from `bevy_math`
This commit is contained in:
parent
5e89acacb4
commit
9366b95006
8 changed files with 76 additions and 94 deletions
|
@ -11,7 +11,12 @@ rust-version = "1.68.2"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glam = { version = "0.29", features = ["bytemuck"] }
|
glam = { version = "0.29", features = ["bytemuck"] }
|
||||||
thiserror = "1.0"
|
derive_more = { version = "1", default-features = false, features = [
|
||||||
|
"error",
|
||||||
|
"from",
|
||||||
|
"display",
|
||||||
|
"into",
|
||||||
|
] }
|
||||||
itertools = "0.13.0"
|
itertools = "0.13.0"
|
||||||
serde = { version = "1", features = ["derive"], optional = true }
|
serde = { version = "1", features = ["derive"], optional = true }
|
||||||
libm = { version = "0.2", optional = true }
|
libm = { version = "0.2", optional = true }
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
//! Provides a simple aspect ratio struct to help with calculations.
|
//! Provides a simple aspect ratio struct to help with calculations.
|
||||||
|
|
||||||
use crate::Vec2;
|
use crate::Vec2;
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error, Into};
|
||||||
|
|
||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
|
|
||||||
/// An `AspectRatio` is the ratio of width to height.
|
/// An `AspectRatio` is the ratio of width to height.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Into)]
|
||||||
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, PartialEq))]
|
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, PartialEq))]
|
||||||
pub struct AspectRatio(f32);
|
pub struct AspectRatio(f32);
|
||||||
|
|
||||||
|
@ -83,23 +83,16 @@ impl TryFrom<Vec2> for AspectRatio {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AspectRatio> for f32 {
|
|
||||||
#[inline]
|
|
||||||
fn from(aspect_ratio: AspectRatio) -> Self {
|
|
||||||
aspect_ratio.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An Error type for when [`super::AspectRatio`] is provided invalid width or height values
|
/// An Error type for when [`super::AspectRatio`] is provided invalid width or height values
|
||||||
#[derive(Error, Debug, PartialEq, Eq, Clone, Copy)]
|
#[derive(Error, Display, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum AspectRatioError {
|
pub enum AspectRatioError {
|
||||||
/// Error due to width or height having zero as a value.
|
/// Error due to width or height having zero as a value.
|
||||||
#[error("AspectRatio error: width or height is zero")]
|
#[display("AspectRatio error: width or height is zero")]
|
||||||
Zero,
|
Zero,
|
||||||
/// Error due towidth or height being infinite.
|
/// Error due towidth or height being infinite.
|
||||||
#[error("AspectRatio error: width or height is infinite")]
|
#[display("AspectRatio error: width or height is infinite")]
|
||||||
Infinite,
|
Infinite,
|
||||||
/// Error due to width or height being Not a Number (NaN).
|
/// Error due to width or height being Not a Number (NaN).
|
||||||
#[error("AspectRatio error: width or height is NaN")]
|
#[display("AspectRatio error: width or height is NaN")]
|
||||||
NaN,
|
NaN,
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ use crate::{
|
||||||
Vec2, VectorSpace,
|
Vec2, VectorSpace,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use derive_more::derive::{Display, Error};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
||||||
|
@ -94,8 +94,8 @@ impl<P: VectorSpace> CubicGenerator<P> for CubicBezier<P> {
|
||||||
|
|
||||||
/// An error returned during cubic curve generation for cubic Bezier curves indicating that a
|
/// An error returned during cubic curve generation for cubic Bezier curves indicating that a
|
||||||
/// segment of control points was not present.
|
/// segment of control points was not present.
|
||||||
#[derive(Clone, Debug, Error)]
|
#[derive(Clone, Debug, Error, Display)]
|
||||||
#[error("Unable to generate cubic curve: at least one set of control points is required")]
|
#[display("Unable to generate cubic curve: at least one set of control points is required")]
|
||||||
pub struct CubicBezierError;
|
pub struct CubicBezierError;
|
||||||
|
|
||||||
/// A spline interpolated continuously between the nearest two control points, with the position and
|
/// A spline interpolated continuously between the nearest two control points, with the position and
|
||||||
|
@ -500,10 +500,10 @@ impl<P: VectorSpace> CyclicCubicGenerator<P> for CubicBSpline<P> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error during construction of [`CubicNurbs`]
|
/// Error during construction of [`CubicNurbs`]
|
||||||
#[derive(Clone, Debug, Error)]
|
#[derive(Clone, Debug, Error, Display)]
|
||||||
pub enum CubicNurbsError {
|
pub enum CubicNurbsError {
|
||||||
/// Provided the wrong number of knots.
|
/// Provided the wrong number of knots.
|
||||||
#[error("Wrong number of knots: expected {expected}, provided {provided}")]
|
#[display("Wrong number of knots: expected {expected}, provided {provided}")]
|
||||||
KnotsNumberMismatch {
|
KnotsNumberMismatch {
|
||||||
/// Expected number of knots
|
/// Expected number of knots
|
||||||
expected: usize,
|
expected: usize,
|
||||||
|
@ -512,13 +512,13 @@ pub enum CubicNurbsError {
|
||||||
},
|
},
|
||||||
/// The provided knots had a descending knot pair. Subsequent knots must
|
/// The provided knots had a descending knot pair. Subsequent knots must
|
||||||
/// either increase or stay the same.
|
/// either increase or stay the same.
|
||||||
#[error("Invalid knots: contains descending knot pair")]
|
#[display("Invalid knots: contains descending knot pair")]
|
||||||
DescendingKnots,
|
DescendingKnots,
|
||||||
/// The provided knots were all equal. Knots must contain at least one increasing pair.
|
/// The provided knots were all equal. Knots must contain at least one increasing pair.
|
||||||
#[error("Invalid knots: all knots are equal")]
|
#[display("Invalid knots: all knots are equal")]
|
||||||
ConstantKnots,
|
ConstantKnots,
|
||||||
/// Provided a different number of weights and control points.
|
/// Provided a different number of weights and control points.
|
||||||
#[error("Incorrect number of weights: expected {expected}, provided {provided}")]
|
#[display("Incorrect number of weights: expected {expected}, provided {provided}")]
|
||||||
WeightsNumberMismatch {
|
WeightsNumberMismatch {
|
||||||
/// Expected number of weights
|
/// Expected number of weights
|
||||||
expected: usize,
|
expected: usize,
|
||||||
|
@ -526,7 +526,7 @@ pub enum CubicNurbsError {
|
||||||
provided: usize,
|
provided: usize,
|
||||||
},
|
},
|
||||||
/// The number of control points provided is less than 4.
|
/// The number of control points provided is less than 4.
|
||||||
#[error("Not enough control points, at least 4 are required, {provided} were provided")]
|
#[display("Not enough control points, at least 4 are required, {provided} were provided")]
|
||||||
NotEnoughControlPoints {
|
NotEnoughControlPoints {
|
||||||
/// The number of control points provided
|
/// The number of control points provided
|
||||||
provided: usize,
|
provided: usize,
|
||||||
|
@ -870,8 +870,8 @@ impl<P: VectorSpace> CyclicCubicGenerator<P> for LinearSpline<P> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error indicating that a spline construction didn't have enough control points to generate a curve.
|
/// An error indicating that a spline construction didn't have enough control points to generate a curve.
|
||||||
#[derive(Clone, Debug, Error)]
|
#[derive(Clone, Debug, Error, Display)]
|
||||||
#[error("Not enough data to build curve: needed at least {expected} control points but was only given {given}")]
|
#[display("Not enough data to build curve: needed at least {expected} control points but was only given {given}")]
|
||||||
pub struct InsufficientDataError {
|
pub struct InsufficientDataError {
|
||||||
expected: usize,
|
expected: usize,
|
||||||
given: usize,
|
given: usize,
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
use super::interval::Interval;
|
use super::interval::Interval;
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
use derive_more::derive::{Display, Error};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
|
@ -131,18 +131,18 @@ pub struct EvenCore<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error indicating that an [`EvenCore`] could not be constructed.
|
/// An error indicating that an [`EvenCore`] could not be constructed.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not construct an EvenCore")]
|
#[display("Could not construct an EvenCore")]
|
||||||
pub enum EvenCoreError {
|
pub enum EvenCoreError {
|
||||||
/// Not enough samples were provided.
|
/// Not enough samples were provided.
|
||||||
#[error("Need at least two samples to create an EvenCore, but {samples} were provided")]
|
#[display("Need at least two samples to create an EvenCore, but {samples} were provided")]
|
||||||
NotEnoughSamples {
|
NotEnoughSamples {
|
||||||
/// The number of samples that were provided.
|
/// The number of samples that were provided.
|
||||||
samples: usize,
|
samples: usize,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Unbounded domains are not compatible with `EvenCore`.
|
/// Unbounded domains are not compatible with `EvenCore`.
|
||||||
#[error("Cannot create a EvenCore over an unbounded domain")]
|
#[display("Cannot create a EvenCore over an unbounded domain")]
|
||||||
UnboundedDomain,
|
UnboundedDomain,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,11 +333,11 @@ pub struct UnevenCore<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error indicating that an [`UnevenCore`] could not be constructed.
|
/// An error indicating that an [`UnevenCore`] could not be constructed.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not construct an UnevenCore")]
|
#[display("Could not construct an UnevenCore")]
|
||||||
pub enum UnevenCoreError {
|
pub enum UnevenCoreError {
|
||||||
/// Not enough samples were provided.
|
/// Not enough samples were provided.
|
||||||
#[error(
|
#[display(
|
||||||
"Need at least two unique samples to create an UnevenCore, but {samples} were provided"
|
"Need at least two unique samples to create an UnevenCore, but {samples} were provided"
|
||||||
)]
|
)]
|
||||||
NotEnoughSamples {
|
NotEnoughSamples {
|
||||||
|
@ -472,15 +472,15 @@ pub struct ChunkedUnevenCore<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that indicates that a [`ChunkedUnevenCore`] could not be formed.
|
/// An error that indicates that a [`ChunkedUnevenCore`] could not be formed.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not create a ChunkedUnevenCore")]
|
#[display("Could not create a ChunkedUnevenCore")]
|
||||||
pub enum ChunkedUnevenCoreError {
|
pub enum ChunkedUnevenCoreError {
|
||||||
/// The width of a `ChunkedUnevenCore` cannot be zero.
|
/// The width of a `ChunkedUnevenCore` cannot be zero.
|
||||||
#[error("Chunk width must be at least 1")]
|
#[display("Chunk width must be at least 1")]
|
||||||
ZeroWidth,
|
ZeroWidth,
|
||||||
|
|
||||||
/// At least two sample times are necessary to interpolate in `ChunkedUnevenCore`.
|
/// At least two sample times are necessary to interpolate in `ChunkedUnevenCore`.
|
||||||
#[error(
|
#[display(
|
||||||
"Need at least two unique samples to create a ChunkedUnevenCore, but {samples} were provided"
|
"Need at least two unique samples to create a ChunkedUnevenCore, but {samples} were provided"
|
||||||
)]
|
)]
|
||||||
NotEnoughSamples {
|
NotEnoughSamples {
|
||||||
|
@ -489,7 +489,7 @@ pub enum ChunkedUnevenCoreError {
|
||||||
},
|
},
|
||||||
|
|
||||||
/// The length of the value buffer is supposed to be the `width` times the number of samples.
|
/// The length of the value buffer is supposed to be the `width` times the number of samples.
|
||||||
#[error("Expected {expected} total values based on width, but {actual} were provided")]
|
#[display("Expected {expected} total values based on width, but {actual} were provided")]
|
||||||
MismatchedLengths {
|
MismatchedLengths {
|
||||||
/// The expected length of the value buffer.
|
/// The expected length of the value buffer.
|
||||||
expected: usize,
|
expected: usize,
|
||||||
|
@ -498,7 +498,7 @@ pub enum ChunkedUnevenCoreError {
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Tried to infer the width, but the ratio of lengths wasn't an integer, so no such length exists.
|
/// Tried to infer the width, but the ratio of lengths wasn't an integer, so no such length exists.
|
||||||
#[error("The length of the list of values ({values_len}) was not divisible by that of the list of times ({times_len})")]
|
#[display("The length of the list of values ({values_len}) was not divisible by that of the list of times ({times_len})")]
|
||||||
NonDivisibleLengths {
|
NonDivisibleLengths {
|
||||||
/// The length of the value buffer.
|
/// The length of the value buffer.
|
||||||
values_len: usize,
|
values_len: usize,
|
||||||
|
|
|
@ -4,8 +4,8 @@ use core::{
|
||||||
cmp::{max_by, min_by},
|
cmp::{max_by, min_by},
|
||||||
ops::RangeInclusive,
|
ops::RangeInclusive,
|
||||||
};
|
};
|
||||||
|
use derive_more::derive::{Display, Error};
|
||||||
use itertools::Either;
|
use itertools::Either;
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
|
@ -29,26 +29,26 @@ pub struct Interval {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that indicates that an operation would have returned an invalid [`Interval`].
|
/// An error that indicates that an operation would have returned an invalid [`Interval`].
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("The resulting interval would be invalid (empty or with a NaN endpoint)")]
|
#[display("The resulting interval would be invalid (empty or with a NaN endpoint)")]
|
||||||
pub struct InvalidIntervalError;
|
pub struct InvalidIntervalError;
|
||||||
|
|
||||||
/// An error indicating that spaced points could not be extracted from an unbounded interval.
|
/// An error indicating that spaced points could not be extracted from an unbounded interval.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Cannot extract spaced points from an unbounded interval")]
|
#[display("Cannot extract spaced points from an unbounded interval")]
|
||||||
pub struct SpacedPointsError;
|
pub struct SpacedPointsError;
|
||||||
|
|
||||||
/// An error indicating that a linear map between intervals could not be constructed because of
|
/// An error indicating that a linear map between intervals could not be constructed because of
|
||||||
/// unboundedness.
|
/// unboundedness.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not construct linear function to map between intervals")]
|
#[display("Could not construct linear function to map between intervals")]
|
||||||
pub(super) enum LinearMapError {
|
pub(super) enum LinearMapError {
|
||||||
/// The source interval being mapped out of was unbounded.
|
/// The source interval being mapped out of was unbounded.
|
||||||
#[error("The source interval is unbounded")]
|
#[display("The source interval is unbounded")]
|
||||||
SourceUnbounded,
|
SourceUnbounded,
|
||||||
|
|
||||||
/// The target interval being mapped into was unbounded.
|
/// The target interval being mapped into was unbounded.
|
||||||
#[error("The target interval is unbounded")]
|
#[display("The target interval is unbounded")]
|
||||||
TargetUnbounded,
|
TargetUnbounded,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ use cores::{EvenCore, UnevenCore};
|
||||||
|
|
||||||
use crate::{StableInterpolate, VectorSpace};
|
use crate::{StableInterpolate, VectorSpace};
|
||||||
use core::{marker::PhantomData, ops::Deref};
|
use core::{marker::PhantomData, ops::Deref};
|
||||||
|
use derive_more::derive::{Display, Error};
|
||||||
use interval::InvalidIntervalError;
|
use interval::InvalidIntervalError;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
/// A trait for a type that can represent values of type `T` parametrized over a fixed interval.
|
/// A trait for a type that can represent values of type `T` parametrized over a fixed interval.
|
||||||
///
|
///
|
||||||
|
@ -624,73 +624,74 @@ where
|
||||||
|
|
||||||
/// An error indicating that a linear reparametrization couldn't be performed because of
|
/// An error indicating that a linear reparametrization couldn't be performed because of
|
||||||
/// malformed inputs.
|
/// malformed inputs.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not build a linear function to reparametrize this curve")]
|
#[display("Could not build a linear function to reparametrize this curve")]
|
||||||
pub enum LinearReparamError {
|
pub enum LinearReparamError {
|
||||||
/// The source curve that was to be reparametrized had unbounded domain.
|
/// The source curve that was to be reparametrized had unbounded domain.
|
||||||
#[error("This curve has unbounded domain")]
|
#[display("This curve has unbounded domain")]
|
||||||
SourceCurveUnbounded,
|
SourceCurveUnbounded,
|
||||||
|
|
||||||
/// The target interval for reparametrization was unbounded.
|
/// The target interval for reparametrization was unbounded.
|
||||||
#[error("The target interval for reparametrization is unbounded")]
|
#[display("The target interval for reparametrization is unbounded")]
|
||||||
TargetIntervalUnbounded,
|
TargetIntervalUnbounded,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error indicating that a reversion of a curve couldn't be performed because of
|
/// An error indicating that a reversion of a curve couldn't be performed because of
|
||||||
/// malformed inputs.
|
/// malformed inputs.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not reverse this curve")]
|
#[display("Could not reverse this curve")]
|
||||||
pub enum ReverseError {
|
pub enum ReverseError {
|
||||||
/// The source curve that was to be reversed had unbounded domain end.
|
/// The source curve that was to be reversed had unbounded domain end.
|
||||||
#[error("This curve has an unbounded domain end")]
|
#[display("This curve has an unbounded domain end")]
|
||||||
SourceDomainEndInfinite,
|
SourceDomainEndInfinite,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error indicating that a repetition of a curve couldn't be performed because of malformed
|
/// An error indicating that a repetition of a curve couldn't be performed because of malformed
|
||||||
/// inputs.
|
/// inputs.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not repeat this curve")]
|
#[display("Could not repeat this curve")]
|
||||||
pub enum RepeatError {
|
pub enum RepeatError {
|
||||||
/// The source curve that was to be repeated had unbounded domain.
|
/// The source curve that was to be repeated had unbounded domain.
|
||||||
#[error("This curve has an unbounded domain")]
|
#[display("This curve has an unbounded domain")]
|
||||||
SourceDomainUnbounded,
|
SourceDomainUnbounded,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error indicating that a ping ponging of a curve couldn't be performed because of
|
/// An error indicating that a ping ponging of a curve couldn't be performed because of
|
||||||
/// malformed inputs.
|
/// malformed inputs.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not ping pong this curve")]
|
#[display("Could not ping pong this curve")]
|
||||||
pub enum PingPongError {
|
pub enum PingPongError {
|
||||||
/// The source curve that was to be ping ponged had unbounded domain end.
|
/// The source curve that was to be ping ponged had unbounded domain end.
|
||||||
#[error("This curve has an unbounded domain end")]
|
#[display("This curve has an unbounded domain end")]
|
||||||
SourceDomainEndInfinite,
|
SourceDomainEndInfinite,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error indicating that an end-to-end composition couldn't be performed because of
|
/// An error indicating that an end-to-end composition couldn't be performed because of
|
||||||
/// malformed inputs.
|
/// malformed inputs.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not compose these curves together")]
|
#[display("Could not compose these curves together")]
|
||||||
pub enum ChainError {
|
pub enum ChainError {
|
||||||
/// The right endpoint of the first curve was infinite.
|
/// The right endpoint of the first curve was infinite.
|
||||||
#[error("The first curve's domain has an infinite end")]
|
#[display("The first curve's domain has an infinite end")]
|
||||||
FirstEndInfinite,
|
FirstEndInfinite,
|
||||||
|
|
||||||
/// The left endpoint of the second curve was infinite.
|
/// The left endpoint of the second curve was infinite.
|
||||||
#[error("The second curve's domain has an infinite start")]
|
#[display("The second curve's domain has an infinite start")]
|
||||||
SecondStartInfinite,
|
SecondStartInfinite,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error indicating that a resampling operation could not be performed because of
|
/// An error indicating that a resampling operation could not be performed because of
|
||||||
/// malformed inputs.
|
/// malformed inputs.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
#[error("Could not resample from this curve because of bad inputs")]
|
#[display("Could not resample from this curve because of bad inputs")]
|
||||||
pub enum ResamplingError {
|
pub enum ResamplingError {
|
||||||
/// This resampling operation was not provided with enough samples to have well-formed output.
|
/// This resampling operation was not provided with enough samples to have well-formed output.
|
||||||
#[error("Not enough unique samples to construct resampled curve")]
|
#[display("Not enough unique samples to construct resampled curve")]
|
||||||
|
#[error(ignore)]
|
||||||
NotEnoughSamples(usize),
|
NotEnoughSamples(usize),
|
||||||
|
|
||||||
/// This resampling operation failed because of an unbounded interval.
|
/// This resampling operation failed because of an unbounded interval.
|
||||||
#[error("Could not resample because this curve has unbounded domain")]
|
#[display("Could not resample because this curve has unbounded domain")]
|
||||||
UnboundedDomain,
|
UnboundedDomain,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use core::f32::consts::FRAC_1_SQRT_2;
|
use core::f32::consts::FRAC_1_SQRT_2;
|
||||||
|
use derive_more::derive::Into;
|
||||||
|
|
||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
|
@ -356,7 +357,7 @@ impl approx::UlpsEq for Dir2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A normalized vector pointing in a direction in 3D space
|
/// A normalized vector pointing in a direction in 3D space
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Into)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, PartialEq))]
|
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, PartialEq))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
|
@ -534,12 +535,6 @@ impl TryFrom<Vec3> for Dir3 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Dir3> for Vec3 {
|
|
||||||
fn from(value: Dir3) -> Self {
|
|
||||||
value.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl core::ops::Deref for Dir3 {
|
impl core::ops::Deref for Dir3 {
|
||||||
type Target = Vec3;
|
type Target = Vec3;
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use core::f32::consts::{FRAC_1_SQRT_2, FRAC_PI_2, FRAC_PI_3, PI};
|
use core::f32::consts::{FRAC_1_SQRT_2, FRAC_PI_2, FRAC_PI_3, PI};
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error, From};
|
||||||
|
|
||||||
use super::{Measured2d, Primitive2d, WindingOrder};
|
use super::{Measured2d, Primitive2d, WindingOrder};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -267,7 +267,7 @@ impl Arc2d {
|
||||||
///
|
///
|
||||||
/// **Warning:** Circular sectors with negative angle or radius, or with angle greater than an entire circle, are not officially supported.
|
/// **Warning:** Circular sectors with negative angle or radius, or with angle greater than an entire circle, are not officially supported.
|
||||||
/// We recommend normalizing circular sectors to have an angle in [0, 2π].
|
/// We recommend normalizing circular sectors to have an angle in [0, 2π].
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq, From)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "bevy_reflect",
|
feature = "bevy_reflect",
|
||||||
|
@ -292,12 +292,6 @@ impl Default for CircularSector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Arc2d> for CircularSector {
|
|
||||||
fn from(arc: Arc2d) -> Self {
|
|
||||||
Self { arc }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CircularSector {
|
impl CircularSector {
|
||||||
/// Create a new [`CircularSector`] from a `radius` and an `angle`
|
/// Create a new [`CircularSector`] from a `radius` and an `angle`
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -406,7 +400,7 @@ impl CircularSector {
|
||||||
///
|
///
|
||||||
/// **Warning:** Circular segments with negative angle or radius, or with angle greater than an entire circle, are not officially supported.
|
/// **Warning:** Circular segments with negative angle or radius, or with angle greater than an entire circle, are not officially supported.
|
||||||
/// We recommend normalizing circular segments to have an angle in [0, 2π].
|
/// We recommend normalizing circular segments to have an angle in [0, 2π].
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq, From)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "bevy_reflect",
|
feature = "bevy_reflect",
|
||||||
|
@ -431,12 +425,6 @@ impl Default for CircularSegment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Arc2d> for CircularSegment {
|
|
||||||
fn from(arc: Arc2d) -> Self {
|
|
||||||
Self { arc }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CircularSegment {
|
impl CircularSegment {
|
||||||
/// Create a new [`CircularSegment`] from a `radius`, and an `angle`
|
/// Create a new [`CircularSegment`] from a `radius`, and an `angle`
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -1620,10 +1608,10 @@ pub struct ConvexPolygon<const N: usize> {
|
||||||
impl<const N: usize> Primitive2d for ConvexPolygon<N> {}
|
impl<const N: usize> Primitive2d for ConvexPolygon<N> {}
|
||||||
|
|
||||||
/// An error that happens when creating a [`ConvexPolygon`].
|
/// An error that happens when creating a [`ConvexPolygon`].
|
||||||
#[derive(Error, Debug, Clone)]
|
#[derive(Error, Display, Debug, Clone)]
|
||||||
pub enum ConvexPolygonError {
|
pub enum ConvexPolygonError {
|
||||||
/// The created polygon is not convex.
|
/// The created polygon is not convex.
|
||||||
#[error("The created polygon is not convex")]
|
#[display("The created polygon is not convex")]
|
||||||
Concave,
|
Concave,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue