Remove force enter/exit logic from JoltArea3D
#106693
Merged
+6
−101
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.
Prior to merging #106490 we were unable to rely on Jolt's contact listener to emit the relevant events whenever an overlapping body/area would enter/exit as a result of disabling the
Area3D.monitoring
property, since it had no actual impact on the underlying collision detection. This led to having a bunch of messy bookkeeping code inJoltArea3D
that would essentially just simulate those events as you toggled said property.Now with #106490 merged we can finally remove all that, in favor of just relying on Jolt's contact listener events, greatly simplifying things.
There was also a minor related bug lurking in
JoltArea3D::_space_changing
, from #100983, which is that we were queueing up a bunch of exit events (one per shape pair) as part of force-exiting all the overlapping bodies/areas, as theArea3D
was leaving/changing the physics space. Then we would immediately remove that sameArea3D
from the list of areas that were meant to flush their events next tick, since its corresponding scene node would be gone by then anyway. This meant that if you never actually freed that area (e.g. when just pulling it out of the scene tree temporarily) you would be sitting on some amount of allocated memory (i.e. the pending events) for no reason whatsoever.Now instead we just clear the entire
bodies_by_id
andareas_by_id
maps, which hold all the overlaps and any pending events they might have, as we leave/change the physics space.