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 physics events being interpreted twice for nodes in canvas layer #66076

Conversation

Sauermann
Copy link
Contributor

@Sauermann Sauermann commented Sep 18, 2022

resolve #64652

Currently GodotPhysicsDirectSpaceState2D::intersect_point returns, when given the default viewport canvas layer as argument, also ShapeResults that belong to other canvas layers within the current viewport.
Since canvas layer of these nodes can have a different transform, they may not intersect with the given point.

This patch introduces an additional parameter to PhysicsPointQueryParameters2D, which governs how canvas_instance_id == 0 should be handled.

Updated 2022-12-12: Fix merge conflict

@Sauermann Sauermann requested a review from a team as a code owner September 18, 2022 22:09
@Sauermann Sauermann changed the title Fix physics events being interpreted twice when in canvas layer Fix physics events being interpreted twice for nodes in canvas layer Sep 18, 2022
@akien-mga akien-mga added this to the 4.0 milestone Sep 19, 2022
@Sauermann Sauermann force-pushed the fix-double-physics-input-events-for-layers branch from cbbb2af to f3fecd0 Compare December 5, 2022 12:38
@Sauermann Sauermann requested review from a team as code owners December 5, 2022 12:38
@Sauermann Sauermann force-pushed the fix-double-physics-input-events-for-layers branch from f3fecd0 to ca1272f Compare December 5, 2022 12:42
@Sauermann
Copy link
Contributor Author

Sauermann commented Dec 5, 2022

I have updated the PR according to the discussion with @rburing on 2022-12-05 in the Physics-channel (https://chat.godotengine.org/channel/physics?msg=pxMvfyFwZWch953dk)
This version is backwards-compatible for handling multiple canvas layers which have the same transform.

@Sauermann Sauermann force-pushed the fix-double-physics-input-events-for-layers branch from ca1272f to f18c898 Compare December 12, 2022 11:02
@rburing
Copy link
Member

rburing commented Jan 31, 2023

I'd prefer to just remove the special treatment of canvas_instance_id == 0 in intersect_point (instead of making it optional), since that is pretty much incompatible with the concept that canvas layers can be transformed. IIRC that's how this PR was originally (minus the docs update), and I prefer that (with docs) to the current (more hacky) variant.

That would break compatibility for people using intersect_point with areas/bodies in several canvas layers (and expecting to hit all of them in one query). I'd say it's worth it for fixing the bug and keeping the API clean. (We could make a note about the behavior change in the blog post of the beta release.)

@Sauermann Sauermann force-pushed the fix-double-physics-input-events-for-layers branch from f18c898 to 7e056f1 Compare January 31, 2023 22:15
@Sauermann
Copy link
Contributor Author

The original version of the PR can be seen at cbbb2af (not sure how long github keeps this cached version).

I have reverted the PR to the original version and updated the docs to additionally describe the case canvas_instance_id == 0.

@akien-mga akien-mga merged commit b7c0f61 into godotengine:master Feb 1, 2023
@akien-mga
Copy link
Member

Thanks!

@Sauermann Sauermann deleted the fix-double-physics-input-events-for-layers branch February 1, 2023 07:28
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.

InputEvent runs twice if object is a child of CanvasLayer Node
3 participants