Skip to content

Contact reporting may panic in assert #718

Description

@Ughuuu

In specific case where the contact is reported with same ID, there will be a panic that occurs:

Here you have an example that reproduces this: appsinacup/godot-rapier-physics#195

Issue happens here:

src/geometry/broad_phase_multi_sap/sap_utils.rs

pub(crate) fn sort2(a: u32, b: u32) -> (u32, u32) {
    assert_ne!(a, b);

    if a < b {
        (a, b)
    } else {
        (b, a)
    }
}

In my case a is 7 and b is 7.

This function is called from:

src/geometry/broad_phase_multi_sap/sap_axis.rs

Possibly best is to change calling function of this (eg. batch_insert or update_endpoints) to not insert or sort if the proxies are equal. If we do allow equal proxies, that will introduce issues down the line (there are other asserts that will fail).

There is already such an if in one of the 3 places where this function is used, eg.:

In batch_insert:

if endpoint2.proxy() == endpoint.proxy() {
    continue;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions