Javier-Garzo / Marching-cubes-on-Unity-3D

Terrain voxel engine with the use of Marching Cubes implemented in Unity 2020.3.17f1 (LTS).
MIT License
332 stars 43 forks source link

Chunks are saved even when SAVE_GENERATED_CHUNKS is false. #8

Closed ghost closed 2 years ago

ghost commented 2 years ago

First off, imo this is one of the best unity marching cubes repos that exists. It's just so damn good.

I was playing around with the FPS scene digging craters and making hills, and the edits I made stay afterwards, even if I close the editor and come back. if the seed is changed, it still keeps that chunk and it leads to that specific memorized chunk having huge holes where the neighbors are supposed to connect and it just doesnt match the surrounding chunks at all.

I read the repo and it said saved files will show up in Application.persistentDataPath+"/chunks". no chunks folder exists. I assume this is due to Save_generated_chunks being false. however, instead there's a worlds folder containing a default folder which has reg files. Im not really sure why this is, or how to make it stop.

Is this intentional? Is there a way to tell it to clear those reg files on playmode exit? Or, at the very least, is there a way to have it only load reg files with the same seed?

Again, this system is great and I thank you for it. So much hard work obviously went into this.

Javier-Garzo commented 2 years ago

First, thanks for the supportive comments, that mean a lot for me.

About the seed change problem with the old chunks, that's the old working system where you need to remove old chunks by hand in the directory Application.persistentDataPath+"/worlds/default" (the chunk of a world is saved in: worlds->[world name]). You haven't found the "/chunks" folder because that was old dir that I changed to the explained one when I created the worldManager. You can use the WorldManager prefab inspector button to get fast access to the "/world" folder:

image

That was a bad user interaction so I create a new constant AUTO_CLEAR_WHEN_NOISE_CHANGE (default set true) and improve the save system to support the save of the noise parameters. The new system remove old chunks if detecte that NoiseManager.worldConfig (noise parameters) change from the previous save one, so you don't have that problem any more. Also, if you use the 0 seed value, you always generate a new world and delete the old chunks.

Remember that if WorldManager exist in the scene this two previous interactions not work, so I suppose that you are trying load world to play and not for testing. With a WorldManager in the Scene you always load the previous chunks and the NoiseManager.worldConfig from the world file to the current NoiseManager.

Try the new implementation, I expect that the new system meets your needs. Feel free ask other doubts or talk about improvements.