Or even coded in C++ instead of GDScript to accelerate its execution. On the bright side, the new algorithm generates 10 times less polygons and collision shapes which will greatly improve the overall performance.
So in the end that's a win I guess.
I improved the terrain destruction system. Especially the way to dig holes in polygons was entirely rewritten.
The former algorithm generates too many collision shapes while the new one keep this number to the minimum required.
2x slower for 10x less shapes.
I did a performance benchmark of the new one compared to the old one. The new one is 2 times slower and takes around 1 frame to complete at 60fps which could argue that's a lot. But fortunatly, players won't spam it and it could always be improved further.
The simulation capabilities are greatly improved. There are still well hidden bugs to fix but the big next step is write a better code for the leaking system, especially the water jet particles.
Leaking water shapes can now merge together. And, to showcase the rewritten splitting system I faked a water level decrease when water stops pouring.
Next step will be to manage a split while water is leaking.
After a few tries and fails with water particles I finally found a convincing water jet simulation code. More CPU friendly than simulating every particle individually and yet visually good. The basic implementation doesn't like terrain modification though.
What about a better terrain for this cave ? Generated from Perlin noise. Even better with holes inside the polygon, because why not ? Any good terrain can be dug, here you are.