public interface CloneableSmartAsset
extends java.lang.Cloneable
CloneableSmartAsset
interface allows use
of cloneable smart asset management.
Smart asset management requires cooperation from the AssetKey
.
In particular, the AssetKey should return WeakRefCloneAssetCache
in its
AssetKey.getCacheType()
method. Also smart assets MUST
create a clone of the asset and cannot return the same reference,
e.g. createClone(someAsset)
!= someAsset
.
If the AssetManager.loadAsset(com.jme3.asset.AssetKey)
method
is called twice with the same asset key (equals() wise, not necessarily reference wise)
then both assets will have the same asset key set (reference wise) via
AssetKey.AssetKey()
, then this asset key
is used to track all instances of that asset. Once all clones of the asset
are garbage collected, the shared asset key becomes unreachable and at that
point it is removed from the smart asset cache.
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Creates a clone of the asset.
|
AssetKey |
getKey()
Returns the asset key that is used to track this asset for garbage
collection.
|
void |
setKey(AssetKey key)
Set by the
AssetManager to track this asset. |
java.lang.Object clone()
Object.clone()
for more info on how this method
should be implemented.void setKey(AssetKey key)
AssetManager
to track this asset.
Only clones of the asset has this set, the original copy that
was loaded has this key set to null so that only the clones are tracked
for garbage collection.key
- The AssetKey to setAssetKey getKey()