Skip to content

Fix False Null MOI warnings#4535

Merged
Goober5000 merged 3 commits into
scp-fs2open:masterfrom
wookieejedi:fix-null-vec-calculations
Aug 15, 2022
Merged

Fix False Null MOI warnings#4535
Goober5000 merged 3 commits into
scp-fs2open:masterfrom
wookieejedi:fix-null-vec-calculations

Conversation

@wookieejedi

Copy link
Copy Markdown
Member

In #4443, fl_near_zero was set to use default epsilon values in the IS_VEC_NULL check. In this comparison, epsilon is the wrong threshold because it used to have a much smaller threshold. The fix restores the previous definitions of IS_VEC_NULL and IS_VEC_NULL_SQ_SAFE by exposing the epsilon value as an optional parameter (similar to how IS_NEAR_ZERO used to work. This PR also restores IS_VEC_NULL_SQ_SAFE where it was replaced by IS_VEC_NULL.

Fixes #4534.

In #4443, `fl_near_zero` was set to use default epsilon values in the `IS_VEC_NULL` check. In this comparison, epsilon is the wrong threshold because it used to have a much smaller threshold. The fix restores the previous definitions of `IS_VEC_NULL` and `IS_VEC_NULL_SQ_SAFE` by exposing the epsilon value as an optional parameter (similar to how `IS_NEAR_ZERO` used to work. This PR also restores `IS_VEC_NULL_SQ_SAFE` where it was replaced by `IS_VEC_NULL.`
@wookieejedi wookieejedi requested a review from asarium as a code owner August 13, 2022 13:59
Comment thread code/math/vecmat.h Outdated
@wookieejedi wookieejedi added fix A fix for bugs, not-a-bugs, and/or regressions. models Issues or features having to do with model data (like animations or geometry) labels Aug 13, 2022
Comment thread code/math/floating.h
Comment thread code/math/vecmat.h Outdated
@wookieejedi wookieejedi removed the request for review from asarium August 14, 2022 02:34

@Goober5000 Goober5000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually hang on while I research some floating point things

@Goober5000

Copy link
Copy Markdown
Contributor

Approving this for the time being. Other floating-point changes can go in a follow-up PR.

@Goober5000 Goober5000 merged commit 0ca8add into scp-fs2open:master Aug 15, 2022
Goober5000 added a commit to Goober5000/fs2open.github.com that referenced this pull request Aug 19, 2022
Floating-point comparisons are tricky beasts.  See this article for a good summary of the issues involved:
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

This PR improves support somewhat, although there are obviously situations in the code (such as comparisons to 0) that should still be addressed.  This PR makes the following improvements:
1) Tightens the threshold on `IS_VEC_NULL` and `IS_VEC_NULL_SQ_SAFE` from 1e-16 and 1e-36 to FLT_EPSILON
2) Tightens the threshold for parsing `turn_time` in POFs
3) Restores the previous implementation of `fl_equal`
4) Adds a dedicated `IS_MOI_VEC_NULL` for moment of inertia values
5) Improves documentation

Follow-up to scp-fs2open#4535 and scp-fs2open#4443.
Goober5000 added a commit to Goober5000/fs2open.github.com that referenced this pull request Aug 26, 2022
Floating-point comparisons are tricky beasts.  See this article for a good summary of the issues involved:
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

This PR improves support somewhat, although there are obviously situations in the code (such as comparisons to 0) that should still be addressed.  This PR makes the following improvements:
1) Tightens the threshold on `IS_VEC_NULL` and `IS_VEC_NULL_SQ_SAFE` from 1e-16 and 1e-36 to FLT_EPSILON
2) Tightens the threshold for parsing `turn_time` in POFs
3) Restores the previous implementation of `fl_equal`
4) Adds a dedicated `IS_MOI_VEC_NULL` for moment of inertia values
5) Improves documentation

Follow-up to scp-fs2open#4535 and scp-fs2open#4443.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. models Issues or features having to do with model data (like animations or geometry)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False Null MOI warnings

4 participants