Skip to content

Fix mesh tangent attribute matching in mesh transform operations #17992

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

Conversation

aloucks
Copy link
Contributor

@aloucks aloucks commented Feb 23, 2025

Fixes #17170

Objective

Tangents are not currently transformed as described in #17170. I came across this while working on #17989 and it seemed like low hanging fruit.

@aloucks aloucks force-pushed the issue-17170-mesh-transform-tangents branch from f49ae62 to 2bd4cac Compare February 23, 2025 02:16
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-glTF Related to the glTF 3D scene/model format labels Feb 23, 2025
@aloucks aloucks force-pushed the issue-17170-mesh-transform-tangents branch 3 times, most recently from 7545db6 to c324540 Compare February 24, 2025 21:45
@aloucks aloucks force-pushed the issue-17170-mesh-transform-tangents branch from c324540 to fecdcb3 Compare March 3, 2025 01:35
Copy link
Contributor

@greeble-dev greeble-dev left a comment

Choose a reason for hiding this comment

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

I've added a test and confirmed this PR fixes the issue. Before and after below. I'll submit the test as a separate PR, although I wouldn't object if it got rolled into this PR.

image
image

self.attribute_mut(Mesh::ATTRIBUTE_TANGENT)
{
// Transform tangents
tangents.iter_mut().for_each(|tangent| {
*tangent = (rotation * Vec3::from_slice(tangent).normalize_or_zero()).to_array();
let handedness = tangent[3];
*tangent = (rotation * Vec3::from_slice(tangent).normalize_or_zero())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this normalize is redundant? Although it's consistent with the normal calculation, so probably not worth changing either way. Flagging up just for a second opinion.

@superdump superdump added this pull request to the merge queue Mar 7, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 7, 2025
Merged via the queue into bevyengine:main with commit edba54a Mar 7, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-glTF Related to the glTF 3D scene/model format C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tangents are not updated when transforming a Mesh
4 participants