Skip to content
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

Glitched Trees #139

Open
Dip98 opened this issue Oct 29, 2024 · 7 comments
Open

Glitched Trees #139

Dip98 opened this issue Oct 29, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@Dip98
Copy link

Dip98 commented Oct 29, 2024

Occasionally after I've been playing on a world for a decent amount of time, I'll randomly come across a tree that is missing all its leaves on one side. If I save the world and re-enter, the leaves re-appear, this isn't a game breaking bug or anything, its just kinda annoying lol.
Photo:
Minekhan Glitch 2

@Dip98
Copy link
Author

Dip98 commented Oct 29, 2024

As you can see the lighting is messed up too, proof that it wasn't just me faking this lol

@EliasElliotson
Copy link

I wonder (and it's just a guess) if the tree was generated on the edge of a chunk. That might cause it to only show part of the tree.

@Shawnlandis
Copy link

Shawnlandis commented Nov 1, 2024 via email

@Dip98
Copy link
Author

Dip98 commented Nov 1, 2024

I think it does have to do with the chunk borders, because today I came across two trees close together that both had the same glitch in the same spot. (it makes more sense if you look at the photos.)
Random stuf
Random Stuff

@Willard21
Copy link
Owner

Yeah, I knew about this before I even released the update that caused it. It was just too annoying to fix, so I put it off for later.

It's caused by generating chunks, then moving away, which deletes the farthest chunks from memory, then moving back. The tree trunks stay in loaded chunks, while the leaves are in a deleted chunk. So when the deleted chunk get regenerated, the tree doesn't get regrown (since the tree's chunk wasn't deleted), so it doesn't generate the leaves back.

The bug only applies to trees and the little puddles that spawn in places, and possibly caves that touch the border of a chunk without crossing it.

@Willard21 Willard21 added the bug Something isn't working label Nov 3, 2024
@EliasElliotson
Copy link

@Willard21 Oh neat! Thanks for explaining that, it's cool to know the nerd knowledge behind how it works :)

@Willard21
Copy link
Owner

Recommended fix would be that when a chunk edits neighboring chunks during its generation, it stores those edits internally. Then when the neighboring chunk generates, it asks its 8 neighbors what edits they made to it. Lighting would work similarly, but without storing anything extra; when a chunk generates, it checks for brighter lights at the edge of the neighboring chunk.

A major advantage of this is that it would allow chunks to be generated completely independently of each other. That would allow multithreading more of the chunk generation process, and it would also make it so only 2 unrendered layers of chunks would need to exist outside the render distance. Currently there's 4 unrendered layers, which at max render distance is 1104 invisible chunks. With only 2 layers, it would only be 536 invisible chunks. The savings should offset the memory cost of storing the extra data.

So the new world gen order would be:

  1. In workers, generate the terrain.
  2. In workers, spawn ore deposits.
  3. In workers, carve caves.
  4. In workers, place trees.
  5. Pass chunk block data and edits to neighboring chunks to the main thread to be stored.
  6. Pass chunk block data, edits to the chunk that the neighbors made, and any compressed save data for the chunk to a worker.
  7. In workers, apply neighboring chunks' block edits.
  8. In workers, apply save data.
  9. In workers, apply lighting.
  10. Pass block and lighting buffers back to the main thread.
  11. In main, apply neighboring chunks lighting.
  12. In main, generate mesh.

Steps 1-5 are stage 1.
Steps 6-10 are stage 2.
Steps 11-12 are stage 3.
At each stage, the surrounding chunks are certain to have finished the previous stage. The data being passed all around would be simpler if SharedArrayBuffers were available on KA, but they aren't so it has to be done by transferring ownership back and forth, or copying the data if multiple threads need access at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants