5.6.2. Cache Files for Faster Scene Loading

Before the first rendering of a scene with DirectViz, building the geometry objects and computing the associated internal acceleration structure can take a significant time, especially for scenes with very large number of polygons. This internal structure can be saved to or loaded from the hard disk.

DirectViz allows you to associate a cache file with an Open Inventor scene graph. Launching DirectViz to render a scene graph with a corresponding cache file on disk avoids the re-creation of the internal structure and speeds up startup before the first render.

The file caching mechanism is enabled by the SoPreferences SoPreferences SoPreferences DIRECTVIZ_FILE_CACHING configuration parameter or the SoDirectVizManager SoDirectVizManager SoDirectVizManager fileCaching field.

To use this mechanism, the directory for cache files must be set via the SoPreferences SoPreferences SoPreferences parameter DIRECTVIZ_CACHE_DIR or using the method setCacheDirectory () of SoDirectVizManager SoDirectVizManager SoDirectVizManager . This directory will contain all the cache files needed by DirectViz for reading and writing. If cache files must be loaded, make sure that they are located in this directory.

[Warning]

File caching in cluster mode (see section below for more details)

  • If the DirectViz file caching mechanism is used, make sure that cache files are accessible from the slave nodes at the same location (same path) used on the master.

  • The cache files should be saved when running in stand-alone mode and be used for reading in cluster mode.

There are two ways to use the cache mechanism: by method calls or automat ically.

The cache file can be automatically fetched from the current cache files directory by DirectViz based on a “signature” of the scene graph. A signature corresponding to a specific scene graph is stored in each cache file. One cache file can only represent one scene graph. In most cases there is no need to manually specify cache files. However your application is still responsible for managing and updating the cache files appropriately (e.g., deleting invalid files).

[Important]

A scene graph signature association is started after the first traversed shape, i.e., it is not dependent on the property nodes traversed at the beginning of the scene graph.

  • Un-traversed SoSwitch SoSwitch SoSwitch nodes are not part of the signature.

  • Two scene graphs with the same nodes at the same positions but with different shape organizations will have the same signature.

  • To avoid problems, specify the cache file with the method described above.

[Warning]

As they are tied to internal data structures, the cached files may not be compatible between different platform architectures, 32-bit and 64-bit systems, different operating systems, or different versions of DirectViz. The cached files may also be dependent on the shader package used.