Skip to content

rename Transform::compute_matrix to to_matrix #19646

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

Open
wants to merge 4 commits into from
Open
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
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/skybox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl ExtractComponent for Skybox {
SkyboxUniforms {
brightness: skybox.brightness * exposure,
transform: Transform::from_rotation(skybox.rotation)
.compute_matrix()
.to_matrix()
.inverse(),
#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]
_wasm_padding_8b: 0,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/light/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ pub fn update_point_light_frusta(

for (view_rotation, frustum) in view_rotations.iter().zip(cubemap_frusta.iter_mut()) {
let world_from_view = view_translation * *view_rotation;
let clip_from_world = clip_from_view * world_from_view.compute_matrix().inverse();
let clip_from_world = clip_from_view * world_from_view.to_matrix().inverse();

*frustum = Frustum::from_clip_from_world_custom_far(
&clip_from_world,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/light_probe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ fn gather_environment_map_uniform(
let environment_map_uniform = if let Some(environment_map_light) = environment_map_light {
EnvironmentMapUniform {
transform: Transform::from_rotation(environment_map_light.rotation)
.compute_matrix()
.to_matrix()
.inverse(),
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_transform/src/components/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ impl Transform {
self
}

/// Returns the 3d affine transformation matrix from this transforms translation,
/// Computes the 3d affine transformation matrix from this transform's translation,
/// rotation, and scale.
#[inline]
pub fn compute_matrix(&self) -> Mat4 {
pub fn to_matrix(&self) -> Mat4 {
Copy link
Member

@janhohenheim janhohenheim Jun 14, 2025

Choose a reason for hiding this comment

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

  • Do we even need this method if we implemented From<Transform> for Mat4? oh I see, people on Discord seem to agree that From should not be implemented here
  • Also, do we want to keep a deprecated alias for a nicer migration?
  • Anyways, better than the current state of things :)

Copy link
Member

Choose a reason for hiding this comment

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

Eh, this is pretty easy to figure out and niche. The deprecated alias is solidly nice-to-have.

Mat4::from_scale_rotation_translation(self.scale, self.rotation, self.translation)
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Transform and GlobalTransform::compute_matrix rename
pull_requests: [19643, 19646]
---

`GlobalTransform::compute_matrix` has been renamed to `GlobalTransform::to_matrix` because it does not compute anything, it simply moves data into a different type.
`Transform::compute_matrix` has been renamed to `Transform::to_matrix` for consistency with `GlobalTransform`.