How much of a spatial can be cached and re-used? In my scene I have lots of spatials using the same textures and same sizes. Can I cache (in a hashmap) the instances I create and reuse those on the spatials I want to create and position ?
Maybe the engine could provide a way to cache assets for you. Sort of a “manager of assets” if you will. Something that could manage the caching of assets so you just request them and they are automatically cached.
…perhaps we could call it the “AssetManager”.
Seriously, though… the AssetManager is already caching textures, meshes, etc. for you. When you load a model, you are only getting a clone of it with whatever shared that can be shared.
It tries to be really smart about it… so hopefully you get what you are looking for “for free”.
For example, if the mesh is not animated then it will be completely shared between reloaded instances. If the mesh is animated then some of the vertex buffers will be shared, etc…
…but textures are definitely cached for sure.
Moreover, it uses a weak reference map for caching, which means when there is no spatial of a specific model key referenced anymore, AssetManager will remove it from the cache also.