Houdini Engine 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages

Houdini Caches

This feature is only available in 15.0.377 or newer builds of 15.0.

Houdini uses caching in several different areas to speed things up. For example, there is a SOP Cache that stores intermediate results for faster re-cooks. To see a list of all active caches in Houdini just go to Windows > Cache Manager.

To get that list of active caches from within HAPI you can call these two pair functions:

There is a list of standard cache names in form of defines:

/// Common cache names. You can see these same cache names in the
/// Cache Manager window in Houdini (Windows > Cache Manager).
#define HAPI_CACHE_COP_COOK "COP Cook Cache"
#define HAPI_CACHE_COP_FLIPBOOK "COP Flipbook Cache"
#define HAPI_CACHE_IMAGE "Image Cache"
#define HAPI_CACHE_OBJ "Object Transform Cache"
#define HAPI_CACHE_GL_TEXTURE "OpenGL Texture Cache"
#define HAPI_CACHE_GL_VERTEX "OpenGL Vertex Cache"
#define HAPI_CACHE_SOP "SOP Cache"
#define HAPI_CACHE_VEX "VEX File Cache"

To get information on a given cache, like current usage and maximum limit, call:

with the appropriate HAPI_CacheProperty:

/// Current memory usage in MB. Setting this to 0 invokes
/// a cache clear.
HAPI_CACHEPROP_HAS_MIN, ///< True if it actually has a minimum size.
HAPI_CACHEPROP_MIN, ///< Min cache memory limit in MB.
HAPI_CACHEPROP_HAS_MAX, ///< True if it actually has a maximum size.
HAPI_CACHEPROP_MAX, ///< Max cache memory limit in MB.
/// How aggressive to cull memory. This only works for:
/// - ::HAPI_CACHE_COP_COOK where:
/// 0 -> Never reduce inactive cache.
/// 1 -> Always reduce inactive cache.
/// - ::HAPI_CACHE_OBJ where:
/// 0 -> Never enforce the max memory limit.
/// 1 -> Always enforce the max memory limit.
/// - ::HAPI_CACHE_SOP where:
/// 0 -> When to Unload = Never
/// When to Limit Max Memory = Never
/// 1-2 -> When to Unload = Based on Flag
/// When to Limit Max Memory = Never
/// 3-4 -> When to Unload = Based on Flag
/// When to Limit Max Memory = Always
/// 5 -> When to Unload = Always
/// When to Limit Max Memory = Always

Conversely, to set properties on a cache call:

Of note here is that setting the HAPI_CACHEPROP_CURRENT to 0 will clear the cache.

Geometry Caching

Houdini supports saving geometry data to a variety of files, and this functionality can now be accessed through Houdini Engine. Given a unique set of asset, object, and geo ids that identifies a geometry, the data in the geometry may be dumped to either a file or a memory buffer. A corresponding load function can later read the file or memory and put the geometry back onto a node.

Geometry Files

The HAPI_SaveGeoToFile() function takes a file name and saves the geometry to the file. The format of the file will be determined by its extension. Supported formats include:

  • abc
  • bhclassic.lzma
  • bhclassic.bz2
  • bgeo
  • bgeo.bz2
  • bgeo.lzma
  • dxf
  • eps, ai
  • geo.bx2
  • geo.lzma
  • hclassic.bz2
  • hclassic.lzma
  • iges, igs
  • lw, lwo
  • obj
  • ply
  • stl, bstl
  • pc, pmap

To load a geometry file back, use the HAPI_LoadGeoFromFile() function.

Geometry Buffers

To Save geometry to memory, first use the HAPI_GetGeoSize() function to get the size of the buffer required to store the geometry in the format you requested. Note that this operation is stateful, as it will cache the geometry in memory. When the HAPI_SaveGeoToMemory() function is called next, the cached geometry will be copied into the buffer provided. HAPI_LoadGeoFromMemory() is the loading counterpart to put the data back onto a SOP node. Finally, note that as only the bgeo format is native to Houdini, it is the most efficient to save and load. All other formats require an internal conversion mechanism, and the architecture of that system is designed to hit the file system - so those operations will be much slower than saving and loading the bgeo format.