Composite Lumber
Despite having a functioning cutting system, I couldn’t rest until the plank was a proper dynamic mesh! This is definitely not the most pressing issue (that honor goes to the whole is-this-prototype-any-fun portion of the prototype) - but I couldn’t stop thinking about how to implement the mesh. So I decided to get it out of the way first.
Turns out the mesh generation is a little more complicated than anticipated! My original plan was to generate the border shape, from which I could use any number of methods to turn into a series of triangles (Like Ear Clipping or Dulaunay Triangulation). Finding the border of a single shape was relatively simple. The complexity arose as soon as shapes had internal holes.
Here, my algorithms started to get hung up and crossing paths. After discovering some odd edge cases in my original fill algorithm, I rewrote it using the Scanline Flood Fill. This provided the benefit of discovering the edges of a shape during the flood step. With a few changes I had the fill “stamp” edges to make building the shape loops easier. What this doesn’t account for, however, is single pixel rows. Suddenly loops are sharing data and crossing streams, often resulting in infinite loops. An inner shape “jumps tracks” to the outer shape and never looks back.
After several attempts to correct the behavior, I instead took a step back and thought of a simpler solution. Rather than build a shape, I’m turning pixels into quads. To reduce the number of quads generated, some optimizations are in place - like expanding in width or height. There’s still plenty of optimizations to make, but good enough for a prototype.
Beyond that I also added in some “smoothing” triangles to make the cuts look less like a grid and more like an actual piece of wood. This algorithm analyzes edges and builds triangles over n number of blank spaces. Once again there’s a lot of optimizations to make, but much better than before.
The result is kind of mesmerizing (Often the outcome of dynamic meshes). It’s pretty wild to see the logic get carried out frame by frame like magic. And even though this step wasn’t entirely necessary, it makes a pretty substantial difference to actually see through the holes you’re cutting.















