Custom AssetLoader and caching objects


I created custom AssetLoader classes to load models in formats I’m used to working with.

As I understand the AssetManager has a mechanism to cache loaded data.

I am wandering how far does it go and what is it’s impact on custom AssetLoaders - I have two questions:

  1. If load the same mesh multiple times using the AssetManager do all created objects use separate copies of the loaded mesh or references to a single object?

  2. If I load a mesh using a custom AssetLoader do I have to make any specific steps to have it cached? If yes what are these?

    thanks a lot for any help :slight_smile:

You can control that through the various clone() methods. Meshes are normally shared when theres no animation on the model.

If your asset key specifies that it does cache (look at ModelAssetKey for an example), then the asset that is returned from your AssetLoader must be able to clone(), this is called in the createClonedInstance method in assetKey. The clone method takes in the existing (already loaded) object and lets you clone a new one from it.