In an editor application, caching causes problems. When you write an asset and then read it, you want to get the newer version, not the one in the cache. When I first encountered this, I worked around it by invoking DesktopAssetManager.clearCache() before every load. But this works only on a desktop, and it flushes everything from the cache, not just the one asset I’m trying to load.
So I created a class UncachedModelKey extends AssetKey<Spatial> specifically for the purpose of bypassing the cache during a loadAsset(). In particular, UncachedModelKey.getCacheType() returns null.
So far, so good. My question is, what should UncachedModelKey.getProcessorType() return?
Since Spatial implements CloneableSmartAsset, DesktopAssetManager.registerAndCloneSmartAsset() insists the AssetProcessor cannot be null. But if I return CloneableAssetProcessor.class, I get an IllegalStateException:
Apr 04, 2017 9:39:03 PM com.jme3.app.LegacyApplication handleError SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main] java.lang.IllegalStateException: Asset implements CloneableSmartAsset but doesn't have cache or was not cloned at com.jme3.asset.DesktopAssetManager.registerAndCloneSmartAsset(DesktopAssetManager.java:321) at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:379)