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

Adds checks to not normalize zero vectors #6642

Open
wants to merge 7 commits into
base: dev/patch
Choose a base branch
from

Conversation

Phill310
Copy link
Contributor

@Phill310 Phill310 commented May 4, 2024

Description

Checks if a vector is zero before calling Vector#normalize() in order to avoid creating vectors with infinite components (stemming from dividing by 0). Currently, syntax that would cause an internal error now returns a zero vector which might be a breaking change according to sovde.


Target Minecraft Versions: any
Requirements: none
Related Issues: #6194

@sovdeeth sovdeeth added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. 2.8 Targeting a 2.8.X version release labels May 4, 2024
@sovdeeth
Copy link
Member

sovdeeth commented May 4, 2024

I think isZero is only available on Paper

No, it's just added very recently in spigot. 1.19.3+

@Phill310
Copy link
Contributor Author

Phill310 commented May 4, 2024

Oh shoot, i didnt even think about checking for that. Ill try to find a different method.
Do you think it would be a bad idea to make my own isZero method that checks the x,y,z componenets? If thats the way to go would i just add it to each file where I use it or would i put it in some utils class

@sovdeeth
Copy link
Member

sovdeeth commented May 5, 2024

Oh shoot, i didnt even think about checking for that. Ill try to find a different method. Do you think it would be a bad idea to make my own isZero method that checks the x,y,z componenets? If thats the way to go would i just add it to each file where I use it or would i put it in some utils class

Sure, slap it in VectorMath

@Moderocky Moderocky added the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label May 6, 2024
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

oh this needs regression tests!

@sovdeeth sovdeeth removed the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label May 8, 2024
@Phill310
Copy link
Contributor Author

Phill310 commented May 9, 2024

Hm, it doesn't seem to be my new test failing and the branch seems to be up to date with dev/patch so I am not sure what the issue is here
Using the new error keyword in the assert statement seems to have been the issue. I guess it hasn't been added to dev/patch yet

@Phill310 Phill310 requested a review from sovdeeth May 10, 2024 00:12
@sovdeeth sovdeeth added the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.8 Targeting a 2.8.X version release bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants