-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor tree and flora generation for improved extensibility #1562
Conversation
The filter depends on the order of chunk generation. It cannot filter trees in a deterministic manner.
It is great to see this get an overhaul with more strategy. Looking forward to giving this a closer look! |
Vector3i pos = new Vector3i(ChunkConstants.SIZE_X / 2, 0, ChunkConstants.SIZE_Z / 2); | ||
|
||
Vector3i min = new Vector3i(pos); | ||
Vector3i max = new Vector3i(pos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these two be final since they are used in an inner class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup this gets me a compile error :-)
Works fine when final is added.
I've commented on some lines for on-spot review. Besides these minor points all looks good, trees are generated as expected, and I couldn't find any cut-off trees. I suggest to change the tree probabilities to have birches in plains and pines in snowy biomes. Furthermore, I'd like to see birches be added to the forest biome as well. |
Not home yet to check it out but am curious if this also fixes tree gen in TTA? Guess I'll know soon :-) |
FloraFacet facet = chunkRegion.getFacet(FloraFacet.class); | ||
Block air = BlockManager.getAir(); | ||
|
||
Random rng = new FastRandom(chunk.getPosition().hashCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause the flora to be not deterministic anymore if the size of the facet changes. I don't think it really matters in this case. But just saying it out loud.
Nice abstraction over these classes, msteiger. All generated well for me. |
Tested out here as well, looks good (after the quick final fix) :-) Doesn't fix trees in TTA so I take it something extra has to be applied to world gen there #1536 is listed as a requirement in one of the commits, and @emanuele3d has partially addressed it, but is more stuff needed? engine-tests ran 100% success, but the 5 tests in TreeTests failed in both IntelliJ and via plain Gradle :-(
|
Thanks @ALL for the reviews. The following changes were made:
Yes, @Cervator, TtA has its own tree generators (in GrowingFlora I believe). They are not affected. |
Vector3i pos = entry.getKey(); | ||
TreeGenerator treeGen = entry.getValue(); | ||
int seed = relativeToWorld(facet, pos).hashCode(); | ||
Random random = new FastRandom(seed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need similar love to how you handled the flora generation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks similar, but the seed value is generated per world location and independent from the iteration order and chunk/facet. At least unless I'm overlooking something here ..
Retested and all looked well :-) @MarcinSc - would this be helpful toward fixing up tree gen in TTA? Or if you're low on time would it help if somebody else gave it a shot? I think you said you were working on trees some time back, am unsure if you have any pending code? |
This PR fixes a few things such as cut-off trees and different generation probabilites for biomes.
Its main focus is the refactoring of tree and flora generation so that modules can extend it. The new SurfaceObjectProvider is the base class of DefaultFloraProvider and DefaultTreeProvider.
Modules can write similar classes to map growth probabilites to biome (or other variables) and add filters such as flatness or UI-based config.
Tree generators are moved to a static class to enable re-use.
Plants have been renamed to "Flora" to be consistent with content and split into 3 groups: Grass, Flowers and Mushrooms. This allows for putting more mushrooms in the forest and more grass on plains.
Also, a unit test (requires #1536 and #1542) estimates maximum tree extents to correctly adjust facet borders. Commit 38b85e9 removes the workaround and requires the verticalChunkMeshSegments variable to be removed from ChunkImpl.