Jump to content

Recommended Posts

Posted (edited)

(Pun intended)

I had a very tall pine tree grow in a valley next to a spire and I wasn't in the mood to prune the top by hand, so I chopped it down. Imagine my surprise when not all of the tree came down:

2023-06-23_01-49-56.thumb.png.869161083f26b3f4a3916d24a703bf06.png

Those are leaf blocks, holding the treetop onto the rock face horizontally. I think there needs to be some better rules about what makes leaf and branch blocks pop.

My proposal is that leaf and leafy branch blocks are considered 'supported' and don't pop if:

  • There is any solid block beneath them.
  • There is an adjacent log block of the same tree type in any direction.
  • There is an adjacent leafy branch block of the same tree type that is 'supported' in any direction (will require recursion over branch blocks to find a base).

Essentially, leaf blocks should not support other leaf blocks or branches. If there are two trees close enough that their leaves are touching, cutting down one tree will remove its top, leaving the other's. This may mean adjusting tree generation so that there are more branch blocks for structure but will leave shrubs intact.

Edited by Bossman
  • Like 1
Posted (edited)

Thing is... these suggestions of yours? They're already in the game. That's how trees have always worked.

The problem is that a leaf block needs to realize it is no longer supported in order to make the decision to despawn. And you cannot just have the game update every block all the time. The game would be so busy doing that it wouldn't do anything else, like for example letting you play. There are just too many blocks in the world.

Most of the time, leaf blocks get updated when adjacent blocks get updated. But there's also the dedicated treechop subroutine, which is tasked with bringing the whole tree down when you chop just a single block at the bottom. This routine must guess what the tree actually is. You as a human may see a tree, but the game only sees tables of coordinates with block IDs assigned to them. So there is a heuristic in place that recursively looks for adjacent log and leaf blocks. But it can't be just that, because if it was, you could chop an entire forest down at once so long as any single chain of leaf blocks keeps connecting tree after tree after tree. No, that heuristic must also be able to guess when a tree stops. When a connected block is no longer part of the same tree. And that is actually the most complicated and difficult part of that entire piece of code.

For the longest time, Vintage Story's tree chopping heuristic was very... optimistic, shall we say, about the size of trees. It pretty much always sheared neighboring trees of their leaves whenever you chopped down a tree, which was not just an eyesore but also risked wasting seeds of valuable trees because leaf blocks destroyed from treechopping drop far fewer seeds (and sticks) than leaf blocks broken directly by the player. In 1.18, this heuristic was adjusted to be more conservative, in an attempt to stop this from happening.

But in return, we now have the rare instance where the heuristic is too conservative, and leaves some leaf blocks untouched that it should really have brought down. Those blocks do not receive any updates (because the heuristic didn't identify them), and thus do not realize that they are no longer supported, and thus they do not decide to despawn. To be clear, this happens only very rarely. Maybe one out of fifty trees, in my nonscientific anecdotal gut feeling guess. But it can happen. It's a tradeoff.

 

Edited by Streetwind
  • Like 1
Posted (edited)
10 hours ago, Streetwind said:

Thing is... these suggestions of yours? They're already in the game. That's how trees have always worked.

Except my picture shows it clearly isn't. Non-branch leaf blocks are supporting the rest of treetop. I was able to remove all of those blocks by hand without removing the two leaf blocks that were next to the cliff. Every time I popped a block, the chunk update should have removed the rest, but it didn't. Because the current rules allow stone and soil to support leaves from any direction instead of just below, and non-branch blocks are allowed to support both kinds of leaf block.

Edited by Bossman
Posted

I've noticed this odd behavior as well (at least in 1.17).  Chop a larch or pine tree with branches low to the ground and the leaf blocks on the ground remain after the rest of the 20 block tall tree fell (with no other trees nearby.

  • 2 weeks later...
Posted
On 6/24/2023 at 3:03 AM, Streetwind said:

Thing is... these suggestions of yours? They're already in the game. That's how trees have always worked.

The problem is that a leaf block needs to realize it is no longer supported in order to make the decision to despawn. And you cannot just have the game update every block all the time. The game would be so busy doing that it wouldn't do anything else, like for example letting you play. There are just too many blocks in the world.

Most of the time, leaf blocks get updated when adjacent blocks get updated. But there's also the dedicated treechop subroutine, which is tasked with bringing the whole tree down when you chop just a single block at the bottom. This routine must guess what the tree actually is. You as a human may see a tree, but the game only sees tables of coordinates with block IDs assigned to them. So there is a heuristic in place that recursively looks for adjacent log and leaf blocks. But it can't be just that, because if it was, you could chop an entire forest down at once so long as any single chain of leaf blocks keeps connecting tree after tree after tree. No, that heuristic must also be able to guess when a tree stops. When a connected block is no longer part of the same tree. And that is actually the most complicated and difficult part of that entire piece of code.

For the longest time, Vintage Story's tree chopping heuristic was very... optimistic, shall we say, about the size of trees. It pretty much always sheared neighboring trees of their leaves whenever you chopped down a tree, which was not just an eyesore but also risked wasting seeds of valuable trees because leaf blocks destroyed from treechopping drop far fewer seeds (and sticks) than leaf blocks broken directly by the player. In 1.18, this heuristic was adjusted to be more conservative, in an attempt to stop this from happening.

But in return, we now have the rare instance where the heuristic is too conservative, and leaves some leaf blocks untouched that it should really have brought down. Those blocks do not receive any updates (because the heuristic didn't identify them), and thus do not realize that they are no longer supported, and thus they do not decide to despawn. To be clear, this happens only very rarely. Maybe one out of fifty trees, in my nonscientific anecdotal gut feeling guess. But it can happen. It's a tradeoff.

 

Streetwind makes some good points, I'm not sure you can actually fix this with the current system as it'll always have small errors no matter how much find tuning you do. 

Not really sure what the solution is for this one, we may have to live with this sort of error if the system is not entirely changed. 

  • 1 year later...
Posted
On 6/24/2023 at 7:03 AM, Streetwind said:

Thing is... these suggestions of yours? They're already in the game. That's how trees have always worked.

The problem is that a leaf block needs to realize it is no longer supported in order to make the decision to despawn. And you cannot just have the game update every block all the time. The game would be so busy doing that it wouldn't do anything else, like for example letting you play. There are just too many blocks in the world.

Most of the time, leaf blocks get updated when adjacent blocks get updated. But there's also the dedicated treechop subroutine, which is tasked with bringing the whole tree down when you chop just a single block at the bottom. This routine must guess what the tree actually is. You as a human may see a tree, but the game only sees tables of coordinates with block IDs assigned to them. So there is a heuristic in place that recursively looks for adjacent log and leaf blocks. But it can't be just that, because if it was, you could chop an entire forest down at once so long as any single chain of leaf blocks keeps connecting tree after tree after tree. No, that heuristic must also be able to guess when a tree stops. When a connected block is no longer part of the same tree. And that is actually the most complicated and difficult part of that entire piece of code.

For the longest time, Vintage Story's tree chopping heuristic was very... optimistic, shall we say, about the size of trees. It pretty much always sheared neighboring trees of their leaves whenever you chopped down a tree, which was not just an eyesore but also risked wasting seeds of valuable trees because leaf blocks destroyed from treechopping drop far fewer seeds (and sticks) than leaf blocks broken directly by the player. In 1.18, this heuristic was adjusted to be more conservative, in an attempt to stop this from happening.

But in return, we now have the rare instance where the heuristic is too conservative, and leaves some leaf blocks untouched that it should really have brought down. Those blocks do not receive any updates (because the heuristic didn't identify them), and thus do not realize that they are no longer supported, and thus they do not decide to despawn. To be clear, this happens only very rarely. Maybe one out of fifty trees, in my nonscientific anecdotal gut feeling guess. But it can happen. It's a tradeoff.

 

Easy, when you break a leaf block, make the game check every block directly next to this block, and if applicable, break them, restart the loop, until all the breakable leaf blocks are gone. Start a chain reaction where breaking one leaf block tests the ones immediately nearby, if any of those break, make the blocks next to that be tested, and so on until blocks stop breaking. Works fine with anything but redwoods, since those have huge leafcrowns and that may stutter the game for a split second.

Posted (edited)
1 hour ago, NastyFlytrap said:

Start a chain reaction where breaking one leaf block...

That's what he tried to explain. See all those different leaf colors? Some of that is frost, but some is not. That tells you there was more than one tree/shrub spawn in the region where he was logging. Almost certainly what happened was that when the logging algorithm tried to decide which leaves go with this tree, there was more than one leaf block to choose from, and it chose the "wrong" one. Could you change the heuristic to do the chain reaction for all possible leaf blocks? Sure, but then you get more or less the old algorithm, where it pruned all the nearby trees, too.

It's a little more complicated, too, because it's not actually breaking those blocks, but decaying them. Breaking them would give you stick and seed drops, while decay does not. They are superficially similar, but decay is a timed process using a different algorithm.

And obviously, in this case, some were touching the ground, where it should probably not be setting them to decay in the first place, as you can't tell the difference between a tree that touches the ground and a shrub that starts on the ground.

Edited by Thorfinn
  • Like 1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.