Skip to content

Conversation

@Oleg4260
Copy link
Contributor

@Oleg4260 Oleg4260 commented Apr 26, 2025

Some technical changes:

  • Removed precalculation of ground levels for terrain mode, taking it directly from the ground object, because it didn't really improve performance and it took extra memory.
  • Unified code for both terrain and flat modes by removing if ground.elevation_enabled {...} else {...} so the code is simpler, both modes share the same code now and ground is generated the same way in both modes, also fillground works for the flat mode, which can be useful in the future.
  • Removed the spawn platform, it isn't really needed, the player always spawns on solid surface
  • Always generate bedrock at MIN_Y
  • Refactored the check_for_block() function, because the whitelist and blacklist worked basically the same, both returned true, and it would be hard to process whitelist for true and blacklist for false at the same time, so leaving just whitelist for simplicity

Suggestion: I think default ground_level should be changed from -62 to -61 and the region.template should be changed to generate a normal superflat world, with 1 grass, 2 dirt, 1 bedrock to match the new generation. There was a discussion in #384 about that file, but I still don't know how to change it, so @louis-e please do this if you agree with my idea

Improvements to generation:

  • Added dead bush to sand regions
  • Added surface types for beaches
  • Implement generation of plants in grassland, scrub, heath and orchard

Todo:

  • Implement tree types
  • Implement better generation of wetlands

@louis-e
Copy link
Owner

louis-e commented Apr 26, 2025

Thanks for the PR! Just a few minor notes from me.

Is there any particular reason for the bedrock at MIN_Y? I guess this is a similar discussion like for the second dirt layer hahha. I just think that this will increase the generation speed unnecessarily with something that most users won't even see in this case. I'd love to hear your opinion about this.


Removed precalculation of ground levels for terrain mode, taking it directly from the ground object, because it didn't really improve performance and it took extra memory.

Were you able to check the generation speed before / after with different map sizes? I don't know the exact numbers but I recall that it actually helped a lot back then. Might also be outdated by now, just making sure :)


the region.template should be changed to generate a normal superflat world

I will check that!

@Oleg4260
Copy link
Contributor Author

Oleg4260 commented Apr 26, 2025

Hello, thanks for your feedback.

  1. No, there isn't an actual important reason for that, I just think there should be a layer of indestructible block in the lowest lever to prevent holes, like for example sometimes people like to explode the map, haha, also with this the flat generation matches the regular superflat world format, that's why I want you to change the default world generation. You can move that line back to if args.fillground {} if you want, but I think the performance difference isn't significant.

  2. I did check generation speed before and after, after my changes it actually became a little slower, but it's probably because of the bedrock layer, also before my changes it would take some time to process the ground heights before the ground generation started, I guess it's the same amount of time now, but as a part of the ground generation time. In both cases the function is called the same number of times, just at a different moment, so there's no real performance difference. Also the main reason I did this is because I wanted the ground to be generated by the same code in both states of args.terrain.

@Oleg4260
Copy link
Contributor Author

After getting some sleep I found out that there's still a way to pre-calculate ground levels, checking right now if it's faster than without it
image

@Oleg4260
Copy link
Contributor Author

Oleg4260 commented Apr 27, 2025

Here are the results:

Bbox: 49.383714 15.605736 49.430403 15.689163 (31.3 km²)

With precalculation:
Terrain on: 1:24
Terrain off: 0:14

No precalculation:
Terrain on: 1:28
Terrain off: 0:13

As we can see, it's nearly the same, so that's why I think we don't really have to pre-calculate ground levels. Also I noticed that with pre-calculation it takes about 20s longer to compile Arnis

@Oleg4260 Oleg4260 marked this pull request as draft April 27, 2025 12:50
@Oleg4260
Copy link
Contributor Author

Oleg4260 commented Apr 27, 2025

I am going to add some improvements to generation of some natural surfaces, so drafting this temporarily

@Oleg4260 Oleg4260 marked this pull request as ready for review April 27, 2025 14:23
@Oleg4260 Oleg4260 marked this pull request as draft April 27, 2025 14:53
@Oleg4260 Oleg4260 changed the title Optimize ground generation Optimize ground generation + new natural elements Apr 27, 2025
@Oleg4260
Copy link
Contributor Author

Oleg4260 commented Apr 27, 2025

Added generation of dead bush in natural:sand, this is how some random desert in Libya looks like
I am currently working on generation of some nice grasslands, scrubs, woods, then I will implement generation of wetlands, like marshes, bogs etc.
I don't have much of free time now, so I will continue later
2025-04-27_17 51 39

@Oleg4260
Copy link
Contributor Author

Final version of natural:scrub is below. Didn't want to make it more complicated, since this isn't a very significant element
2025-04-27_21 20 08
2025-04-27_21 35 08

@Oleg4260
Copy link
Contributor Author

An orchard.
2025-04-27_22 07 27
2025-04-27_22 07 36

@Oleg4260 Oleg4260 marked this pull request as ready for review April 27, 2025 20:09
@louis-e
Copy link
Owner

louis-e commented Apr 27, 2025

Very cool, thanks a lot! I'm always happy about visual enhancements :)
Just so you know, I might change the bedrock layer again in the future - maybe by aligning it directly with the elevation level instead of at a fixed Y coordinate.

@louis-e louis-e merged commit f1d3c0b into louis-e:main Apr 27, 2025
3 checks passed
@Oleg4260
Copy link
Contributor Author

Oleg4260 commented Apr 27, 2025

maybe by aligning it directly with the elevation level instead of at a fixed Y coordinate.

If you mean that bedrock might be higher than -64 in the future, I don't think it's a good idea. I am trying to make the generated map be as close as possible to a normal minecraft world. while also keeping it realistic and corresponding to the OSM data. There are suggestions like #350, and I really like the idea of making it possible to survive on a generated map, so I'm slowly moving towards adding an option of generating resources, and that's why everything between the ground level and -64 has to be filled with stone, only with bedrock being at the lowest level

P.S. We also might add some underground structures in the future, like subway tunnels, that's another reason why we need some space under the ground

@Oleg4260
Copy link
Contributor Author

@louis-e just a ping to be sure that you are aware of my reply

@louis-e
Copy link
Owner

louis-e commented Apr 27, 2025

Alright, then let's keep it as it is for now - I also really need to get some sleep now haha!
Also I'm really looking forward to the underground structures. I really want to have them included as well at some point!

@Oleg4260 Oleg4260 mentioned this pull request Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants