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

Rect2.intersects implementation wrong #947

Closed
Shou opened this issue Sep 20, 2022 · 0 comments · Fixed by #948
Closed

Rect2.intersects implementation wrong #947

Shou opened this issue Sep 20, 2022 · 0 comments · Fixed by #948
Labels
Milestone

Comments

@Shou
Copy link
Contributor

Shou commented Sep 20, 2022

it seems that it doesn't match the Godot code logic:

https://github.com/godot-rust/godot-rust/blob/e131df29c3ccd9d1ea733d25d5e621f6df2e2817/gdnative-core/src/core_types/geom/rect2.rs#L114-L118

vs

			if (position.x >= (p_rect.position.x + p_rect.size.width)) {
				return false;
			}
			if ((position.x + size.width) <= p_rect.position.x) {
				return false;
			}
			if (position.y >= (p_rect.position.y + p_rect.size.height)) {
				return false;
			}
			if ((position.y + size.height) <= p_rect.position.y) {
				return false;
			}

The last line of Rust should be

         && self.position.y + self.size.y > b.position.y

Rect2.intersects_including_borders has the same error as well.

@Shou Shou added the bug label Sep 20, 2022
bors bot added a commit that referenced this issue Sep 20, 2022
948: fix(rect2): match Rect2.intersects with Godot logic r=Bromeon a=Shou

Fixes #947

Co-authored-by: Shou <x+g@shou.io>
@Bromeon Bromeon added this to the v0.10.2 milestone Sep 20, 2022
@bors bors bot closed this as completed in 5a5a62d Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants