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

[Merged by Bors] - Add builder methods to Transform #2778

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions crates/bevy_transform/src/components/global_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ impl GlobalTransform {
self
}

#[doc(hidden)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add doc(hidden) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it because the other creation methods (looking_at and from_*) are all doc(hidden).

I think it's a bit strange that they are hidden but users don't usually create GlobalTransforms.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yeah then i guess we can just leave this as-is for now and then circle back if/when we need to with docs.

#[inline]
pub fn with_translation(mut self, translation: Vec3) -> Self {
self.translation = translation;
self
}

#[doc(hidden)]
#[inline]
pub fn with_rotation(mut self, rotation: Quat) -> Self {
self.rotation = rotation;
self
}

#[doc(hidden)]
#[inline]
pub fn with_scale(mut self, scale: Vec3) -> Self {
self.scale = scale;
self
}


/// Returns the 3d affine transformation matrix from this transforms translation,
/// rotation, and scale.
#[inline]
Expand Down
21 changes: 21 additions & 0 deletions crates/bevy_transform/src/components/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,27 @@ impl Transform {
self
}

/// Returns this [`Transform`] with a new translation.
#[inline]
pub fn with_translation(mut self, translation: Vec3) -> Self {
self.translation = translation;
self
}

/// Returns this [`Transform`] with a new rotation.
#[inline]
pub fn with_rotation(mut self, rotation: Quat) -> Self {
self.rotation = rotation;
self
}

/// Returns this [`Transform`] with a new scale.
#[inline]
pub fn with_scale(mut self, scale: Vec3) -> Self {
self.scale = scale;
self
}

/// Returns the 3d affine transformation matrix from this transforms translation,
/// rotation, and scale.
#[inline]
Expand Down