VincentLagerros / RealTimeTerrainEdit

YEET
MIT License
7 stars 0 forks source link

Problem with terrain altering on borders #1

Open renegadeandy opened 4 years ago

renegadeandy commented 4 years ago

Hi! I have some questions around this project -- not this version you have in Github but the version you shared with others here : https://drive.google.com/drive/folders/1t28wldbP_nkK5qRB9NOzSZMk7RtrONLK?usp=sharing

Can you help me out? I have added you on facebook in the hope we can have a chat about what I see?

The problem seems to stem whenever I click on a border chunk in a 3x3x3 set of chunks.

This bit of code appears to cause the issue :

 if (addChunks.Count > 0)
                {
                    for (int i = 0; i < addChunks.Count; i++)
                    {
                        GameObject g;
                        if ((g = GameObject.Find(mainHolder.GetNameFromCoord(addChunks[i]))) == null)
                        {
                            mainHolder.AddChuck(addChunks[i]);
                        }
                        else
                        {
                            Debug.Log("HOT RELOAD");
                            mainHolder.HotReloadChunk(addChunks[i], g.GetComponent<MeshChunk>());
                        }
                    }

                }

We check if the Chunk == null, and if it is, we add it to the main holder, which then causes a nullreferenceexception?

VincentLagerros commented 4 years ago

it fails because when adding/removing to a chuck, that chuck updates all surrounding chuncks also. This is to minimize the border issues. To be honest this project was more of a proof of concept, I never really did anything with it. There was so many issues with chuck borders and I figured that I would only use it on an infinite world so I never fixed the Fixed Map Size. If you really want to use this project I could probably recode it to work more fluently, but it will probs take some time.

renegadeandy commented 4 years ago

Hi @VincentLagerros Thank you so much for replying! There are parts of the code I just don't understand, and to be honest I don't need infinite terrain, but it can be used nicely with my desired approach.

If you consider rewriting it could you also comment what is happening in the areas of the code, as I am having a difficult time understanding how it works and why things are the way they are. It is worthwhile saying that the game type I want to make is where I can 'dig' with a 'spade' into my environment but it would be unlikely that it would be used for anything as elaborate as creating huge spikes or tunnels and bridges.

I also want a way to 'dig' a certain amount of 'terrain', and them move that 'earth' to another point on the map, literally as if i was digging a hole. Ultimately that it is where I am heading. Needing to be able to use the borders is quite important to me as I envision using a fixed map size(currently 3 x 3 x 3) and it is a fairly flat plane it creates using the various noise parameters. I would love to watch as you try to recode it? Maybe you could stream your process?

VincentLagerros commented 4 years ago

@renegadeandy you can just use https://github.com/Eldemarkki/Marching-Cubes-Terrain instead, it looks like they have a way better system then mine

SpecificOcean commented 1 year ago

I know this is old, but I believe that solution wont work for my needs as I believe it is more cpu dependent than gpu. Do you know if theres a similar project with an active development community?