/** * @brief Check collision conditions to follow Unity's guidelines. * * @return False if bodies should not collide. **/ public static bool CheckCollisionConditions(Fixture fixtureA, Fixture fixtureB) { Body body1 = fixtureA.Body; Body body2 = fixtureB.Body; if (body1.disabled || body2.disabled || !physicsManager.IsCollisionEnabled(body1, body2)) { return(false); } bool body1IsSpecialSensor = body1._specialSensor != BodySpecialSensor.None; bool body2IsSpecialSensor = body2._specialSensor != BodySpecialSensor.None; if (body1IsSpecialSensor || body2IsSpecialSensor) { if (body1IsSpecialSensor) { int body2Layer = 1 << physicsManager.GetBodyLayer(body2); if ((body1.SpecialSensorMask & body2Layer) != body2Layer) { return(false); } } else { int body1Layer = 1 << physicsManager.GetBodyLayer(body1); if ((body2.SpecialSensorMask & body1Layer) != body1Layer) { return(false); } } return(true); } if (body1.IsStatic && body2.IsStatic) { return(false); } bool anyBodyColliderOnly = fixtureA.IsSensor || fixtureB.IsSensor; if (!anyBodyColliderOnly) { if (body1.IsKinematic && body2.IsKinematic || (body1.IsKinematic && body2.IsStatic) || (body2.IsKinematic && body1.IsStatic)) { return(false); } } return(true); }