Using the Cache

As introduced under Initializing and Terminating Beast, most calls to the Beast API are done within the context of a Beast Manager, which handles memory management and object creation tasks. Each Beast Manager stores records of objects such as meshes and textures in a file cache. You may be able to increase the speed of your baking by re-using the meshes and textures from the cache rather than re-creating them from their corresponding game objects each time you render a level.

You can re-use these objects in two ways:

The contents of your cache can also aid Autodesk support in diagnosing problems or unexpected results that you may encounter when using Beast. You may be asked to provide your cache, so that support engineers can attempt to reproduce your problem using the same set of data.

Setting up cache sharing

In order for a Beast Manager to be able to share meshes and textures that were added to the cache by a different Beast Manager:

These values are set when the Beast Manager is created. See the ILBCreateManager() function.

Note that both Beast Managers need to have access to read, write and delete files in the cache directory.

Finding cached objects

You can retrieve an object from the cache by the unique name that you specified at the time the object was created. You can retrieve:

Each of the functions listed above requires you to provide a pointer to a handle of the appropriate type. If an object of the requested type with the specified name is found in the cache, the handle you provide is updated to point to the retrieved object. If no matching object could be found in the cache, the handle is not updated and the function returns ILB_ST_UNKNOWN_OBJECT. Your code should handle this case by re-creating the object from scratch from the corresponding game object.

Invalidating cached objects

All cached objects can be removed (invalidated) by calling ILBClearCache().

If any other resource in the same Beast Manager is currently referring to the object you try to erase (e.g. if a scene contains the texture that you want to erase), your call will fail. However, note that if any object handles exist that already refer to the erased object, those handles will be invalidated. Any further use of those handles will cause undefined behavior.

Updating cached objects

If the source of an object that exists in the cache is changed in your level design tool or game editor, you need to introduce a mechanism to ensure that you do not keep re-using the cached version of the object the next time you render your scene. You can either: