Skip to content

Asynchronous simulation loop#290

Draft
alxbilger wants to merge 11 commits into
sofa-framework:masterfrom
alxbilger:threadvisu
Draft

Asynchronous simulation loop#290
alxbilger wants to merge 11 commits into
sofa-framework:masterfrom
alxbilger:threadvisu

Conversation

@alxbilger

@alxbilger alxbilger commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Rendering and simulation loops run asynchronously. This allows different update frequencies. The rendering loop enables VSync, such that it runs at the frequency of the monitor (in my case 60 Hz), while the simulation loops runs as fast as possible.

The rendering and GUI is always responsive, even for slow simulations, running much slower than the rendering frequency. On the opposite, if the simulation is much faster, the rendering loop always runs at the frequency of the monitor, limiting the accesses to GPU resources.

Until now, the rendering and simulation loops were run sequentially. With the asynchronicity, the accesses to the scene graph and SOFA data structures becomes thread-unsafe. To allow to keep rendering a mesh responsively, the scene to be rendered is captured at every simulation tick. The rendering loop always renders the latest snapshot.

To do:

  • Capture the camera properties to remove all the camera accesses in the rendering loop
  • Investigate VisualParams thread-safety
  • Implement a command queue for the GUI
  • Capture all the displayed Data in the GUI
  • Deal with Visual models
  • Deal with OglSceneFrame
  • Capture DrawTool features (lighting, blending etc)
  • Show the physics frequency in imgui
  • Deal with the video recorder
  • Indication that the simulation is running after a given timeout

Example where the sim runs faster than the rendering:

simu_faster.mp4

Example where the rendering is faster than the sim:

sim_slower.webm

@alxbilger alxbilger added enhancement New feature or request pr: status wip labels Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pr: status wip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant