OpenBVE icon indicating copy to clipboard operation
OpenBVE copied to clipboard

Experimental: Improve forced updates when large numbers of Animated Objects are present

Open leezer3 opened this issue 1 year ago • 0 comments

https://github.com/leezer3/OpenBVE/issues/955

The (essential) cause of the above issue is that it uses large numbers of animated objects, all of which contain functions which are costly to execute.

The game executes a forced update on all world animated objects in the two following circumstances:

  • At game start
  • After a jump (manual / change ends)

If our world contains thousands of animated objects, each of which contains one or more heavy functions, this can bog down significantly, and cause the slow loading above.

This PR does the following:

  • Implements a custom equality operator for animated objects. (This speeds up some aspects of the update)
  • On a forced update, only objects placed within 5km of the camera position or having a TrackFollowerFunction will be evaluated.

This brings the loading time of the linked route above to a sensible level, and as a bonus improves loading times for anything using lots of animated objects.

RISKS:

Actually, I'm not sure, and this is what concerns me a little. There was obviously a reason for updating all animated objects. but I can't immediately think of one. Any objects present after a jump should be culled before the start of the frame with the standard visibility update routine.

https://bveworldwide.forumotion.com/t2168-building-a-route-based-on-the-staten-island-railway-integrated-into-the-nyc-subway-system-download-update-10-24-2023#21704

Should be properly tested with the above, as another instance of massive animated function use.....

leezer3 avatar Nov 09 '23 18:11 leezer3