-
-
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 RigidBodies only interact with Bodies with layers in their mask #49166
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested yet, but I would expect that when both bodies are dynamic and one of them ignores the contact, its mass is considered infinite (like a static/kinematic body) in order to correctly apply impulses on the other one. Otherwise the bodies are going to go through each other.
@@ -403,12 +403,12 @@ bool BodyPair2DSW::pre_solve(real_t p_step) { | |||
c.rA = global_A; | |||
c.rB = global_B - offset_B; | |||
|
|||
if (A->can_report_contacts()) { | |||
if (A->can_report_contacts() && B->layer_in_mask(A)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a member or at least local variable to avoid repeating the same logic multiple times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer it this way. It's the same format as the other condition, it's method name makes it easy to understand when reading, and the compiler will inline it anyway.
They should go through each other. If a When I originally created #42641, I used the following test project, created in 3.2 to test a combination of #42642 and #49169 2D and 3D: 15243.zip. The following videos show the output of those tests Current 3D i.e. without #42642 and #49169: |
@madmiraal You can see in the 2d version how rigid body 1 slightly goes into rigid body 2, my guess is it's a buggy collision that is due to what I'm talking about and would be fixed with my suggestion. |
07b1086
to
136ca0f
Compare
Updated to include equivalent fix from #50685. |
Superseded by #50625. |
The
RigidBody
sister PR to #42268 (Area
s) and #42641 (KinematicBody
s).Currently, when a
RigidBody
collides with anotherCollisionObject
thecollision_layer
->collision_mask
combination is checked both ways. This results in unintended and unwanted collisions.This PR ensures that
RigidBody
s only collide withCollisionObjects
that have one of theRigidBody
'scollision_layer
bits in the otherCollisionObject
'scollision_mask
. It fixes both 2D and 3D Godot physics.Note: Unlike #42268 and #42641, this PR does not apply the same fix to Bullet physics.
The final part of godotengine/godot-proposals#2775.