fixed asset linked node to reuse shared data between loaded models. (#739)
* fixed asset linked node to reuse shared data between loaded models. * updated implementation of binary loader.empirephoenix-patch-1
parent
94e828f92e
commit
556e3de1c0
@ -0,0 +1,41 @@ |
||||
package com.jme3.export.binary; |
||||
|
||||
import com.jme3.asset.AssetInfo; |
||||
import com.jme3.asset.AssetLoader; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.ArrayDeque; |
||||
import java.util.Deque; |
||||
|
||||
/** |
||||
* The default loader to load binaries files. |
||||
* |
||||
* @author JavaSaBr |
||||
*/ |
||||
public class BinaryLoader implements AssetLoader { |
||||
|
||||
/** |
||||
* The importers queue. |
||||
*/ |
||||
private final Deque<BinaryImporter> importers; |
||||
|
||||
public BinaryLoader() { |
||||
importers = new ArrayDeque<>(); |
||||
} |
||||
|
||||
@Override |
||||
public Object load(final AssetInfo assetInfo) throws IOException { |
||||
|
||||
BinaryImporter importer = importers.pollLast(); |
||||
|
||||
if (importer == null) { |
||||
importer = new BinaryImporter(); |
||||
} |
||||
|
||||
try { |
||||
return importer.load(assetInfo); |
||||
} finally { |
||||
importers.addLast(importer); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue