Skip to content

A bug in Path Extrusion  #128

@Crash22191

Description

@Crash22191

I'm not very high level in math and not sure what the proper fix should be, but in Path+Shapes.swift extrusionContours there is a check for point count being bigger than 1, while later on in tries to access points[2] which fails if the count is 2 and it was causing crashes on my end. I changed the count check to 2 which fixed it, but again not sure if it's a correct solution here.

...
        let count = points.count
        guard count > 1 else {
            return [translated(by: p0.position)]
        }
...
        if along.isClosed  {
            for i in 1 ..< count {
                addShape(points[(i < count - 1) ? i + 1 : 1])
            }
            addShape(points[2])
            shape = shapes.last!
            shapes[shapes.count - 1] = shapes[0]
        } else {
            addShape(p0, nil)
            for point in points.dropFirst(2) {
                addShape(point)
            }
            let last2 = points.suffix(2).map { $0.position }
            twistShape(last2[1] - last2[0])
            addShape(points.last!, nil)
            shape = shapes.last!
        }
        

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions