Fix Area monitorable in 2D and 3D Godot physics. #41698
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Godot physics (2D and 3D), when an
Area
'sMonitorable
property is changed, it updates the broadphase collision checker by changing thestatic
field. This removes any active collision pairs and creates new ones. Currently, deleting an active collision pair will triggerarea_exited
signals. However, theArea
's status is not changed, so the new pair is ignored until something else forces an update e.g. moving theArea
.This patch does two things, both of which are required to fix the issues with changes to
Monitorable
not working. First, when changing theMonitorable
property, it calls_shapes_changed()
, which adds theArea
to theSpace
's moved areas' list, which will trigger a collision update for the new collision pair created. Second, it ensures that only areas that wereMonitorable
are added to theAreas
removed list when the collision pair is deleted. This also ensures that the new pair'sarea_entered
signals are not cancelled by the old pair'sarea_exited
signals.Fixes #23484
Fixes #27441
Note: This does not fix being unable to disable
Monitorable
in Bullet physics. This is fixed in #42306.