Fix KinematicBody2D floor detection regression #45340
Closed
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.
These changes modify a specific part of #42576 that was skipping rest info checking when no collision occurred in the motion check.
Having this check back allows floor detection to be more reliable by checking for rest info consistently (#45259).
On the other hand, one-way collision needs another fix in order to avoid inconsistencies between motion check and rest info check that causes bugs like #25967, which was fixed by skipping the rest info check in this case. This is done by restoring
valid_depth
in rest info check and set it the same way as in motion check to make it work more consistently with one-way collision (other cases are not affected).Also making minor changes in
_rest_cbk_result
in order to early exit by doing depth tests first, before extra calculations for normal checking.This is tested on multiple use cases to make sure this PR doesn't revert a previous fix for
KinematicBody2D
:KinematicBody2D hugs corners when using move_and_slide() #43012 is still fixedEdit: Actually this issue now occurs again, so it would have to be re-opened and needs a separate fix.
Add One Way Collision for 2D Physics tests godot-demo-projects#573
Fixes #45259