RobustToolbox
RobustToolbox copied to clipboard
StartCollideEvent is raised for fixtures that should not collide
Description
The StartCollideEvent
is incorrectly raised for fixtures that shouldn't collide, given their layers and masks.
Reproduction
A simple example is Remilia being slowed down by a spill of glue.
// glue
var fixtureACollisionMask = 10; // ItemMask = Impassable | HighImpassable
var fixtureACollisionLayer = 20; // SlipLayer = MidImpassable | LowImpassable
// bat
var fixtureBCollisionMask = 10; // FlyingMobMask = Impassable | HighImpassabl
var fixtureBCollisionLayer = 65; // FlyingMobLayer = Opaque | BulletImpassable
var shouldCollide = !((fixtureACollisionMask & fixtureBCollisionLayer) == 0x0 &&
(fixtureBCollisionMask & fixtureACollisionLayer) == 0x0); // False
I tried to debug it a little, and it looks like CollideContacts() skips the ShouldCollide check when the ContactFlags.Filter isn't set, and it seems the flag isn't being set correctly.
https://github.com/space-wizards/RobustToolbox/blob/ace8334a3e39ffe7d3ad94c5caba48d245ddfe7b/Robust.Shared/Physics/Systems/SharedPhysicsSystem.Contacts.cs#L405-L418