Marching Cubes algorithm acting slow

I have finally finished a working, functioning marching cubes algorithm. I have my character, and I can dig holes into the “terrain” of the marching cubes mesh. (simaler to minecraft). The problem is, each time I click the mouse to “dig”, the game lags for up to 2 seconds. I went online and found other peoples videos using marching cubes, and they are adjusting the mesh rapidly without any lag.

For example:

Does anyone who is experienced with meshes or marching cubes know any of reasons why adjusting a mesh causes so much lag? How did they do it in the video so quickly? My ultimate goal is to be able to edit the “terrain” in real time just like the video.

Firstly, you need to be splitting your mesh up into chunks, that video looks like its all one mesh, but it will be split into chunks so that the mesh updates will only occur on specific chunks. This chunk system is your vital goal towards creating a workable playable game. Another thing you must do is optimize your mesh code as much as possible, remove any un necessary code from the mesh update function because I can tell you this, it WILL slow your performance down a lot.

Chunks can be done easily, I did it in my Voxel Engine which I am working on, It is done through having a controller object that instantiates the area of chunks with empty data and then fills them with procedural data which is split along the chunks. It is quite a pain to do but it is well worth it for the performance gain you get.

OK, after 10 days, I finally figured out whats wrong. it simply involved optimizing my code for efficiency.