Help with surface net implementation

Godot Version

4.4.1

Question

Hi, I was hoping to get some assistance/code review style feedback for my surface nets implementation. My plan was to implement surface nets in GDScript first and then once I had that working move it to either C++ or compute shaders to make it fast enough to run in real time. But as it turns out my implementation has holes in it (literally).

I’ve mainly been using this blog as a guide for implementing them, but their actual implementation is in rust which I don’t really understand.

If anyone feels like helping out I would really appreciate it, I’ve been staring at the code a while now changing parts I think could be causing it but none of it has had much effect. The code can be found here

There is a debugging drawing addon can can be toggled on and off in the TerrainChunk settings in the test scene, I only have the Windows binaries included to save space so if you are on a different platform and want to use the debug drawing add you will have to redownload it from the AssetLib.