anyKode Marilou
ContentsIndexHome
PreviousUpNext
Accelerate the simulation

How to Accelerate the simulation.

When the simulation grows (physics and/or 3D display), it is possible that your CPU and/or video card become too slow for running the simulation. In most case, you can optimise the simulation and free some CPU/video resources in order to keep real/accelerated time in good conditions. There are two ways for accelerating the simulation (Exec): acting on 3D rendering and physics modeling. 

 

Acting on 3D rendering:

 

Use low polygon models: the 3D rendering time is directly dependant of the number of triangles to draw. If you are using some 3D models, use the MeshTool (or other tool) in order to create low polygons models. If the 'compute shadows' parameter is checked, the shadow volume is created from the primary mesh: that's mean that the shadow volume complexity is high when the mesh complexity is high. 

 

Prefer choosing simple geometries for shadow volume: 

If you are using a mesh file for a physics geometry display, check the 'compute shadows' property from the physics geometry (instead of from the mesh). Because physics geometries are very low polygon, the corresponding shadow volume complexity is very low too and of course very fast to draw. 

 

Do not use 'compute shadows' for small object: 

In most case small objects's shadowing is not useful in the 3D display and add additional rendering time ... Prefer use shadows for large objects like walls, floors or robots base and wheels and ignore it for small details. 

 

Do not use the 'generate dynamic shadows' light's property if not required: 

In some case like LED display or very short range lights, it is not required to generate shadows in the video card. This operation is long and not useful for low range lights. 

 

Use small lights count on the same location

Every object in the scene is drawn one time for each light which touch the object. In other worlds, if an object is lightened by 10 lights, it is drawn 11 times (10 lights + ambient pass). Then, prefer add one BIG light in the location instead of several low range lights. 

 

Disable helpers display: 

In Exec, you can choose to display distance sensors rays, air pressure rays, contacts points and other helpers: because they are out of the rendering general process, these 3D objects are consuming a lot of video card resources. 

 

Acting on physics properties:

In most case the physics computing consumes more processor resource than the 3D display or other processes. You can act on the physics, global configuration and devices properties for accelerate the simulation. 

 

Do not use a feature if not required: 

In the general case, every enabled feature consumes more CPU time than the disabled ones ! 

For exemple: gyroscopic effect, resistive torques and forces, spring, limits and other physics features do not consume any CPU when disabled. It is important that you choose exactly the feature you need and disable the others. 

 

Reduce the contact points count: 

The simulation complexity/speed is directly pow(DOF , 2) dependant. DOF is the degrees of freedom declared in the simulation for 1 timestep: it is equal to the number of axes you are using (joints) + the number of contacts points generated dynamically in the scene ! That's mean that if you have a lot of physics objects in the scene, you will have a lot of DOF. For exemple, a box over another box can generate up to 12 contact points. 

 

  • Use the contacts management (from physics geometry properties): you can reduce the number of contact points that the geometry is allowed to create in a given situation. For exemple a table's foot don't need to create more than one contact point with the floor ... (4 foots = 4 contact points : enough to make the table stay on the floor).
  • Use the Autodiable feature (from body's properties): autodisable stops to create contact points when the entire body speeds are below a defined threshold. In other words, if a body is stabilized, no contact point is generated. The autodisable computing must be allowed in the configuration-> Physics panel.

 

Use kinematic bodies: 

It is very faster to compute the physics of a kinematic body than a dynamic one. Use the kinematic property each time the object does not have to move: wall, static object, robot that is glued on the floor ... The kinematic property is faster than using the fixed joint connected to the static environment (NULL body). Also, this property locks body's position and reduce the joints chain instabilities. 

 

Disable/remove unused devices: 

If a device is not used, prefer disabling it: a disabled device is not created at Exec startup. A device in Off or AutoOn startup state is updated like the other devices. According to the device function, the update time in these states can be faster than the On state but is not equal to 0. 

 

Reduce the 3D frame rate: 

By default, the 3D rendering is done every 30 simulated ms. There is several case where 3D rendering slow down the physics process:

  • 1 processor computers: Marilou is built on a multiprocessor architecture that allows to separate 3D computing and physics management. If your computer have 1 processor, the 3D pre-computing consumes time that should be useful for the physics.
  • You are using Camera devices: camera device cannot create its images if a 3D display is already running (DirectX limitation): in this case, the physics process is awaiting the end of the 3D rendering.

 

Try to use the iterative method (configuration->Physics): 

There are two ways for solving the physics: solver (slow and accurate) and iterative (fast and less accurate). Try to use the iterative method if your project don't need excessive accuracy ...

Documentation v4.7 (18/01/2015), Copyright (c) 2015 anyKode. All rights reserved.
What do you think about this topic? Send feedback!