Simsilica/SimEthereal

Objects that don't get updated look removed

Closed this issue · 0 comments

SimEthereal was built to assume that all objects being managed would be updated every frame even if they weren't moving. Unfortunately, for some physics engines that try to be extra efficient, we don't normally see update notifications for objects that have gone to sleep. Working around this at that level is quite inconvenient and may lead to a bunch of state duplication.

On the other hand, SimEthereal uses this to its advantage by letting this automatically expire objects from zone views. The NetworkStateListener can easily determine if an object is no longer in the player's local view by nature of not having received an update. This is an elegant way to detect this since an object might otherwise be in multiple zones at once (even within the player's view). So receiving no updates for some object is an easy way to guarantee that it does not appear in ANY of the player's visible zones.

There is another related issue to this in that if a zone has no active objects at all (even if it does have children) then it will stop updating completely. The NetworkStateListener doesn't even have a chance to send out the removals in this case and the objects continue to be 'in view' even as the player moves many zones away. That's clearly a bug.

After much thinking about that, I think one enhancement can be made that covers these cases at the expense of a little book-keeping. The idea would have to have the Zone and its current StateBlock to keep track of the children of that zone that have not received updates. Then, similar to removals, we can handle these 'non-updates' in a special way. NetworkStateListener could loop over them and provide no-op style state updates to the SharedObjects, etc. just to update their timestamps. Maybe someday we even think of a more efficient way to send no-ops... but this way is pretty efficient when the baselines are already in sync.