RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
1.02k stars 178 forks source link

The simulation loop design #1574

Closed ohlidalp closed 2 years ago

ohlidalp commented 6 years ago

I have a very large redesign of RoR in my head (devmaster9 is just a start), and I'd like every further git-commit to be a step towards that design. I'm using a GitHub issue rather than RoR forum because my employer blocks RoR website, and I need to stay in contact.

I'm writing this down to help myself calm down in the current coding hurricane and to sync up with other devs' ideas and visions. This doesn't mean I want to re-shuffle anything, just to explain why I focus on some things and ignore others.

Terminology

Devmaster9

For each rendered frame:

  1. Sync Sim Tasks (threadpool)
  2. Legacy per-frame Sim + OGRE updates:
    1. Local player inputs (GUI, keyboard, mouse, gamecontrollers...)
    2. Network inputs
    3. Scripting
    4. Camera
    5. Stuff... :smile:
  3. Update SimBuffers
  4. Update simulation (Start Sim Tasks)
  5. Update OGRE scene and render:
    1. Start Flex tasks
    2. Update non-Flex OGRE scene elements, including GUI
    3. Sync Flex tasks, update related OGRE scene elements
    4. Invoke rendering

Ideal

For each simulation step (PHYSICS_DT):

  1. Update player inputs (GUI, keyboard etc...) - Will enable recording/replaying macros and exact benchmarking
  2. Update network inputs (UDP protocol) - Will enable networked collisions.
  3. Invoke scripting (SIMULATION* hooks, see https://github.com/RigsOfRods/rigs-of-rods/issues/1558#issuecomment-420234219)
  4. Update simulation
  5. If it's time to render, update SimBuffers and launch all OGRE scene updates + scripting (FRAME hook) + rendering on background.

Softbody data handling.

Feedback needed

This is what I want to archieve in the long run. Does it make sense? What steps (and in what order) will get us there?

ohlidalp commented 2 years ago

Closing as partially done and generally out of date. The remaining points were moved to #2981.