Skip to content

Convex hull produces invalid topology #311

@werner291

Description

@werner291

Hi there,

I put this in the Discord too, but just for good measure I'll open an issue too.

It appears that ConvexPolyhedron::from_convex_hull(&points) produces invalid topology:

use std::fs::File;
use parry3d::na::Point3;
use parry3d::shape::{ConvexPolyhedron, TriMeshFlags};

fn main() {
    let decoded: Vec<f32> = bincode::deserialize_from(File::open("points.bin").unwrap()).unwrap();

    let points : Vec<Point3<f32>> = decoded.chunks(3).map(|c| Point3::new(c[0], c[1], c[2])).collect();

    let convex = ConvexPolyhedron::from_convex_hull(&points)
        .expect("Failed to compute convex hull of mesh");

    let (vertices, mut indices) = convex.to_trimesh();

    let mut convex_mesh = parry3d::shape::TriMesh::new(vertices, indices)
        .expect("Failed to convert convex polyhedron to triangle mesh");

    // This panics.
    convex_mesh.set_flags(TriMeshFlags::HALF_EDGE_TOPOLOGY).unwrap()
}

Here's the input data (remove the .txt, GitHub refused to upload it otherwise)

points.bin.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions