use of com.badlogic.gdx.utils.Disposable in project nhglib by VoidZombie.
the class NhgModelLoader method loadSync.
@Override
public Model loadSync(AssetManager manager, String fileName, FileHandle file, P parameters) {
ModelData data = null;
synchronized (items) {
for (int i = 0; i < items.size; i++) {
if (items.get(i).key.equals(fileName)) {
data = items.get(i).value;
items.removeIndex(i);
}
}
}
if (data == null)
return null;
final Model result = new Model(data, new TextureProvider.AssetTextureProvider(manager));
// need to remove the textures from the managed disposables, or else ref counting
// doesn't work!
Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
while (disposables.hasNext()) {
Disposable disposable = disposables.next();
if (disposable instanceof Texture) {
disposables.remove();
}
}
// Automatically convert all materials to PBR
for (Material material : result.materials) {
TextureAttribute textureAttribute = (TextureAttribute) material.get(TextureAttribute.Diffuse);
if (textureAttribute != null) {
material.set(PbrTextureAttribute.createAlbedo(textureAttribute.textureDescription.texture));
}
}
data = null;
return result;
}
use of com.badlogic.gdx.utils.Disposable in project nhglib by VoidZombie.
the class EngineStateClosing method enter.
@Override
public void enter(NhgEntry nhgEntry) {
Logger.log(this, "Engine is closing.");
nhgEntry.engineClosing();
ImmutableBag<BaseSystem> systems = nhgEntry.nhg.entities.getEntitySystems();
for (BaseSystem bs : systems) {
if (bs instanceof Disposable) {
((Disposable) bs).dispose();
}
}
nhgEntry.nhg.assets.dispose();
nhgEntry.nhg.threading.terminate();
Gdx.app.exit();
}
Aggregations