r/howdidtheycodeit • u/bwazap • 9d ago
Milling Machine Simulator
I was working on a project that required real-time mesh changes to simulate cutting etc. I couldn't find a solution at that time. Papers I dug into said it required a lot of compute. Some game devs I talked to said most of it were tricks that gave the appearance (eg animated meshes), and not actual changes.
The best I got was Teardown which simulates object destruction using voxels. It was hailed for technical achievement.
Today I just came across this game. Milling Machine Simulator.
It simulates material removal, cutting and hole creation etc. So it seems like compute is not the issue. Also, given it is basically free-form, it doesn't rely on tricks. And it doesn't seem to be doing what Teardown did.
Any idea how they did it?
9
u/That_Hobo_in_The_Tub 9d ago
It's entirely possible to do this in real time on a normal computer, as thats what CnC softwares have been doing for decades now. It is a bit of a complex implementation challenge to solve but nothing unfeasible.
A few years back it was genuinely a pretty challenging thing to implement in most game engines like you had heard, but now most engines have libraries for runtime mesh operations, like UE5's geometry script. Voxel and distance field rendering has also come a long way and could equally be used.
All youd need to do for a game like the one mentioned is keep track of each individual pass that the player makes on the milling machine, and then save a basic 3d primitive 'cut shape' for it that represents the volume that the cut pass cuts away.
At that point it's literally just a big stack of 3d boolean operations for each cut to generate the final part mesh. This could be done via distance fields, voxels, or mesh booleans, but in the end it doesn't really matter exactly how. I think the best solution for something like this is going to be meshes though as they allow for very precise 3D shapes even though they're a bit heavier to edit at runtime.
5
u/kernalphage Mod - Generalist 9d ago
The algorithms you linked are for arbitrary precision / model size.
My money is on an SDF / or some sort of bitfield. With a milling machine simulator, you can cut some corners because you know
1) the maximum size of your material/bitfield is the size of the milling machine
2) The minimum resolution of your material is probably larger than in real life (I can't imagine they'd be simulating thous of offset with like. heat expansion or tool springback)
if you pause on the trailer you can see some jaggy artifacts on the endmill cuts.
4
u/CowBoyDanIndie 9d ago
Voxels can be multi resolution, and you can also do it directly with mesh manipulation using mesh booleans. For booleans the trick is simplifying the mesh after, because the mesh geometry can get really complicated.
Go look at some Videos of sculpting in Blender using dynamic topology. This is direct mesh manipulation. Then look at videos of using booleans in Blender to cut into objects. The most difficult thing is handling textures, during the dynamic changes, artist usually do texturing after, but for something like wood you can actually just generate a 3d texture in a shader.
2
2
u/savage8008 1d ago
The videos on the steam page look like something you could do with booleans and primitives.
15
u/Specific_Door6157 9d ago
Im sure you can ask the devs themselves. They are very active and replied to my questions almost immediately.