-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Ensure Areas and Bodies only interact with Areas with layers in their mask #42268
Conversation
This changes how the layer and mask check works. It may be good or bad depending the situations. For example, the bullet default check make sure that layer and mask matches in both ways. It allows a grater range of combination but in the past was considered too difficult to get right, so the Godot approach was kept. I think we need a proposal to change this behaviour, and in case the check should behave the same also for RigidBodies, otherwise would be too confusing. |
@madmiraal I looked at the relevant issue-tests (take a look at the attached collection) on the 3.2 branch and noticed the following with the PR:
Someone's 4yr old comment »I intuitively expect that an object would live in it's layers, and see stuff in it's mask.« |
@AndreaCatania This PR fixes an old issue (#7644). I understand that when issues are old, people get used to things not working and then are surprised when they are fixed and things behave differently. But I don't think that there is an argument for not fixing an issue simply because it is old. @capnm Thanks for testing. This PR specifically addresses the issues of |
The example project doesn't have the |
In case someone has time to take a quick look at the merge (pr41699 + pr42268 ;) |
It works following a decision made time ago, so it's working as intended. If you think that such decision should be changed (and I'm not against this idea), I think we should discuss it in a proposal. Also, I think that such change cannot be back ported to 3.2 since it's breaking change. |
@AndreaCatania, source for your statement that it is following a deliberate decision made in the past? To me it looks more like a bug that is being fixed now after being overlooked for years. |
Godot physics engine was working in that way because reduz thought it was the easiest thing to have. I'm not against changing it, rather in the past I proposed to stick with bullet standard that allows more combinations (similar to the following change). Since it's working as was designed, I'm saying this is not a bug, because it's already working as intended. I think we need a proposal because this is a change in how the engine behave, and I think we should discuss how it should be. Especially because I think that RigidBody and Area should behave exactly the same, so we need a common agreement. Which is not strange, since the current workflow to change the engine behavior is to open a proposal and discuss it. |
#42641 is the sister PR for |
Rebased following #42639. |
The documentation only states that it's checked both ways: If we ignore that, we're just going to end up with as many issues the other way around from users who expect the original behavior to be correct. Godot 4.0 would be a great time to make this change though, and I'm personally all for it. So I agree with @AndreaCatania that a proposal is the best route. It can be very short, but it's just to summarize what collision layer/mask rules should be in different cases (including kinematic bodies as well, and maybe some other cases). This proposal can also be used to discuss how to update the documentation, which is needed too. |
I recently ran into this issue and I strongly agree with the quote I found on the linked PR:
Having it be bidirectional makes it harder to manage in my opinion. When trying to figure out how something works I defer to the documentation. In this case
Given that an area can be scanning no layers (having no layers in it's) mask, then that area should not be detecting any collisions. As it stands you can't look at the Is there currently any proposal for this change to be included in 4.0? |
I'm having a problem: |
Now we have an approved proposal: So this change is welcome for 4.0, the PR just needs a rebase. |
6ec013c
to
f20c2a7
Compare
Updated to include equivalent fix from #50685. |
Superseded by #51801. |
Currently, when interacting with an
Area
, thecollision_layer
-collision_mask
combination is checked both ways. This results in interactions that are not wanted:Area
's mask bit is disabled, it should not respond toCollisionObject
s with that layer bit set.CollisionObject
's layer bit is disabled, anArea
with that mask bit set, should not respond to theCollisionObject
.However, in both cases, if the other
CollisionObject
's mask matches one of theArea
's layer bits, theArea
will incorrectly respond to the otherCollisionObject
.This PR ensures that
Area
s only respond toCollisionObject
s that have layer bits that match theArea
's mask bits. It fixes both 2D and 3D (Godot and Bullet) physics.Fixes #7644.