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

Replace is_zero_approx(A.distance_to(B)) with A==B #31395

Merged
merged 1 commit into from
Aug 20, 2019

Conversation

ptrojahn
Copy link
Contributor

@ptrojahn ptrojahn commented Aug 15, 2019

Related to #22988 (Fixes the holes in the shape of
the first comment)

@ptrojahn ptrojahn requested a review from BastiaanOlij as a code owner August 15, 2019 16:43
modules/csg/csg.cpp Outdated Show resolved Hide resolved
@aaronfranke
Copy link
Member

aaronfranke commented Aug 16, 2019

The reason this issue exists is that is_zero_approx is not actually the right thing to use here in the first place. Increasing the tolerance will only hide the true cause of the problem.

The purpose of this code is seems to be to check if the distance between two vectors is nearly zero. In other words, check if the vectors are approximately equal. Thanks to #18992, this is what the == operator does, so the fix should be if (segment[j] == points[i].point) {

There seem to be a lot of other places that have this problem, we can investigate using this command in Bash: grep -RIn distance_ | grep Math::is_zero_approx

@akien-mga akien-mga added this to the 3.2 milestone Aug 17, 2019
Related to godotengine#22988 (Fixes the holes in the shape of
the first comment)
@ptrojahn
Copy link
Contributor Author

@aaronfranke Good idea! Didn't know == handles that.

@ptrojahn ptrojahn changed the title Fix holes in csg shapes Replace is_zero_approx(A.distance_to(B)) with A==B Aug 19, 2019
@akien-mga akien-mga merged commit a8db4c8 into godotengine:master Aug 20, 2019
@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.

5 participants