StructureTree.GenerateTrunkPart() & StructureTree.GenerateCrownPart() Called At Least Four Times Per Tree
aesliva opened this issue · comments
Tried finding a way to speed up structure generation times and found this out in the profiler. Had 30 trees spawn, and saw that GenerateTrunkPart() was called 124 times, while GenerateCrownPart() was called 172 times.
Was looking for the cause, but couldn't figure it out. I'll look into it more when I have time. Just wanted to report it. ;)
Fixed problem by checking to see if we built a structure there before. Now some trees are only partially generated.
If there's a structure placed at the edge of a chunk or if the structure is sufficiently big it can spread over multiple chunks. Because of that, it's okay for some methods to be called multiple times for one structure because there're called for a different part of it (if I remember correctly).
However, I find this whole system rather unfortunate and I implemented it only so that there's something working. Let's call it 0.1 :)
That's what I figured. Interestingly though, when I check to see if a tree had already spawned where another tree is trying to spawn I found that these methods were only called for the amount of trees visible, fixing the 'problem'. The trees were even generating across chunks, but for some reason there are a few exceptions where they don't. I haven't figured out why yet, just left it at that for the time being.