EliCDavis / polyform

Immutable mesh processing library
https://elicdavis.gitbook.io/polyform/
MIT License
79 stars 6 forks source link

feature: Add flag to optionally turn cylinder primitive into pipe #35

Closed alexykot closed 3 months ago

alexykot commented 3 months ago

I needed to make a cylinder with one side open, optimizing for minimal triangles in this mesh, as I have a lot of copies of it in my resulting model. So I've added flags into the primitives.Cylinder to optionally not generate top and/or bottom of the cylinder and skip those triangles.

Flags are set to positive by default, so preserve current behavior of the existing code.

I didn't try to optimise local allocations to not create the corresponding meshes at all. This only prevents including them into resulting mesh. I can do that easily if it's worth it.

alexykot commented 3 months ago

I thought of adding another dedicated Pipe primitive, but they will be nearly identical, so a flag seems more fitting.

EliCDavis commented 3 months ago

Looks good to me!