Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bad triangle panic with variable line width #821

Closed
luiswirth opened this issue Sep 2, 2022 · 2 comments · Fixed by #822
Closed

bad triangle panic with variable line width #821

luiswirth opened this issue Sep 2, 2022 · 2 comments · Fixed by #822

Comments

@luiswirth
Copy link
Contributor

This is probably still #819, but in combination with an attribute to support variable line width.
This wasn't fixed by #820

use lyon::{
    geom::point,
    lyon_tessellation::{geometry_builder::simple_builder, StrokeOptions},
    path::{LineCap, Path},
    tessellation::{StrokeTessellator, VertexBuffers},
};

const DEFAULT_STROKE_WIDTH: f32 = 1.0;
const STROKE_WIDTH_ATTRIBUTE: lyon::path::AttributeIndex = 0;

fn path() -> Path {
    let mut path = Path::builder_with_attributes(1);
    path.begin(point(-45.192276, -69.800575), &[DEFAULT_STROKE_WIDTH]);
    path.line_to(point(-45.164116, -69.84931), &[DEFAULT_STROKE_WIDTH]);
    path.line_to(point(-45.135952, -69.90564), &[DEFAULT_STROKE_WIDTH]);
    path.line_to(point(-45.10779, -69.93248), &[DEFAULT_STROKE_WIDTH]);
    path.line_to(point(-45.052788, -69.96064), &[DEFAULT_STROKE_WIDTH]);
    path.line_to(point(-45.026604, -69.898155), &[DEFAULT_STROKE_WIDTH]);

    path.end(false);
    path.build()
}

fn main() {
    let mut stroker = StrokeTessellator::new();

    let options = StrokeOptions::default()
        .with_tolerance(0.001)
        .with_line_cap(LineCap::Round)
        .with_variable_line_width(STROKE_WIDTH_ATTRIBUTE);

    let path = path();
    let mut mesh = VertexBuffers::new();
    let mut builder = simple_builder(&mut mesh);
    stroker
        .tessellate_path(&path, &options, &mut builder)
        .unwrap();
}

panics with

bad triangle VertexId(4) VertexId(7) VertexId(7)
thread 'main' panicked at 'assertion failed: b != c', /home/luis/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/lyon_tessellation-1.0.3/src/geometry_builder.rs:461:9
@nical
Copy link
Owner

nical commented Sep 2, 2022

That's a different issue. The other one was producing invalid vertex ids due to some computation being skipped, while this one has triangles with the same vertex twice which should not happen.

Thanks for filing this and double thanks for the reduced test case, I'll look into it soon.

@luiswirth
Copy link
Contributor Author

Thanks 👍🏾 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants