1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

Cave support

Discussion in 'Source Code' started by fourthquantum, Apr 11, 2016.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. fourthquantum

    fourthquantum Senior Engineer

    Messages:
    1,286
    I might be a bit naive and ignorant on this but would it be hard to add an algorithm that adds a cave system when planets are generated and explored?
     
    • Agree Agree x 1
  2. Mix-martes86

    Mix-martes86 Senior Engineer

    Messages:
    1,110
    Thinking about it, there's a few approaches to this that come to mind:

    - Add it in the planetary maps. Might be viable, by adding a new distinction within the color layers, but the plan could be thwarted because it'd be hard to have the pixels in the maps represent accurately the cave structures, so many things may have to be statically defined (always the same for all caves).
    - Generate randomly at runtime. Possible to do, but like we saw with the initial iterations of the planets (when they were 100% random, like asteroids), the results may not be aesthetically pleasing.
    - Add pre-generated caves at runtime. A variant of how planets are predefined, caves would be made the same way, and then randomly inserted into the planets, the only problem being in determining where to put the cave's entrance. In my opinion, probably the most viable option.
     
    • Like Like x 1
  3. fourthquantum

    fourthquantum Senior Engineer

    Messages:
    1,286
    I'm not too concerned about cave entrances but it would be cool to come across one that has a pack of spiders living there, perhaps a queen spider thingy could live in there as well. I think it would add a whole new dynamic to finding minerals, building bases and exploration especially if exploration spaces contain 'things' that you can't make.
     
    • Agree Agree x 1
  4. Mix-martes86

    Mix-martes86 Senior Engineer

    Messages:
    1,110
    As in "it's ok if there's no entrance"? Like, stumbling upon caves just by doing regular mining? If so, that'd make things a bit easier, as you'd only have to consider at which depth to place the caves and how to fill them with stuff or make it have materials similar to the surrounding areas. The planet generator would still have to be modified some, but it may be doable that way. However, it brings the question of how much would you have to mine to actually find one of these caves.
     
    • Agree Agree x 1
  5. mexmer

    mexmer Senior Engineer

    Messages:
    1,977
    this was already happening with procedural generated asteroids, tho' they toned that somewhat down. but even start asteroid (in easy start) had caves.
    planets are prefabs tho', due quite long creation time, when they were proceduraly generated (in first few versions after planet release).
    so i can't actually tell, how "hard" it will be to add caves to already premade planet.
     
  6. Mix-martes86

    Mix-martes86 Senior Engineer

    Messages:
    1,110
    Yes, but they are hollow prefabs with zoned materials, so technically one coud paste a prefab asteroid below the surface and have the effect of a cave (in the parts of the asteroid where there's no materials) because no conflicting structures have been instanced yet.
    That said, I don't know how would that be organized so that the pasted structure is considered/stored as part of the planet in which you have spawned the structure.
     
  7. shimonu

    shimonu Apprentice Engineer

    Messages:
    396
    Donut shaped caves comes to mind :)
     
    • Funny Funny x 1
  8. Aeronaut

    Aeronaut Trainee Engineer

    Messages:
    18
  9. fourthquantum

    fourthquantum Senior Engineer

    Messages:
    1,286
    That would be a pretty cool addition to the game.
     
  10. M4ck

    M4ck Trainee Engineer

    Messages:
    74
    Now I'm not familiar with the way that planets+asteroids (rocks, predefined structures etc.) interact or if it is even possible to "check" whether they overlap on certain voxels, but what about this approach:

    1. Planets will have a kind of gradient of how likely a cave is to appear in given area - like more likely in the mountains, rare under lakes or in grasslands, very common near cliffs. This chance should be rather low, due to the next point.
    2. Each time a player digs more than, say, 100m deep, a roll is made to check if a cave should be generated - unless the area has been previously flagged not to generate caves.
    3. If the roll succeeds, a cave will be generated there (see next points). Either way, a chunk of a specific size (say, 500x500x500 m) is flagged as "already rolled, don't do this again". I'm pretty sure the ground is already split into some sections - it likes to glitch in and out sometimes, in large rectangular pieces - so we could use these.
    4. A large, pre-defined, or procedural, asteroid-like shape is spawned such that the whole bounding box is below the player.
    5. Overlapping voxels of planet and asteroid are removed and the asteroid is completely deleted as to not waste ram/cpu/save size.
    6. A "ping" goes off from a drill/ore detector/something to notify the player that an unusual underground formation has been found nearby.

    It wouldn't take very long, I guess, as spawning even a massive procedural asteroid only takes a few seconds. It should be pretty light on save sizes and cpu/gpu/ram load, as there wouldn't be any caves generated and computed all the time all over the planet, unless they were already found by the player.

    We also wouldn't get strange issues like in Minecraft where caves sometimes "crawl" to the surface and result in some pretty messed up terrain near entrances, as it all would be happening deep enough that only cliffs would sometimes get cave entrances generated after roaming the area previously. Step 3 should be enough to prevent caves "growing" around places where the player has already been (so your underground base won't be suddenly hanging mid-air if you go drilling nearby) and you wouldn't randomly fall to your doom due to the whole bounding box being lower than you are at the time.

    You could also change it slightly as in to make flagged chunks small enough that caves can overlap nearby chunks slightly - if a chunk nearby has been flagged as visited, no cave - nothing happens, but if a chunk next to one that is generating a cave right now is not flagged, another roll is made to maybe expand the cave to nearby chunk. This could be messy, but caves would be much more spacious and branched, and not so similar in sizes/overal shape.

    If something is not clear, ask me and I'll try to explain my idea better.
     
    • Like Like x 1
  11. gornyakmaniac

    gornyakmaniac Apprentice Engineer

    Messages:
    186
    Cave systems on planets would be fine addition to the game. I don't know how hard it will be to process data, but it shouldn't be hard for sure to add one or two height maps with some flags and some additional rules for subsurface materials generation (because algorythms for surface generation using rules already exist in game).

    Players on my server regulary asking me: can they build bases in digged? And for now I can't say them "yes" because of three reasons:
    1) If smb digs a cave for base, he will exactly dig extra unnecessary holes. This holes will create extra difficulties for player and will prevent to fit player's base in landscape beautiful enough. And ships crashed near this base makes some extra holes too.
    2) There is no endless RAM on DS machine and on client's machine to keep and process very large voxel maps.
    3) Ores on planet aren't endless.

    But If cave system will exist - it will solve all of these problems + add some exploration elements in game.
     
    Last edited: Sep 27, 2016
  12. Foogs

    Foogs Apprentice Engineer

    Messages:
    123
  13. Devon_v

    Devon_v Senior Engineer

    Messages:
    1,602
    Down.

    Caves are down.
     
  14. gornyakmaniac

    gornyakmaniac Apprentice Engineer

    Messages:
    186
    Stand-up comedian in thread
     
Thread Status:
This last post in this thread was made more than 31 days old.