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

[3.x] Float literals - fix math classes to allow 32 bit calculations #58492

Merged
merged 1 commit into from
Mar 6, 2022

Conversation

lawnjelly
Copy link
Member

@lawnjelly lawnjelly commented Feb 24, 2022

Converts float literals from double format (e.g. 0.0) to float format (e.g. 0.0f) or integer where appropriate for 32 bit calculations, and cast to (real_t) or (float) as appropriate.

This ensures that appropriate calculations will be done at 32 bits when real_t is compiled as float, rather than promoted to 64 bits.

Combined version of #57703 and #58488 for 3.x

Notes

  • I opted to combine these into one PR for 3.x, just saves me going through the same code twice.
  • In contrast to the 4.x version this also covers the BVH.

@lawnjelly lawnjelly requested a review from a team as a code owner February 24, 2022 10:53
Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

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

As with the other PR, the only notable behavior changes are all things that we don't care much about precision of, such as comparisons with 0.99 or 0.0001.

Unlike the other PR, for 3.x we can assume real_t will always be float, so adding f suffixes is safer here since calculations should be 32-bit anyway.

@Calinou Calinou added this to the 3.5 milestone Feb 24, 2022
Converts float literals from double format (e.g. 0.0) to float format (e.g. 0.0f) where appropriate for 32 bit calculations, and cast to (real_t) or (float) as appropriate.

This ensures that appropriate calculations will be done at 32 bits when real_t is compiled as float, rather than promoted to 64 bits.
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants