Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove thiserror from bevy_transform #15761

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/bevy_transform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [
"bevy",
], optional = true }
serde = { version = "1", features = ["derive"], optional = true }
thiserror = "1.0"
derive_more = { version = "1", default-features = false, features = [
"error",
"from",
"display",
] }

[dev-dependencies]
bevy_tasks = { path = "../bevy_tasks", version = "0.15.0-dev" }
Expand Down
9 changes: 2 additions & 7 deletions crates/bevy_transform/src/components/global_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use super::Transform;
use bevy_math::{Affine3A, Dir3, Isometry3d, Mat4, Quat, Vec3, Vec3A};
#[cfg(all(feature = "bevy-support", feature = "serialize"))]
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
use derive_more::derive::From;
#[cfg(feature = "bevy-support")]
use {
bevy_ecs::{component::Component, reflect::ReflectComponent},
Expand Down Expand Up @@ -39,7 +40,7 @@ use {
/// - [`transform`][transform_example]
///
/// [transform_example]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs
#[derive(Debug, PartialEq, Clone, Copy)]
#[derive(Debug, PartialEq, Clone, Copy, From)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "bevy-support",
Expand Down Expand Up @@ -274,12 +275,6 @@ impl From<Transform> for GlobalTransform {
}
}

impl From<Affine3A> for GlobalTransform {
fn from(affine: Affine3A) -> Self {
Self(affine)
}
}

impl From<Mat4> for GlobalTransform {
fn from(world_from_local: Mat4) -> Self {
Self(Affine3A::from_mat4(world_from_local))
Expand Down
13 changes: 8 additions & 5 deletions crates/bevy_transform/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy_ecs::{
system::{Query, SystemParam},
};
use bevy_hierarchy::{HierarchyQueryExt, Parent};
use thiserror::Error;
use derive_more::derive::{Display, Error};

use crate::components::{GlobalTransform, Transform};

Expand Down Expand Up @@ -64,17 +64,20 @@ fn map_error(err: QueryEntityError, ancestor: bool) -> ComputeGlobalTransformErr
}

/// Error returned by [`TransformHelper::compute_global_transform`].
#[derive(Debug, Error)]
#[derive(Debug, Error, Display)]
pub enum ComputeGlobalTransformError {
/// The entity or one of its ancestors is missing the [`Transform`] component.
#[error("The entity {0:?} or one of its ancestors is missing the `Transform` component")]
#[display("The entity {_0:?} or one of its ancestors is missing the `Transform` component")]
#[error(ignore)]
MissingTransform(Entity),
/// The entity does not exist.
#[error("The entity {0:?} does not exist")]
#[display("The entity {_0:?} does not exist")]
#[error(ignore)]
NoSuchEntity(Entity),
/// An ancestor is missing.
/// This probably means that your hierarchy has been improperly maintained.
#[error("The ancestor {0:?} is missing")]
#[display("The ancestor {_0:?} is missing")]
#[error(ignore)]
MalformedHierarchy(Entity),
}

Expand Down