briansemrau / godot_box2d

A C++ module that integrates the Box2D library with the Godot game engine by providing nodes for standard Box2D objects.
MIT License
44 stars 4 forks source link

Collision group_index overrides explicit collision exceptions #42

Closed briansemrau closed 3 years ago

briansemrau commented 3 years ago

I noticed this issue while working on code changes.

Code snippet pulled from box2d_world.cpp :

bool Box2DWorld::ShouldCollide(b2Fixture *fixtureA, b2Fixture *fixtureB) {
    ...
    if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0) {
        return filterA.groupIndex > 0; // TODO fix this. Group index should not override explicit exclusions, calculated below.
    }
    ...
    // Check for fixture exclusions
    ...
}

The group_index calculation should only return if it's returning false.

Under the current behavior, if it returns true then body/fixture collision exclusions won't be able to disable collisions.

This will be fixed alongside my changes for #9

jordo commented 3 years ago

ah yes, nice catch.