ApanLoon / UnitySL

A port of some of the subsystems of Indra Second Life
9 stars 4 forks source link

ViewerObjects: Sort the oct tree #52

Open ApanLoon opened 1 year ago

ApanLoon commented 1 year ago

Is it plausible to do this for optimizing rendering of viewer objects?

1) Sort each cell in the oct tree that contains all the ViewerObjects by the falling square size of the two largest dimensions of each object? (Only using the two largest dimensions means that very flat but otherwise large prims will be visible from a large distance) 2) Then, before rendering (when the player moves?), loop through all the cells within view distance of the player 3) For each cell, loop through all the ViewerObjects and compute something like "size / distance". It should be possible to map this value to the LOD range. Store this LOD value in the ViewerObject.

If this is a heavy operation, it should be possible to parallelize it by spreading out one or more cells to separate threads.

When all LODs has been calculated, the LOD of the GameObject that corresponds to each ViewerObject can be set and if the LOD value in the tree is is outside the LOD range, the GameObject will be disabled. This step probably has to be done in the main thread since that is the only one with access to the actual GameObjects.

ApanLoon commented 1 year ago

Also, when a ViewerObject moves, i.e. is (re-)inserted into the oct tree, the LOD calculation should be updated based on the current player position.