Add libm feature to bevy_math#11238
Merged
mockersf merged 1 commit intobevyengine:mainfrom Jan 6, 2024
Merged
Conversation
alice-i-cecile
approved these changes
Jan 6, 2024
Member
|
Great PR description: this is exactly the sort of context that I wish more contributors gave. |
100-TomatoJuice
approved these changes
Jan 6, 2024
mockersf
approved these changes
Jan 6, 2024
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 16, 2024
# Objective gltf-rs does its own computations when accessing `transform.matrix()` which does not use glam types, rendering #11238 useless if people were to load gltf models and expecting the results to be deterministic across platforms. ## Solution Move the computation to bevy side which uses glam types, it was already used in one place, so I created one common function to handle the two cases. The added benefit this has, is that some gltf files can have translation, rotation and scale directly instead of matrix which skips the transform computation completely, win-win.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Different platforms use their own implementations of several mathematical functions (especially transcendental functions like sin, cos, tan, atan, and so on) to provide hardware-level optimization using intrinsics. This is good for performance, but bad when you expect consistent outputs across machines.
libmis a widely used crate that provides mathematical functions that don't use intrinsics likestdfunctions. This allows bit-for-bit deterministic math across hardware, which is crucial for things like cross-platform deterministic physics simulation.Glam has the
libmfeature for usinglibmfor the math in its own types. This would be nice to expose as a feature inbevy_math.Solution
Add
libmfeature tobevy_math. We could name it something likeenhanced-determinism, but this wouldn't be accurate for the rest of Bevy, so I think justlibmis more fitting and explicit.