You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix glTF coordinate conversion not converting tangents (#20573)
# Objective
Fix glTF coordinate conversion not converting tangents.
<img width="995" height="565" alt="image"
src="https://github.com/user-attachments/assets/20aada7a-39fe-4527-b257-c5efb4555aaf"
/>
Report:
https://discord.com/channels/691052431525675048/692572690833473578/1405362252617355335
Thread:
https://discord.com/channels/691052431525675048/1405451520836898848
## Solution
Fixed by removing a redundant copy of the tangent attributes.
In #5370 attribute copying was moved to a more generic function (see
`convert_attribute`). But one code path was left behind, so the tangents
are actually copied twice. This is technically a bug, but a harmless one
since both copies are the same.
Later on, #19633 added the option to convert attribute coordinates. But
only the first tangent copy (in `convert_attribute`) applies the
conversion - the second copy will overwrite them with unconverted
values. This PR removes the second copy.
There's also some minor code quality tweaks - prefer
`contains_attribute()` to `attribute().is_some()`, and fixed some bad
indentation in log macros. I can revert these if we want to play it
safe.
## Testing
Tested a modified version of example `load_gltf` with and without
feature `gltf_convert_coordinates_default`. Also tested after hacking
the loader to use the code path where tangents are recalculated.
"Missing vertex tangents for {}, computing them using the mikktspace algorithm. Consider using a tool such as Blender to pre-compute the tangents.", file_name
784
-
);
779
+
"Missing vertex tangents for {}, computing them using the mikktspace algorithm. Consider using a tool such as Blender to pre-compute the tangents.", file_name
780
+
);
785
781
786
782
let generate_tangents_span = info_span!("generate_tangents", name = file_name);
787
783
788
784
generate_tangents_span.in_scope(|| {
789
785
ifletErr(err) = mesh.generate_tangents(){
790
786
warn!(
791
-
"Failed to generate vertex tangents using the mikktspace algorithm: {}",
792
-
err
793
-
);
787
+
"Failed to generate vertex tangents using the mikktspace algorithm: {}",
0 commit comments