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 Area monitorable in 2D and 3D Godot physics. #41698

Merged
merged 1 commit into from
Nov 20, 2021

Conversation

madmiraal
Copy link
Contributor

@madmiraal madmiraal commented Sep 2, 2020

In Godot physics (2D and 3D), when an Area's Monitorable property is changed, it updates the broadphase collision checker by changing the static field. This removes any active collision pairs and creates new ones. Currently, deleting an active collision pair will trigger area_exited signals. However, the Area's status is not changed, so the new pair is ignored until something else forces an update e.g. moving the Area.

This patch does two things, both of which are required to fix the issues with changes to Monitorable not working. First, when changing the Monitorable property, it calls _shapes_changed(), which adds the Area to the Space's moved areas' list, which will trigger a collision update for the new collision pair created. Second, it ensures that only areas that were Monitorable are added to the Areas removed list when the collision pair is deleted. This also ensures that the new pair's area_entered signals are not cancelled by the old pair's area_exited signals.

Fixes #23484
Fixes #27441

Note: This does not fix being unable to disable Monitorable in Bullet physics. This is fixed in #42306.

@pouleyKetchoupp
Copy link
Contributor

This fix looks good, it just needs a rebase.

and only remove area from query when deleting pair if it was monitorable.
@akien-mga

This comment has been minimized.

@akien-mga akien-mga merged commit a8b563d into godotengine:master Nov 20, 2021
@akien-mga
Copy link
Member

Thanks!

@madmiraal madmiraal deleted the fix-23484 branch November 20, 2021 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants