Skip to content

Animation loop

All the scenes in SOFA must include an AnimationLoop. This component orders all steps of the simulation and the system resolution. At each time step, the animation loop triggers each event (solving the matrix system, managing the constraints, detecting the collision, etc.) through a Visitor mechanism (see below). In a scene, if no animation loop is defined, a "DefaultAnimationLoop" is automatically created.

Several AnimationLoops are already available in SOFA:

  • DefaultAnimationLoop: this is the default animation loop as the name indicates! This animation loop is included by default at the root node of the graph, if no animation loop is specified in the scene. With a DefaultAnimationLoop, the loop of one simulation step follows:

    1. collision detection is triggered through the collision pipeline (if any)
    2. solve the physics in the scene by triggering the integration scheme, taking the constraint, collision into account
    3. update the system (new values of the dofs), the context (dt++), the mappings and the bounding box (volume covering all objects of the scene)
  • MultiTagAnimationLoop: this animation loop works by labelling components using different tags. With a MultiTagAnimationLoop, the loop of one simulation step is the same as the DefaultAnimationLoop, except that one tag is solved after another, given a list of tags:

    1. For each tag defined:
    2. collision detection is triggered through the collision pipeline (if any)
    3. solve the physics in the scene by triggering the integration scheme, taking the constraint, collision into account
    4. update the system (new values of the dofs), the context (dt++), the mappings and the bounding box (volume covering all objects of the scene)
  • MultiStepAnimationLoop: given one time step, this animation loop allows for running several collision (C being the number of collision steps) and several time integrations in one step (I being the number of integration time steps), where C and I can be different. If the global time step is noted dt, the time integration time is actually: dt' = dt / (C.I). The loop in one animation step is:

    1. compute C times the collision pipeline within one time step dt
    2. For each collision step, solve I times the linear system for time integration using the time step dt'
    3. update the context, the mappings, the bounding box (the visualization is done once at each time step dt)
  • FreeMotionAnimationLoop: this animation loop is used for simulation involving constraints and collisions. With a FreeAnimationLoop, the loop of one simulation step follows:

    1. build and solve all linear systems in the scene without constraints and save the "free" values of the dofs
    2. collision detection is computed thus generating constraints
    3. constraints are solved as one system to compute a correction term taking into account the collisions & constraints
    4. update the mappings, the bounding box