+1
Not a bug

LOD not working properly when moving trees

Leon 6 years ago updated by Aaron Brown 6 years ago 4

I am working on an AR game where I have a small city that can be placed in AR. However the LOD calculation calculates from Camera to original tree positions, not the ones where they are placed after. So basically you can get really close to the trees and they will still be billboard LOD. Is there a way to update this at runtime so the LOD still works properly after moving the trees to a new location?

Answer

Answer
Not a bug

The function that needs to be called is the "recalculate parents" function. There should be a button for it in the LushLOD Trees Manager window. Or, you can manually call that function from your code. The function is located in the _LushLODTreesManager.cs file. Any time you add any new trees, and any time you move any trees around, that function needs to be called again.

Answer
Not a bug

The function that needs to be called is the "recalculate parents" function. There should be a button for it in the LushLOD Trees Manager window. Or, you can manually call that function from your code. The function is located in the _LushLODTreesManager.cs file. Any time you add any new trees, and any time you move any trees around, that function needs to be called again.

Hi,

Thanks for you quick reply. I however can't seem to get it to work. I have setup a bunch of trees, some are close to the camera and show as higher LOD, some are further away and show as lower LOD. When i move a lower LOD tree close to the camera and call ReCalculateParents from code the tree still stays as it it was far away. Any idea what I am doing wrong? Thanks! 

Ah i had to call ApplyAll after the ReCalculateParents, seems to work now.

EDIT: ApplyAll without ReCalculateParents does the trick.

ApplyAll is meant to apply any changes that you made to the settings in the manager. So if you change some slider bar or change the LOD value, you have to click applyall to apply the change. Once you've click ApplyAll, you shouldn't need to click it again unless you change something in the manager. So then, once you've clicked applyall, and then you change nothing in the manger, but you move a tree, it should have no affect to click applyall again? Because there's no changes to apply? I would think that if you've clicked applyall once, then from that point on if you move a tree, you would still need to click recalculate parents each time you move a tree. 

Basically, the ApplyAll button applies changes made in the manager, to the trees. 

But recalculate parents button, associates trees with each other, based on their proximity to each other. And that's why if you move a tree, it's proximity to other trees around it changes, which is why you need to recalculate parents. My trees do not all claculate their distance to the camera, as that would be very expensive to do for a large number of trees in the scene. So instead, I designed this parenting system. The "parents" calculate their distance to the camera, and if the camera gets close to a parent, then the parent tells all the nearby trees around it, to start their LOD transitionins as needed. This is why if you move a tree, it may need to be assigned to a different "parent", or else it will not receive the message to start its LOD transition when it is supposed to. That's what the recalculate parents button is for, and that's why you need to click it each time you move or add new trees to the scene. I can't remember if the apply all button actually calls recalculate parents for you, but I don't think it does, so I'm not sure why clicking it fixed anything, but if it did then that's great. :)