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

Fix glm::is_null epsilon test #1350

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Fix glm::is_null epsilon test #1350

wants to merge 1 commit into from

Conversation

CAD97
Copy link
Contributor

@CAD97 CAD97 commented Jan 13, 2024

The existing implementation compares each component to zero with an epsilon; effectively glm::all(glm::is_comp_null(v, epsilon)). This probably isn't the desired semantics when calling glm::is_null; rather, we want to determine if the magnitude of the vector is within epsilon units of zero. It's the question of circle versus square.

The new behavior matches that of OpenGL Mathematics.

@CAD97
Copy link
Contributor Author

CAD97 commented Jan 13, 2024

Unfortunately it seems that the existing bound isn't sufficient to call .norm_squared(), so this would be an API breaking change.

@CAD97 CAD97 force-pushed the patch-4 branch 2 times, most recently from f6e9e8c to b37ae36 Compare January 13, 2024 05:05
The existing implementation compares each component to zero with
an epsilon; effectively `glm::all(glm::is_comp_null(v, epsilon))`.
This probably isn't the desired semantics when calling `glm::is_null`;
rather, we want to determine if the magnitude of the vector is within
`epsilon` units of zero. It's the question of circle versus square.

This behavior matches that of OpenGL Mathematics.
@CAD97
Copy link
Contributor Author

CAD97 commented Jan 13, 2024

(Apologies for the force pushes; I initially wrote the patch in GitHub's UI without rustc to yell at me when I got things wrong. It should be fixed and squashed now.)

@tpdickso
Copy link
Collaborator

Looks like this is correct; glm computes this for vectors differently than for matrices.

Code change LGTM but I'll leave the semver-wrangling to someone with more experience.

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

Successfully merging this pull request may close these issues.

None yet

2 participants