Skip to content

Polyline-Polyline intersection fails since 0.22 #376

@s-nie

Description

@s-nie

The following code started failing with the 0.22 release. It seems that polyline intersections are not detected reliably anymore.

use parry2d_f64::{
    math::{Isometry, Point},
    query::contact,
    shape::Polyline,
};

fn main() {
    // Large closed rectangle
    let vertices = [
        [-5.0, 20.0],
        [-45.0, 20.0],
        [-45.0, -20.0],
        [-5.0, -20.0],
        [-5.0, 20.0],
    ];
    let line1 = Polyline::new(vertices.into_iter().map(Point::from).collect(), None);

    // Small closed rectangle
    let line2 = Polyline::new(
        [
            [-1.0, -1.0],
            [4.0, -1.0],
            [4.0, 1.0],
            [-1.0, 1.0],
            [-1.0, -1.0],
        ]
        .into_iter()
        .map(Point::from)
        .collect(),
        None,
    );

    let result = contact(
        &Isometry::default(),
        &line1,
        // On the large rectangle
        &Isometry::new([-25.0, -20.0].into(), -1.57),
        &line2,
        0.0,
    );

    // Fails since 0.22.0
    assert!(result.is_ok_and(|c| c.is_some()));
}

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